×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*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.

Students Click Here

Jobs

VBA Macro(UG) to rename each Operation with its Tool name
2

VBA Macro(UG) to rename each Operation with its Tool name

VBA Macro(UG) to rename each Operation with its Tool name

(OP)
Hello Team,

Can anyone please suggest the macro which will run through all operation list and rename it with Tool Name.

Please suggest

Thanks
Rishi

RE: VBA Macro(UG) to rename each Operation with its Tool name

If you search this forum for remame operation tool you will some previous samples.

Basically, you need to cycle through each operation in the Operation Navigator, get the name of its tool parent, and then rename the operation.

There are some samples of cycling through operations and renaming in your installation.
Go to UGOPEN\SampleNXOpenApplications\.NET\CAM and look for programs with "CycleAll" in the name.

Mark Rief
NX CAM Customer Success
Siemens PLM Software

RE: VBA Macro(UG) to rename each Operation with its Tool name

An amazing assemblage of anachronisms:
VBA -- is not used much these days, and has never been used in Siemens products
Macro -- an older (and deprecated) way of recording user actions, superseded by journals
UG -- no longer exists; it has been called NX for the last decade or so

RE: VBA Macro(UG) to rename each Operation with its Tool name

(OP)
Thanks Mark for your reply,

I am able to loop through each operation....only problem I having is with getting the Tool name.

Few lines of codes will be of great help as how to get the tool name when its looping through each operation.

Many Thanks

RE: VBA Macro(UG) to rename each Operation with its Tool name

Once you have the operation you should be able to:

CODE -->

NCGroup theTool = myOp.GetParent(CAMSetup.View.MACHINE_TOOL);
String toolName = theTool.name(); 

Graham Inchley, Systems Developer, Sandvik Coromant. www.sandvik.com
HP EliteBook 8760w, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP4 64bit
Testing: NX9.0.2.5

RE: VBA Macro(UG) to rename each Operation with its Tool name

Rishi,
Feel free to post your final program when you get it all working.
I am always looking for more good examples.

Mark Rief
NX CAM Customer Success
Siemens PLM Software

RE: VBA Macro(UG) to rename each Operation with its Tool name

(OP)
Hello Graham,

Thanks for your response,

I tried to put your code but its showing some messages which I have attached. Please suggest

MACHINE_TOOL IS NOT A MEMBER OF 'NXOpen.CAM.CAMSetup.View'.
'name is not a member of String
Character is not valid

Thanks
Rishi

RE: VBA Macro(UG) to rename each Operation with its Tool name

(OP)
Hello Team,

Any suggestion...

Thanks
Rishi Raj

RE: VBA Macro(UG) to rename each Operation with its Tool name

Have you tested in visual studio or anything, Could you please post your full code

GANESH KOTHAKOTA
CAD/CAM LEAD
NX8.5, Vericut7.3.1
TECHMAHINDRA Inc

RE: VBA Macro(UG) to rename each Operation with its Tool name

You haven't stated what language you are using, my example code was Java.
If you look in the documentation for NXOpen.CAM.CAMSetup.View you'll find that the machine member is called MachineTool in C#, VB and C++.
Ganesh is right though, post some of you own code and it'll be much easier for us to help.

Graham Inchley, Systems Developer, Sandvik Coromant. www.sandvik.com
HP EliteBook 8760w, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP4 64bit
Testing: NX9.0.2.5

RE: VBA Macro(UG) to rename each Operation with its Tool name

(OP)
Hello Team,

Sorry for late response...

Here my code which I am using for looping through each operation

Dim counter As Integer = 101
For Each Op As String In Opnames
theUfSession.Ui.SetStatus("Renaming Operation:" & OP)
Dim operation As CAM.Operation
operation = CType(WorkPart.CAMSetup.CAMOperationCollection.FindObject(Op), CAM.Operation)
operation.SetName(Tool Name & counter) ' Tool Name ( Here I need the Machine tool name to be added)
counter += 1
Next

Many Thanks for all your help..

RE: VBA Macro(UG) to rename each Operation with its Tool name

So your code should look like this I think:

CODE -->

Dim counter As Integer = 101
For Each Op As String In Opnames
   theUfSession.Ui.SetStatus("Renaming Operation:" & OP)
   Dim operation As CAM.Operation
   operation = CType(WorkPart.CAMSetup.CAMOperationCollection.FindObject(Op), CAM.Operation)
   Dim toolName As String
   toolName = operation.GetParent(CAMSetup.View.MachineTool)
   operation.SetName(toolName & counter)
   counter += 1
Next 

Graham Inchley, Systems Developer, Sandvik Coromant. www.sandvik.com
HP EliteBook 8760w, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP4 64bit
Testing: NX9.0.2.5

RE: VBA Macro(UG) to rename each Operation with its Tool name

(OP)
Hi Graham,
Thanks for quick reply...I tried to put your code in between but its shows the below message for below line

toolName = operation.GetParent(CAMSetup.View.MachineTool)
Error message - Value of type NXOpen.CAM.NCGroup cannot be coverted to string

Please suggest.

Thanks
Rishi

RE: VBA Macro(UG) to rename each Operation with its Tool name

Oops, my bad! GetParent() returns the tool group object, so you need to get its name. It should look like this:

CODE -->

Dim counter As Integer = 101
For Each Op As String In Opnames
   theUfSession.Ui.SetStatus("Renaming Operation:" & OP)
   Dim operation As CAM.Operation
   operation = CType(WorkPart.CAMSetup.CAMOperationCollection.FindObject(Op), CAM.Operation)
   Dim toolGroup As NCGroup
   Dim toolName As String
   toolGroup = operation.GetParent(CAMSetup.View.MachineTool)
   toolName = toolGroup.Name
   operation.SetName(toolName & counter)
   counter += 1
Next 

Graham Inchley, Systems Developer, Sandvik Coromant. www.sandvik.com
HP EliteBook 8760w, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP4 64bit
Testing: NX9.0.2.5

RE: VBA Macro(UG) to rename each Operation with its Tool name

(OP)
Hello Graham,

It worked....many thanks!!

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.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources