Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

Jornal: Name of selected operation

Hello!

 

I'm struggling with journal for post processing selected operation with its name. So far it works for any operation, but I can't get variable of its name. I would be grateful for help.

 

Option Strict Off
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

' ----------------------------------------------
' Menu: Tools->Operation Navigator->Output->Postprocess...
' ----------------------------------------------
workPart.CAMSetup.OutputBallCenter = False

Dim objects1(0) As NXOpen.CAM.CAMObject
Dim theUI As UI = UI.GetUI()

objects1(0) = CType(theUI.SelectionManager.GetSelectedObject(0), NXOpen.CAM.Operation)
workPart.CAMSetup.PostprocessWithSetting(objects1, "WIRE_EDM_4_AXIS", "C:\~~\Desktop\12345.h", NXOpen.CAM.CAMSetup.OutputUnits.PostDefined, NXOpen.CAM.CAMSetup.PostprocessSettingsOutputWarning.PostDefined, NXOpen.CAM.CAMSetup.PostprocessSettingsReviewTool.PostDefined)

' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------

End Sub
End Module

 

Regards,

Sebastian

7 REPLIES
Solution
Solution
Accepted by topic author SebatianP
‎06-21-2016 09:09 AM

Re: Jornal: Name of selected operation

Hello Sebastian!

 

Dim curOperation As NXOpen.CAM.Operation
curOperation = CType(theUI.SelectionManager.GetSelectedObject(0), NXOpen.CAM.Operation)

You should now be able to get the name of the operation with

curOperation.Name

You are creating a variable called objects1(0) (Type: NXOpen.CAM.CAMObject), but

to get some properties of an operation you need a variable Type: NXOpen.CAM.Operation.

 

Hope that helps! Bye,

 

Flo

Re: Jornal: Name of selected operation

Thank you Flo !

 

Now it works with one selected operation (vb file in attachment)

 

Is there any simple way to automate this, for example:

After selecting 10 operation journal will post process 10 files?

 

Regards,

Sebastian

Re: Jornal: Name of selected operation

For Each theSelectedObject as NXObject in theUI.SelectionManager.GetSelectedObjects()

    ' ... your code goes here with some modifications

Next

 

This is just out of my head, so you get a hint, the methods might be called differently.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community
Solution
Solution
Accepted by topic author SebatianP
‎06-22-2016 08:52 AM

Re: Jornal: Name of selected operation

There are several vb examples that operate on the selected operations, or members of selected groups that are operations. Take a look in the install folder - UGOPEN\SampleNXOpenApplications\.NET\CAM for *OntSelection.vb.

Mark Rief
Retired Siemens

Re: Jornal: Name of selected operation

Thank you for tip. After a few hours, journal is generating multiple files with different names of selected operation, but with same code inside it.

 

I can't link tagged operation in code below. I tried different ways but I failed. (Full code in annex)

 

'Check if the object is a operation
If TypeOf camObject Is CAM.Operation Then
'Get the current operation name
Dim CurrentName As String = camObject.Name()
Dim filepath As String = "C:\~~\Desktop"

'Post selected operation
Dim objects1(0) As NXOpen.CAM.CAMObject
Dim theUI As UI = UI.GetUI()
objects1(0) = CType(theUI.SelectionManager.GetSelectedObject(0), NXOpen.CAM.Operation)
workPart.CAMSetup.PostprocessWithSetting(objects1, "WIRE_EDM_4_AXIS", IO.Path.Combine(filepath, CurrentName & ".h") , NXOpen.CAM.CAMSetup.OutputUnits.PostDefined, NXOpen.CAM.CAMSetup.PostprocessSettingsOutputWarning.PostDefined, NXOpen.CAM.CAMSetup.PostprocessSettingsReviewTool.PostDefined)


End If

 

Regards,

Sebastian

Solution
Solution
Accepted by topic author SebatianP
‎06-22-2016 08:52 AM

Re: Jornal: Name of selected operation

[ Edited ]

Replace

objects1(0) = CType(theUI.SelectionManager.GetSelectedObject(0), NXOpen.CAM.Operation)

with

objects1(0) = camObject

since

theUI.SelectionManager.GetSelectedObject(0)

will always use the first selected object and nothing else.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: Jornal: Name of selected operation

Thank you all! Works perfect!

 

Have a nice day!