Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations LittleInch on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

set attributes in journal vice versa

Status
Not open for further replies.

gani009

Mechanical
Dec 26, 2013
93
Hi All,
I am trying to modify journal for change of cut direction and to get this I need to change my attribute called "VM_cutDirection" in my cam object. In my journal I can able to change through set attributes but I would like to automate little for this.
If my attribute is 0 then needs to set as 1 or vice versa. I am unable make if statement for that Can anyone help me in this here is my code.
Code:
Option Strict Off
Imports System
Imports System.IO
Imports System.Windows.Forms
Imports NXOpen
Imports NXOpen.CAM
Imports NXOpen.UF
Imports NXOpen.Utilities

Module ChangeCutDirection

    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)
		End If
          			           		
			Dim oOpers(0) As Cam.Operation
			oOpers(0) = camObject
			WorkPart.CAMSetup.GenerateToolPath(oOpers)
		
	        	   ' Set cut direction
				'camObject.SetAttribute("VM_cutDirection", "0")  ' THIS SETS VOLMILL TO CLIMB
				camObject.SetAttribute("VM_cutDirection", "1")  ' THIS SETS VOLMILL TO CONVENTIONAL

			     ' Comment the following two lines to suppress the listing window
				theSession.ListingWindow.Open()
				theSession.ListingWindow.WriteLine("Parameters set in: " & camObject.Name() )
			Dim oOpers1(0) As Cam.Operation
			oOpers1(0) = camObject
			WorkPart.CAMSetup.GenerateToolPath(oOpers1)

End Function

End Module
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor