×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Multiple operations editing ?

## Multiple operations editing ?

(OP)
Hello guys,

I'm starting with NXopen, and even after I read the getting started pdf online I'm still struggling.

I'm trying to create a comand to edit several CAM operations I selected manualy, instead of modifying each one by one. The objective is to delete the body selection of those operations and select a new one.

I'm not even sure what code would be easier between making a looping on a string of all the selection, or if I try to edit the selection directly (don't even know if it's possible tho).

I tried to record a journal but I'm not advanced enought to understand everything because the code is way more dense than in themanual, and the few things I tried to change only lead to errors.

I'm working with NX 1972 or 1968, not sure of the exact number, it's not the very last version but the previous one.
And we use VB language in our company.

If anyone have an advice on how to process or I don't know, whatever that could help.
Thanks

### RE: Multiple operations editing ?

(OP)
Hello, so now that I'm at work I can say I'm working on NX 1973, and post the result :

#### Spoiler:

' NX 1973
' Journal created by baguette on Tue Aug 3 12:07:57 2021 Paris, Madrid (heure d’été)

'
Imports System
Imports NXOpen

Module NXJournal
Sub Main (ByVal args() As String)

Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work

Dim displayPart As NXOpen.Part = theSession.Parts.Display

Dim surfaceContour1 As NXOpen.CAM.SurfaceContour = CType(workPart.CAMSetup.CAMOperationCollection.FindObject("OP2_FIN-RAIDISSEUR_5"), NXOpen.CAM.SurfaceContour)

theSession.CAMSession.PathDisplay.ShowToolPath(surfaceContour1)

Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Editer OP2_FIN-RAIDISSEUR_5")

Dim markId2 As NXOpen.Session.UndoMarkId = Nothing
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Départ")

Dim surfaceContourBuilder1 As NXOpen.CAM.SurfaceContourBuilder = Nothing
surfaceContourBuilder1 = workPart.CAMSetup.CAMOperationCollection.CreateSurfaceContourBuilder(surfaceContour1)

theSession.SetUndoMarkName(markId2, "Boîte de dialogue Axe Outil Fixe - [OP2_FIN-RAIDISSEUR_5]")

surfaceContourBuilder1.PartGeometry.InitializeData(False)

Dim markId3 As NXOpen.Session.UndoMarkId = Nothing
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Départ")

Dim geometrySetList1 As NXOpen.CAM.GeometrySetList = Nothing
geometrySetList1 = surfaceContourBuilder1.PartGeometry.GeometryList

theSession.SetUndoMarkName(markId3, "Boîte de dialogue Géométrie de pièce")

Dim taggedObject1 As NXOpen.TaggedObject = Nothing
taggedObject1 = geometrySetList1.FindItem(0)

Dim geometrySet1 As NXOpen.CAM.GeometrySet = CType(taggedObject1, NXOpen.CAM.GeometrySet)

' ----------------------------------------------
' Début dialogue Géométrie de pièce
' ----------------------------------------------
geometrySetList1.Erase(0, NXOpen.ObjectList.DeleteOption.Delete)

Dim geometrySet2 As NXOpen.CAM.GeometrySet = Nothing
geometrySet2 = surfaceContourBuilder1.PartGeometry.CreateGeometrySet()

geometrySetList1.Append(geometrySet2)

Dim selectionIntentRuleOptions1 As NXOpen.SelectionIntentRuleOptions = Nothing
selectionIntentRuleOptions1 = workPart.ScRuleFactory.CreateRuleOptions()

selectionIntentRuleOptions1.SetSelectedFromInactive(False)

Dim bodies1(0) As NXOpen.Body
Dim body1 As NXOpen.Body = CType(workPart.Bodies.FindObject("LINKED_BODY(1075)"), NXOpen.Body)

bodies1(0) = body1
Dim bodyDumbRule1 As NXOpen.BodyDumbRule = Nothing
bodyDumbRule1 = workPart.ScRuleFactory.CreateRuleBodyDumb(bodies1, True, selectionIntentRuleOptions1)

selectionIntentRuleOptions1.Dispose()
Dim scCollector1 As NXOpen.ScCollector = Nothing
scCollector1 = geometrySet2.ScCollector

Dim rules1(0) As NXOpen.SelectionIntentRule
rules1(0) = bodyDumbRule1
scCollector1.ReplaceRules(rules1, False)

Dim markId4 As NXOpen.Session.UndoMarkId = Nothing
markId4 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Géométrie de pièce")

theSession.DeleteUndoMark(markId4, Nothing)

Dim markId5 As NXOpen.Session.UndoMarkId = Nothing
markId5 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Géométrie de pièce")

theSession.DeleteUndoMark(markId5, Nothing)

theSession.SetUndoMarkName(markId3, "Géométrie de pièce")

theSession.DeleteUndoMark(markId3, Nothing)

Dim markId6 As NXOpen.Session.UndoMarkId = Nothing
markId6 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Axe Outil Fixe - [OP2_FIN-RAIDISSEUR_5]")

theSession.DeleteUndoMark(markId6, Nothing)

Dim markId7 As NXOpen.Session.UndoMarkId = Nothing
markId7 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Axe Outil Fixe - [OP2_FIN-RAIDISSEUR_5]")

