cancel
Showing results for 
Search instead for 
Did you mean: 

Change the attribute on a VoluMill operation by journal

Hi,

 

I am trying to modify journal for volumill. The main journal supplied by @MarkRief . My volumill sequence has attribute called " VM_cutdirection", this will control the cut direction as climb or conventional by using values 0 and 1 respectively. I would like to control throgh journal for my mirrored path. By journal is running without any error but there is no chnage in my volumill sequence. here is my code could you please correct me

'=============================================================================
'
'   Copyright 2015 Siemens Product Lifecycle Management Software Inc. All Rights Reserved.
'
'=============================================================================
'  REVISIONS

'     05-mar-2015  Mark Rief  adapt for cut direction 
'
' ===========================================================================
'   DESCRIPTION

'     This program will edit planar type mill operations
'
'     This can be used as a boiler plate to set other method parameters.
' ============================================================================
 
Option Strict Off
Imports System
Imports System.IO
Imports System.Windows.Forms
Imports NXOpen
Imports NXOpen.CAM
Imports NXOpen.UF
Imports NXOpen.Utilities
Imports NXOpen.UF.UFoper
Imports NXOpenUI

Module flutelength

    Dim theSession As Session
    Dim theUfSession As UFSession


    Sub Main()

        theSession = Session.GetSession()
        theUfSession = UFSession.GetUFSession()
        Dim WorkPart As Part = TheSession.Parts.Work
		

        Dim setupTag As Tag
        Dim camObjectTag As Tag
        Dim selectedTags() As NXOpen.Tag
        Dim selectedCount As Integer

        theUfSession.Cam.InitSession()
        theUfSession.Setup.AskSetup(setupTag)

        ' If there is a setup only then we go further
        If setupTag <> 0 Then

            ' Get the selected nodes from the Operation Navigator
            theUfSession.UiOnt.AskSelectedNodes(selectedCount, selectedTags)

            Dim ptr As IntPtr = New System.IntPtr
            Dim cycle_cb_fn As UFNcgroup.CycleCbFT = New UFNcgroup.CycleCbFT(AddressOf cycle_cb)

            Dim i As Integer
            'Loop over the selected nodes to take action
            For i = 0 To selectedCount - 1
                ' The selected item needs to be checked to take action
                action(selectedTags(i))
                ' Now if the selected item is a Group object then we need to cycle objects inside it
                theUfSession.Ncgroup.CycleMembers(selectedTags(i), cycle_cb_fn, ptr)
            Next i
        End If

    End Sub


    Function cycle_cb(ByVal camObjectTag As Tag, ByVal ptr As IntPtr) As Boolean

        Dim answer As Boolean
        ' Every item needs to be checked to take action
        answer = action(camObjectTag)
        Return answer

    End Function

    Function action(ByVal camObjectTag As Tag) As Boolean

        Dim camObject As NXObject = NXObjectManager.Get(camObjectTag)
        Dim WorkPart As Part = TheSession.Parts.Work
		
        'Check if the object is an Operation
        If TypeOf camObject Is CAM.Operation Then
            Dim operationType As Integer
            Dim operationSubtype As Integer
		
            'Get the type and subtype of the operation
            theUFSession.Obj.AskTypeAndSubtype(camObjectTag, operationType, operationSubtype)
				theSession.ListingWindow.Open()
				theSession.ListingWindow.WriteLine("operationSubtype = " & operationSubtype)

            Dim operationBuilder As CAM.MillOperationBuilder
		



           If operationSubtype = 800 Then         ' This is a Mill user defined Operation so create mill UD Builder
                'operationBuilder = WorkPart.CAMSetup.CAMOperationCollection.CreateMillUdBuilder(camObject)
	

            End If

            ' Check if there is a valid Builder
            If operationBuilder IsNot Nothing Then
			
				' Set cut direction
				'operationBuilder.CutParameters.CutDirection.Type = CAM.CutDirection.Types.Climb
				'operationBuilder.CutParameters.CutDirection.Type = CAM.CutDirection.Types.Conventional
       			'operationBuilder.CutParameters.CutDirection.Type = CAM.CutDirection.Types.Mixed
				camObject.SetAttribute("VM_cutDirection", 1) ' SET FOR CONVENTIONAL CUT FOR VOLUMILL
			
                '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(clean up memory)
                operationBuilder.Destroy()

				' Comment the following two lines to suppress the listing window
				theSession.ListingWindow.Open()
				theSession.ListingWindow.WriteLine("Parameters set in: " & camObject.Name() )
				
            End If

        End If

        Return True
    End Function

End Module


 

Regards,
Ganesh
NX 8.5 and Vericut 7.3
7 REPLIES

Re: Change the attribute on a VoluMill operation by journal

Does the program list the correct operation type and subtype?

After you run the program, is the attribute set on the user defined operation?

 

camObject.SetAttribute (attributeName, attributeValue) sets without a category - I would use the AttributePropertiesBuilder. There is an example in AssignAttributesForTooltips.vb in the samples.

Mark Rief
Retired Siemens

Re: Change the attribute on a VoluMill operation by journal

Hi Mark,

I am getting opertation subtype as 800 only by using your code.

 


MarkRief wrote:

Does the program list the correct operation type and subtype?

After you run the program, is the attribute set on the user defined operation?

 

camObject.SetAttribute (attributeName, attributeValue) sets without a category - I would use the AttributePropertiesBuilder. There is an example in AssignAttributesForTooltips.vb in the samples.



 I used same format for set attributes but no luch some where i am gettiung error. here I am attching the modified code for volumill. Please suggest me

 

 

Regards,
Ganesh
NX 8.5 and Vericut 7.3

