cancel
Showing results for 
Search instead for 
Did you mean: 

Tool path Visualization settings

PLM World Member Phenom PLM World Member Phenom
PLM World Member Phenom

Is there some easy way to reset the tool Path Visualization settings when changing parts. The speed value seems inconsonant from part to part. On the Replay tab the Animation Speed of 1 is incredibly slow on some file and too fast on other parts. If I don’t forget to change the speed and have a very long move I may as well go get a cup of coffee while I’m waiting for the tool to finish the move and there is no way to stop in the middle of a move.   Is there some setting I am unaware of that will reset the animation when opening a file?

 

NX9.0.3.4

John Joyce, Manufacturing Engineer,
Senior Aerospace Connecticut
www.senioraeroct.com
Production: NX10.0.3.5, Vericut 8.0.3
Development: Tcl/Tk
Testing: NX11.0.2.7
1 REPLY

Re: Tool path Visualization settings

PLM World Member Legend PLM World Member Legend
PLM World Member Legend

Here's a Journal that does what you need. It will do more:

It will set the toolpath colors to standard colors (to make old toolpaths visially better)

You can choose if tooldisplay will be 3D, Axis or None

 

If you don't want all this perhaps just strip out the speed thing

Ps. It only works on some operations Smiley Sad

 

Option Strict Off
Imports System
Imports System.IO
Imports NXOpen
Imports NXOpen.CAM
Imports NXOpen.UF
Imports NXOpen.Utilities