Dim nXObject1 As NXOpen.NXObject = Nothing
nXObject1 = surfaceContourBuilder1.Commit()

theSession.DeleteUndoMark(markId7, Nothing)

theSession.SetUndoMarkName(markId2, "Axe Outil Fixe - [OP2_FIN-RAIDISSEUR_5]")

surfaceContourBuilder1.Destroy()

theSession.DeleteUndoMark(markId2, Nothing)

Dim markId8 As NXOpen.Session.UndoMarkId = Nothing
markId8 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Départ")

Dim surfaceContour2 As NXOpen.CAM.SurfaceContour = CType(nXObject1, NXOpen.CAM.SurfaceContour)

Dim surfaceContourBuilder2 As NXOpen.CAM.SurfaceContourBuilder = Nothing
surfaceContourBuilder2 = workPart.CAMSetup.CAMOperationCollection.CreateSurfaceContourBuilder(surfaceContour2)

theSession.SetUndoMarkName(markId8, "Boîte de dialogue Axe Outil Fixe - [OP2_FIN-RAIDISSEUR_5]")

' ----------------------------------------------
' Début dialogue Axe Outil Fixe - [OP2_FIN-RAIDISSEUR_5]
' ----------------------------------------------
Dim markId9 As NXOpen.Session.UndoMarkId = Nothing
markId9 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Axe Outil Fixe - [OP2_FIN-RAIDISSEUR_5]")

theSession.DeleteUndoMark(markId9, Nothing)

Dim markId10 As NXOpen.Session.UndoMarkId = Nothing
markId10 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Axe Outil Fixe - [OP2_FIN-RAIDISSEUR_5]")

Dim nXObject2 As NXOpen.NXObject = Nothing
nXObject2 = surfaceContourBuilder2.Commit()

theSession.DeleteUndoMark(markId10, Nothing)

theSession.SetUndoMarkName(markId8, "Axe Outil Fixe - [OP2_FIN-RAIDISSEUR_5]")

surfaceContourBuilder2.Destroy()

theSession.DeleteUndoMark(markId8, Nothing)

theSession.CAMSession.Utils.SetInspectionIntent(False)

' ----------------------------------------------
' ----------------------------------------------

End Sub
End Module

This is the record of me doing those exact things :

-start recording
-selecting the CAM operation with left click
-right click on it
-edit
-clicking OK on the popup saying all instances will be modified
-idk the exact words for this one (in french for me) but it's the second line, under the geometry choice, maybe it is body selection
-delete the selection by left clicking the cross
-select the new body
-left click on OK to close the body selection
-left click on OK to close the CAM operation window
-stop recording

So as I say the code is somehow hard for me to understand, but the idea would be to change the operation clicked for a list aiming selected operations before playing the journal I guess ?

I saw that I have to remove the fact that the journal is linked to the specifics paramters of the clicked operation so it will become usable in a general way for any operation selected, have I a few changes to do to get there or do I have to rewrite a lot of things ?

I'm really clueless about where to start to be honest, I don't even know if it's the best solution.
Maybe some smaller codecould be more effective but I don't have enought knowledge.

Thanks by advance for any help.

### RE: Multiple operations editing ?

Hi,
It's possible... but before you start programming, why you don’t use workpiece follow geometry view ?

### RE: Multiple operations editing ?

(OP)
Hello
I'm not sure to understand what you mean

If you want me to replace directly the solid instead of the operations that were created on it, it's not possible in this case

I have as rule to not modify it, but only the operations

And to be honest when I realize all the possibilities NXopen offers I really want to be able to learn more about it

I'm having a look at the examples in UG folders but I'm kinda lost, I feel like the more I read the less I understand

### RE: Multiple operations editing ?

(OP)
Hello

So I cleaned my code as much I can, I think even if there's still some useless stuff it won't be a big deal

Now I should make all this code as a function, use a list to gather the selected CAM operations I want to modify and loop the function on each name ?

I'm thinking about something looking like that :

#### CODE --> VB

Dim namelist As New List
Dim Name As String

Do
name=GetName(SelectedTags)
Loop Until name=" "

For each namelist

Function geomchange
End Function 

I took this idea from the VB section of the getting started guide

Is it a legal way to go ?

I'm sorry it's probably obvious and annoying to deal with beginner stuff like this but I didn't find anything on changing geometries, it's often about names, colors, speeds...
And nothing as well on editing several things like multiple operations on the tree.

### RE: Multiple operations editing ?

(OP)

#### Quote (UserCFAO)

Hi,
It's possible... but before you start programming, why you don’t use workpiece follow geometry view ?

Hello
And to be more precise about that, the workpiece contains a lot of operations, and something like a half of those operations are based on specific geometries that are made on purpose for each of them
So not all the operations should be modified, I think it's something like 100 operations that I have to change

And I have as rule to not change anything else

I'm actually lost somewhere between guides, videos and whatever I could find
It's really hard to understand what syntax to use, it looks like no one ever had to do this, there's litteraly nothing I could find about editing something else than feed or spindle speeds in CAM operations

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

#### Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a partâ€™s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

# Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!