Re: Change the attribute on a VoluMill operation by journal

Hi Mark,

 

Just now I noticed, If i open file in ug session and go to properties of volumill then nothinh shown belongs to volumill , If i regenerate path then in properties its showing all volmill attributes. Why this is coming like this

 

 

Regards,

Gani

Regards,
Ganesh
NX 8.5 and Vericut 7.3

Re: Change the attribute on a VoluMill operation by journal

Esteemed Contributor
Esteemed Contributor

VoluMill is a separate product and does not work like native NX operation types.

 

Best would be to contact the VoluMill support, who know how VoluMill operations can be changed through NXOpen API.

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: Change the attribute on a VoluMill operation by journal

@Stefan_Pendland  Markrief  I modified journal to my requirement for volumill but It works great If I generete volumill path before executing my journal. So I would like to introduce generate tool path in my journal before set attributes and after set attributes for my camObject. I tried different syntexs from examples but no luck could you please guide me. Here I am attachingmy code

'=============================================================================
'
'   Copyright 2015 Siemens Product Lifecycle Management Software Inc. All Rights Reserved.
'
'=============================================================================
'  REVISIONS

'     05-mar-2015  Mark Rief  adapt for cut direction 
'
' ===========================================================================
'   DESCRIPTION

'     This program will edit planar type mill operations
'
'     This can be used as a boiler plate to set other method parameters.
' ============================================================================
 
Option Strict Off
Imports System
Imports System.IO
Imports System.Windows.Forms
Imports NXOpen
Imports NXOpen.CAM
Imports NXOpen.UF
Imports NXOpen.Utilities

Module CUTDIRECTIONCHANGE

    Dim theSession As Session
    Dim theUfSession As UFSession


    Sub Main()

        theSession = Session.GetSession()
        theUfSession = UFSession.GetUFSession()
        Dim WorkPart As Part = TheSession.Parts.Work

        Dim setupTag As Tag
        Dim camObjectTag As Tag
        Dim selectedTags() As NXOpen.Tag
        Dim selectedCount As Integer

        theUfSession.Cam.InitSession()
        theUfSession.Setup.AskSetup(setupTag)

        ' If there is a setup only then we go further
        If setupTag <> 0 Then

            ' Get the selected nodes from the Operation Navigator
            theUfSession.UiOnt.AskSelectedNodes(selectedCount, selectedTags)

            Dim ptr As IntPtr = New System.IntPtr
            Dim cycle_cb_fn As UFNcgroup.CycleCbFT = New UFNcgroup.CycleCbFT(AddressOf cycle_cb)

            Dim i As Integer
            'Loop over the selected nodes to take action
            For i = 0 To selectedCount - 1
                ' The selected item needs to be checked to take action
                action(selectedTags(i))
                ' Now if the selected item is a Group object then we need to cycle objects inside it
                theUfSession.Ncgroup.CycleMembers(selectedTags(i), cycle_cb_fn, ptr)
            Next i
        End If

    End Sub


    Function cycle_cb(ByVal camObjectTag As Tag, ByVal ptr As IntPtr) As Boolean

        Dim answer As Boolean
        ' Every item needs to be checked to take action
        answer = action(camObjectTag)
        Return answer

    End Function

    Function action(ByVal camObjectTag As Tag) As Boolean

        Dim camObject As NXObject = NXObjectManager.Get(camObjectTag)
        Dim WorkPart As Part = TheSession.Parts.Work
		
        'Check if the object is an Operation
        If TypeOf camObject Is CAM.Operation Then
            Dim operationType As Integer
            Dim operationSubtype As Integer

            'Get the type and subtype of the operation
            theUFSession.Obj.AskTypeAndSubtype(camObjectTag, operationType, operationSubtype)
				theSession.ListingWindow.Open()
				theSession.ListingWindow.WriteLine("operationSubtype = " & operationSubtype)

            Dim millUserDefinedBuilder1 As CAM.MillUserDefinedBuilder

		
			
           If operationSubtype = 800 Then         ' This is a Volmilling Operation so create a Volmilling Builder
                millUserDefinedBuilder1 = workPart.CAMSetup.CAMOperationCollection.CreateMillUserDefinedBuilder(camObject)
			
			
           End If

       
		' Check if there is a valid Builder FOR VOLUME MILLING
            If millUserDefinedBuilder1 IsNot Nothing Then
					
			        
			   ' Set cut direction
				'camObject.SetAttribute("VM_cutDirection", "0")  ' THIS SETS VOLMILL TO CLIMB
				camObject.SetAttribute("VM_cutDirection", "1")  ' THIS SETS VOLMILL TO CONVENTIONAL
       			
			
                'Commit the change to the operation( this is the equivalent of OK'ing the operation dialog )
                millUserDefinedBuilder1.Commit()

                'Destroy the builder its job is done(clean up memory)
                millUserDefinedBuilder1.Destroy()

				' Comment the following two lines to suppress the listing window
				theSession.ListingWindow.Open()
				theSession.ListingWindow.WriteLine("Parameters set in: " & camObject.Name() )

			      			
			
              
				
            End If
End If

       
        Return True
    End Function

End Module

 

Regards,
Ganesh
NX 8.5 and Vericut 7.3

Re: Change the attribute on a VoluMill operation by journal

Esteemed Contributor
Esteemed Contributor

You need to use an array even if there is only one item.

 

Dim oOpers(0) As Cam.Operation
oOpers(0) = camObject
WorkPart.CAMSetup.GenerateToolPath(oOpers)

 

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: Change the attribute on a VoluMill operation by journal

This works great....

Regards,
Ganesh
NX 8.5 and Vericut 7.3

Learn online





Solution Information