Site Logo
Site Logo
 
It is currently Sun Apr 02, 2017 7:22 pm

All times are UTC [ DST ]




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Code Optimization
PostPosted: Tue Dec 08, 2015 1:41 pm 
Offline
DELCAM Guru
DELCAM Guru
User avatar

Joined: Wed Jul 20, 2005 9:25 am
Posts: 699
Location: Portsmouth, England
Hi All,

I am using this code on a form load event to populate some basic toolpath properties. It finds the active toolpath within the project and generally works well, however on this project I am on at the moment(200+ toolpaths) it takes an absolute age as it loads the session details at every toolpath loop.

I welcome any feedback to improving on my current format

Code:
For Each Me.toolpath In session.Toolpaths
            If toolpath.IsCalculated = True Then
                If toolpath.IsActive = True Then

                    'Collect the Toolpath Properties
                    useAxialThickness = powerMILL.ExecuteEx("print $entity('toolpath','" & toolpath.Name & "').UseAxialThickness")
                    thickness = powerMILL.ExecuteEx("print $entity('toolpath','" & toolpath.Name & "').Thickness")
                    axialThickness = powerMILL.ExecuteEx("print $entity('toolpath','" & toolpath.Name & "').AxialThickness")
                    stepover = powerMILL.ExecuteEx("print $entity('toolpath','" & toolpath.Name & "').Stepover")

                    toolpathType = toolpath.ToString
                    If toolpathType = "Delcam.ProductInterface.PowerMILL.PMToolpathDrilling" Then
                        toolpathType = "drilling"
                    Else
                        toolpathType = powerMILL.ExecuteEx("print $entity('toolpath','" & toolpath.Name & "').ToolpathType")
                    End If

                    Select Case toolpathType
                        Case Is = "roughing"
                            stepdown = powerMILL.ExecuteEx("print $entity('toolpath','" & toolpath.Name & "').AreaClearance.ZHeights.Automatic")
                            If CDbl(stepdown) = 1 Then
                                stepdown = powerMILL.ExecuteEx("print $entity('toolpath','" & toolpath.Name & "').AreaClearance.ZHeights.Stepdown")
                                Me.lblStepdownOutput.Text = ": " & stepdown & "mm"
                            Else
                                stepdown = powerMILL.ExecuteEx("print $entity('toolpath','" & toolpath.Name & "').AreaClearance.ZHeights.Value")
                                Me.lblStepdownOutput.Text = ": " & stepdown & "mm"
                            End If

                            'stepdown = powerMILL.ExecuteEx("print $entity('toolpath','" & toolpath.Name & "').AreaClearance.Slicer.Type")

                            If stepdown = "flat" Then
                                Me.lblStepdownOutput.Text = ": Flats"
                            End If

                        Case Is = "finishing"
                            Me.lblStepdownOutput.Text = ": N/A for finishing"
                        Case Is = "drilling"
                            powerMILL.Execute("DEACTIVATE BOUNDARY")
                            stepdown = powerMILL.ExecuteEx("print $entity('toolpath','" & toolpath.Name & "').Drill.PeckDepth.Value")
                            Me.lblStepdownOutput.Text = ": " & stepdown & "mm"
                    End Select

                    'Update the Toolpath Properties
                    Me.lblToolpathProperties.Text = "Toolpath Properties : " & toolpath.Name
                    Me.grbToolpathProperties.Text = "Toolpath Properties : " & toolpath.Name
                    lblToolpathToleranceOutput.Text = ": " & powerMILL.ExecuteEx("print $entity('toolpath','" & toolpath.Name & "').Tolerance")
                    If useAxialThickness = True Then
                        Me.lblToolpathThicknessOutput.Text = ": " & "Radial : " & thickness & "mm" & "          " & "Axial: " & axialThickness & "mm"
                    Else
                        Me.lblToolpathThicknessOutput.Text = ": " & thickness & "mm"
                    End If
                    Me.lblStepoverOutput.Text = ": " & stepover & "mm"

                    toolpathBoundary = powerMILL.ExecuteEx("print $entity('toolpath','" & toolpath.Name & "').Boundary.Name")

                    If toolpathBoundary.Contains("#ERROR:") = False Then
                        Me.lblBoundaryOutput.Text = ": " & toolpathBoundary
                    Else
                        Me.lblBoundaryOutput.Text = ": None"
                    End If

                    toolpathTime()

                    description = powerMILL.ExecuteEx("print $entity('toolpath','" & toolpath.Name & "').Description")
                    Me.txtDescription.Text = description
                    activeToolpathFound = toolpath.Name
                    Exit Sub

                End If

            ElseIf toolpath.IsActive = True Then

                MessageBox.Show("The active Toolpath is un-calculated")
                Exit Sub

            End If
        Next


Thanks in advance

Nathan

_________________
www.amdale.co.uk
www.laze-etch.co.uk


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB