Showing results for 
Search instead for 
Do you mean 
Reply

Retrieve the tool number from NC operation

i have created a journal to retrieve the tool number from the nc operation using the below code,

CAM:Smiley TonguelanarMilling *planarMilling1(dynamic_cast<CAM:Smiley TonguelanarMilling *>(workPart->CAMSetup()->CAMOperationCollection()->FindObject("RGH_OP_FACE")));
CAM:Smiley TonguelanarMillingBuilder *planarMillingBuilder1;

planarMillingBuilder1 = workPart->CAMSetup()->CAMOperationCollection()->CreatePlanarMillingBuilder(planarMilling1);

planarMillingBuilder1->ToolChangeSetting()->Number()->Value();

 

But here in this code(using c++) if you notice this is specific to a operation type and also the operation name is hardcoded so how to generalize this code to get tool numbers of all the tools used in all the operations of the NC program.

2 REPLIES

Re: Retrieve the tool number from NC operation

[ Edited ]

Please use the code snippet feature so that we can read your code.

 

This is explained in the first sticky post in this forum http://community.plm.automation.siemens.com/t5/NX-Programming-Customization/Preserving-code-snippets...

 

Wnei I post - this is the <> button above the text window.

Mark Rief
Retired Siemens

Re: Retrieve the tool number from NC operation

If you need to create a builder, then it must be based on operation type.

There is a c++ example in UGOPEN\SampleNXOpenApplications\C++\CAM

 

Here is a bioler plate for vb:

 

            'Get the type and subtype of the operation
            theUFSession.Obj.AskTypeAndSubtype(camObjectTag, operationType, operationSubtype)

			Dim operationBuilder As CAM.OperationBuilder

            'Milling
            'For operation types we are interested in, create the correct builder
            If operationSubtype = 110 Then             ' This is a Planar Milling Operation so create a Planar Milling Builder
                operationBuilder = WorkPart.CamSetup.CAMOperationCollection.CreatePlanarMillingBuilder(camObject)
            ElseIf operationSubtype = 210 Then         ' This is a Surface Contouring Operation so create a Builder
                operationBuilder = workPart.CAMSetup.CAMOperationCollection.CreateSurfaceContourBuilder(camObject)
            ElseIf operationSubtype = 211 Then         ' This is a Variable Contour Operation so create a Builder
                operationBuilder = workPart.CAMSetup.CAMOperationCollection.CreateSurfaceContourBuilder(camObject)
            ElseIf operationSubtype = 260 Then         ' This is a Cavity Milling Operation so create a Cavity Milling Builder
                operationBuilder = WorkPart.CamSetup.CAMOperationCollection.CreateCavityMillingBuilder(camObject)
            ElseIf operationSubtype = 261 Then         ' This is a Face Milling Operation so create a Face Milling Builder
                operationBuilder = WorkPart.CamSetup.CAMOperationCollection.CreateFaceMillingBuilder(camObject)
            ElseIf operationSubtype = 263 Then         ' This is a Z Level Milling Operation so create a Z Level Milling Builder
                operationBuilder = WorkPart.CamSetup.CAMOperationCollection.CreateZLevelMillingBuilder(camObject)
            ElseIf operationSubtype = 265 Then         ' This is a Plunge Milling Operation so create a Plunge Milling Builder
                operationBuilder = WorkPart.CamSetup.CAMOperationCollection.CreatePlungeMillingBuilder(camObject)
            ElseIf operationSubtype = 266 Then         ' This is a 5 axis Z Level Milling Operation so create a 5 axis Z Level Milling Builder
                operationBuilder = WorkPart.CamSetup.CAMOperationCollection.CreateVazlMillingBuilder(camObject)

			' Turning
			ElseIf operationSubtype = 510 Then         ' This is a Turn Rough Operation
                operationBuilder = WorkPart.CamSetup.CAMOperationCollection.CreateRoughTurningBuilder(camObject)
			ElseIf operationSubtype = 520 Then         ' This is a Turn Finish Operation
                operationBuilder = WorkPart.CamSetup.CAMOperationCollection.CreateFinishTurningBuilder(camObject)
			ElseIf operationSubtype = 530 Then         ' This is a Turn Teachmode Operation
                operationBuilder = WorkPart.CamSetup.CAMOperationCollection.CreateTeachmodeTurningBuilder(camObject)
			ElseIf operationSubtype = 540 Then         ' This is a Turn Thread Operation
                operationBuilder = WorkPart.CamSetup.CAMOperationCollection.CreateThreadTurningBuilder(camObject)
			ElseIf operationSubtype = 550 Then         ' This is a Turn Centerline Drilling Operation
                operationBuilder = WorkPart.CamSetup.CAMOperationCollection.CreateCenterlineDrillTurningBuilder(camObject)

			End If

            ' Check if there is a valid Builder
            If operationBuilder IsNot Nothing Then

				' Do whatever you want here
				operationBuilder.PathDisplayOptions.ToolDisplay.ToolDisplayType = CAM.DisplayTool.ToolDisplayTypes.None
							
                'Commit the change to the operation( this is the equivalent of OK'ing the operation dialog )
                operationBuilder.Commit()

                'Destroy the builder its job is done(cleanup memory)
                operationBuilder.Destroy()

            End If

 

 

 

Mark Rief
Retired Siemens