Module ToolDisplay_Off

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

    Dim MyForm As New xxx
    Dim tooldisplaytype As String

    Sub Main()

        ' If there is a work part only then we can go further
        If WorkPart IsNot Nothing Then

            ' If there is a setup only then do we have to go further
            If WorkPart.CAMSetup() IsNot Nothing Then

                If MyForm.ShowDialog = Windows.Forms.DialogResult.OK Then

                    tooldisplaytype = MyForm.ComboBox1.Text

                    'If Cam Session is not initialized then we have to create a session
                    If theSession.IsCamSessionInitialized() = False Then
                        theSession.CreateCamSession()
                    End If

                    Dim selectedTags() As NXOpen.Tag = Nothing
                    Dim selectedCount As Integer = 0

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

                    Dim index As Integer = 0

                    Dim answer As Boolean = False
                    Dim ptr As IntPtr = New System.IntPtr
                    Dim cycleCbFn As UFNcgroup.CycleCbFT = New UFNcgroup.CycleCbFT(AddressOf cycleCb)

                    If selectedCount <> 0 Then
                        'Cycle all the selected objects and take required action
                        While index < selectedCount
                            ' If the object is a group then cycle through the group
                            theUfSession.Ncgroup.IsGroup(selectedTags(index), answer)
                            If answer = True Then
                                'Cycle throught the Program and find every object 
                                theUfSession.Ncgroup.CycleMembers(selectedTags(index), cycleCbFn, ptr)
                            Else
                                'Take action on the operation
                                OperationAction(selectedTags(index))
                            End If

                            ' Increment to the next object
                            index = index + 1

                        End While
                    Else
                        ' Find the Program root and perform the actions on all obects in the part
                        Dim programRoot As Tag = Tag.Null
                        theUfSession.Setup.AskProgramRoot(WorkPart.CAMSetup().Tag, programRoot)
                        'Cycle throught the Program and find every object 
                        theUfSession.Ncgroup.CycleMembers(programRoot, cycleCbFn, ptr)
                    End If
                End If
                MyForm.Close()
                MyForm.Dispose()
                MyForm = Nothing
            End If
        End If
    End Sub

    'This is the function that is called on every object encountered in the cycling
    Function cycleCb(ByVal camObjectTag As Tag, ByVal ptr As IntPtr) As Boolean
        Dim answer As Boolean

        ' If the object is not an operation then leave without doing anything more
        theUfSession.Ncgroup.IsGroup(camObjectTag, answer)
        If answer = True Then
            Return True
        End If

        'If it is an operation then take the action
        OperationAction(camObjectTag)
        Return True

    End Function

    'This is the Funciton in which the Action is taken for an operation
    Function OperationAction(ByVal camObjectTag As Tag) As Boolean
        ' Find the object associated with the Tag
        Dim camObject As NXObject = NXObjectManager.Get(camObjectTag)
        Dim WorkPart As Part = theSession.Parts.Work
        Dim operationBuilder As CAM.OperationBuilder
        Dim response As Boolean = True

        'If it is an operation then get the proper operation builder
        operationBuilder = GetOperationBuilder(camObjectTag)

        'Now set the variables on the operation builder
        response = ActionFunction(camObject, operationBuilder)

        'Destroy the builder its job is done(cleanup memory)
        'Clean up memory
        If operationBuilder IsNot Nothing Then
            operationBuilder.Destroy()
        End If

        Return response
    End Function

    'Function to get the operation builder
    Function GetOperationBuilder(ByVal camObjectTag As Tag) As CAM.OperationBuilder
        Dim camObject As NXObject = NXObjectManager.Get(camObjectTag)
        Dim WorkPart As Part = theSession.Parts.Work
        Dim operationBuilder As CAM.OperationBuilder = Nothing

        operationBuilder = Nothing

        '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)


            If operationSubtype = 110 Then             ' This is a Planar Milling Operation so create a Planar Milling Builder
                operationBuilder = WorkPart.CAMSetup.CAMOperationCollection.CreatePlanarMillingBuilder(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 = 266 Then         ' This is a Variable Axis Z Level Milling Operation so create a Variable Axis Z Level Milling Builder
                operationBuilder = WorkPart.CAMSetup.CAMOperationCollection.CreateVazlMillingBuilder(camObject)
            ElseIf operationSubtype = 210 Then         ' This is a Fixed Axis Surface Contour Operation so create a Surface Contour Builder
                operationBuilder = WorkPart.CAMSetup.CAMOperationCollection.CreateSurfaceContourBuilder(camObject)
            ElseIf operationSubtype = 211 Then         ' This is a Variable Axis Surface Contour Operation so create Surface Contour Builder
                operationBuilder = WorkPart.CAMSetup.CAMOperationCollection.CreateSurfaceContourBuilder(camObject)
            Else
                theSession.ListingWindow.Open()
                theSession.ListingWindow.WriteLine("Display optie kan niet ingesteld worden voor operatie: " & camObject.Name & Space(40 - Len(camObject.Name)) & "Type = " & operationSubtype)
            End If
        End If
        Return operationBuilder

    End Function

    ' Function to set variables in the Builder
    Function ActionFunction(ByVal operation As CAM.Operation, ByVal operationBuilder As CAM.OperationBuilder) As Boolean
        ' Check if there is a valid Builder
        If operationBuilder IsNot Nothing Then
            ' Change General Parameters
            'GeneralParameters(operationBuilder)
            ' Change Cutting Parameters
            'CutParameters(operationBuilder)
            ' Change Non Cutting Parameters
            'NonCutParameters(operationBuilder)
            ' Change Display Parameters
            DisplayParameters(operationBuilder)

            'Save the changes made
            Try
                operationBuilder.Commit()
            Catch E As Exception
                MsgBox(E.Message)
            End Try
            ' Tool path Generation, Post processing, Clsf Output all these will be done after
            ' the changes have been commited

            ' Prepare an array of objects
            Dim objects(1) As CAM.CAMObject
            objects(0) = operation

            ' Get the Work Part
            Dim workPart As Part = theSession.Parts.Work

            ' Get the Setup
            Dim setup As CAM.CAMSetup = workPart.CAMSetup()

            ' Generate Tool Path
            'setup.GenerateToolPath(objects)
        End If

        Return True

    End Function

    ' Function to set Generate Parameters
    Function GeneralParameters(ByVal operationBuilder As CAM.OperationBuilder) As Boolean
        If TypeOf operationBuilder Is CAM.MillOperationBuilder Then
            Dim millOperationBuilder As CAM.MillOperationBuilder = operationBuilder
            ' Now we are ready to change the parameters
            Return True
        End If
        Return False
    End Function

    ' Function to set Cutting Parameters
    Function CutParameters(ByVal operationBuilder As CAM.OperationBuilder) As Boolean
        'What type of a builder is this?
        If TypeOf operationBuilder Is CAM.MillOperationBuilder Then
            Dim millOperationBuilder As CAM.MillOperationBuilder = operationBuilder
            'From the Operation Builder get the Cutting Parameters Object
            Dim cutParams As CAM.MillCutParameters = millOperationBuilder.CutParameters

            ' Now we are ready to change the parameters of cutting
            Return True
        End If
        Return False

    End Function


    ' Function to set Non Cutting Parameters
    Function NonCutParameters(ByVal operationBuilder As CAM.OperationBuilder) As Boolean
        Dim response As Boolean = False
        'What type of a builder is this?
        If TypeOf operationBuilder Is CAM.PlanarOperationBuilder Then
            Dim planarOperationBuilder As CAM.PlanarOperationBuilder = operationBuilder

            ' From the Operation Builder get the Non Cutting Builder
            Dim ncmBuilder As CAM.NcmPlanarBuilder = planarOperationBuilder.NonCuttingBuilder

            ' Now we are ready to change the Non Cutting Parameters
            ncmBuilder.CollisionCheck = False

            response = True
        ElseIf TypeOf operationBuilder Is CAM.SurfaceContourBuilder Then
            Dim scBuilder As CAM.SurfaceContourBuilder = operationBuilder

            ' From the Operation Builder get the Non Cutting Builder
            Dim ncmBuilder As CAM.NcmScBuilder = scBuilder.NonCuttingBuilder

            ' Now we are ready to change the Non Cutting Parameters
            ncmBuilder.CollisionCheck = False

            response = True
        End If

        Return response

    End Function


    Function DisplayParameters(ByVal operationBuilder As CAM.OperationBuilder) As Boolean


        If TypeOf operationBuilder Is CAM.MillOperationBuilder Then
            Dim millOperationBuilder As CAM.MillOperationBuilder = operationBuilder
            'From the Operation Builder get the Display Parameters Object

            ' From the Operation Builder get the Display Builder
            Dim dispParams As CAM.OperationDisplayOptionsBuilder = millOperationBuilder.PathDisplayOptions

            ' Now we are ready to change the Display Parameters
            If tooldisplaytype = "None" Then dispParams.ToolDisplayType = OperationDisplayOptionsBuilder.ToolDisplayTypes.None
            If tooldisplaytype = "3D" Then dispParams.ToolDisplayType = OperationDisplayOptionsBuilder.ToolDisplayTypes.Tool3d
            If tooldisplaytype = "2D" Then dispParams.ToolDisplayType = OperationDisplayOptionsBuilder.ToolDisplayTypes.Tool2d
            If tooldisplaytype = "Axis" Then dispParams.ToolDisplayType = OperationDisplayOptionsBuilder.ToolDisplayTypes.Axis

			'Set the Display speed at 10
			dispParams.PathDisplay.ReplaySpeed = 10
			
            ' Set default colors for moves
            Dim pathDisplayColors1 As CAM.PathDisplayColors
            pathDisplayColors1 = dispParams.PathDisplayColors
            pathDisplayColors1.Rapid = WorkPart.Colors.Find("Red")
            pathDisplayColors1.Approach = WorkPart.Colors.Find("Blue")
            pathDisplayColors1.Engage = WorkPart.Colors.Find("Deep Yellow")
            pathDisplayColors1.FirstCut = WorkPart.Colors.Find("Cyan")
            pathDisplayColors1.Stepover = WorkPart.Colors.Find("Green")
            pathDisplayColors1.Cut = WorkPart.Colors.Find("Deep Cyan")
            pathDisplayColors1.Traversal = WorkPart.Colors.Find("Strong Blue")
            pathDisplayColors1.Retract = WorkPart.Colors.Find("Pale Pink")
            pathDisplayColors1.Departure = WorkPart.Colors.Find("Blue")
			

            Return True
        End If
        Return False


    End Function

End Module
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class xxx
    Inherits System.Windows.Forms.Form

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub
    Friend WithEvents Panel1 As System.Windows.Forms.Panel
    Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Label2 As System.Windows.Forms.Label

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.Panel1 = New System.Windows.Forms.Panel()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.ComboBox1 = New System.Windows.Forms.ComboBox()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Button2 = New System.Windows.Forms.Button()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.Panel1.SuspendLayout()
        Me.SuspendLayout()
        '
        'Panel1
        '
        Me.Panel1.BackColor = System.Drawing.Color.FromArgb(CType(CType(64, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.Panel1.Controls.Add(Me.Label2)
        Me.Panel1.Controls.Add(Me.ComboBox1)
        Me.Panel1.Controls.Add(Me.Label1)
        Me.Panel1.Controls.Add(Me.Button2)
        Me.Panel1.Controls.Add(Me.Button1)
        Me.Panel1.Location = New System.Drawing.Point(14, 11)
        Me.Panel1.Name = "Panel1"
        Me.Panel1.Size = New System.Drawing.Size(281, 127)
        Me.Panel1.TabIndex = 9
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label2.ForeColor = System.Drawing.Color.Yellow
        Me.Label2.Location = New System.Drawing.Point(13, 56)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(218, 15)
        Me.Label2.TabIndex = 13
        Me.Label2.Text = "Tool Path Colors will be reset to default"
        '
        'ComboBox1
        '
        Me.ComboBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.ComboBox1.ForeColor = System.Drawing.Color.Blue
        Me.ComboBox1.FormattingEnabled = True
        Me.ComboBox1.Items.AddRange(New Object() {"None", "3D", "2D", "Axis"})
        Me.ComboBox1.Location = New System.Drawing.Point(152, 19)
        Me.ComboBox1.Name = "ComboBox1"
        Me.ComboBox1.Size = New System.Drawing.Size(111, 28)
        Me.ComboBox1.TabIndex = 12
        Me.ComboBox1.Text = "None"
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.ForeColor = System.Drawing.Color.White
        Me.Label1.Location = New System.Drawing.Point(16, 22)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(94, 20)
        Me.Label1.TabIndex = 11
        Me.Label1.Text = "Tool Display"
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Button2
        '
        Me.Button2.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.Button2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button2.ForeColor = System.Drawing.Color.White
        Me.Button2.Location = New System.Drawing.Point(180, 90)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(84, 26)
        Me.Button2.TabIndex = 10
        Me.Button2.Text = "Cancel"
        Me.Button2.UseVisualStyleBackColor = True
        '
        'Button1
        '
        Me.Button1.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button1.ForeColor = System.Drawing.Color.White
        Me.Button1.Location = New System.Drawing.Point(16, 90)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(80, 26)
        Me.Button1.TabIndex = 9
        Me.Button1.Text = "Ok"
        Me.Button1.UseVisualStyleBackColor = True
        '
        'xxx
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(7.0!, 12.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.BackColor = System.Drawing.Color.Purple
        Me.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center
        Me.ClientSize = New System.Drawing.Size(309, 150)
        Me.ControlBox = False
        Me.Controls.Add(Me.Panel1)
        Me.Font = New System.Drawing.Font("Lucida Sans", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "xxx"
        Me.Opacity = 0.95R
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Choose Tool Display Type"
        Me.Panel1.ResumeLayout(False)
        Me.Panel1.PerformLayout()
        Me.ResumeLayout(False)

    End Sub
End Class

 

Patrick Delisse
KMWE - DutchAero
NX11.0, CAMPOST V22, Vericut 8.0

Learn online





Solution Information