Populating Toolpath along with Toolpath tolerance, Speed and Feed which can be edited

Populating Toolpath along with Toolpath tolerance, Speed and Feed which can be edited

Anonymous
Not applicable
3,346 Views
21 Replies
Message 1 of 22

Populating Toolpath along with Toolpath tolerance, Speed and Feed which can be edited

Anonymous
Not applicable

Hello API Forum,

I am preparing a form and in that require help (Visual studio & VB language)

I am trying to collect toolpath information like Tolerance, Feed & Speeds which can be edited by multiple selection.

In this Toolpath list (ListView) is being populated using For loop but Tol, feed and speed are not being captured.

 

FYI, Attached images shows Form and Code.

 

Please can you advise how this can be done or suggest if other solution is required to achieve this.

Many Thanks,

 

Toolpath Image.JPGVB Code.JPG

0 Likes
Accepted solutions (1)
3,347 Views
21 Replies
Replies (21)
Message 2 of 22

Anonymous
Not applicable

..

0 Likes
Message 3 of 22

luke.edwards.autodesk
Community Manager
Community Manager

You are only adding the text strings to the List Box for "Feed", "RPM" etc.  You would need to query PowerMill to find out what the values are.  The OLE API you are using is super old and was replaced by the API described in the sticky posts in this forum.  I would suggest you use those instead.


Luke Edwards
Consulting Services Manager
0 Likes
Message 4 of 22

luke.edwards.autodesk
Community Manager
Community Manager

Sorry, looking at the screenshot again, I can see that you have used a mix of the two APIs, new and old.

Remove the references to the OLE one.  You would then need to do something like:

For Each (toolpath As PMToolpath In session.Toolpaths)
    Dim lvItem = ListView1.Items.Add(toolpath.Name)
    lvItem.SubItems.AddRange(toolpath.Tolerance, toolpath.SurfaceSpeed, toolpath.CuttingFeed)
Next

However the API currently doesn't have a Tolerance property for Toolpaths.  I could add that for you though if that would help? 


Luke Edwards
Consulting Services Manager
0 Likes
Message 5 of 22

Anonymous
Not applicable

Hello Luke,

 

Thanks for the feedback.

I tried to remove as instructed but "toolpath" gives a error as shown in below image.

Please can you advise what I am doing wrong. I have attached the code and image below.

As a side note : Also advise how would you add Tolerance property ? FYI you can exclude not to include this time-being.

Imports Autodesk.ProductInterface.PowerMILL

Public Class Form1
    Dim powerMill As New PMAutomation(Autodesk.ProductInterface.InstanceReuse.UseExistingInstance)
    Dim session As PMProject = powerMill.ActiveProject

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        ListView1.Items.Clear()
        Dim toolpath As String

        For Each (toolpath As PMToolpath In session.Toolpaths)
            Dim lvItem = ListView1.Items.Add(toolpath.Name)
            lvItem.SubItems.AddRange(toolpath.Tolerance, toolpath.SurfaceSpeed, toolpath.CuttingFeed)
        Next

    End Sub
End Class


Capture.JPG 

0 Likes
Message 6 of 22

luke.edwards.autodesk
Community Manager
Community Manager

You have Dim toolpath As String.  This is a duplicate definition.  Just remove that line and it should resolve the issue.

You will then see an error because Tolerance is not a valid property of PMToolpath.  Let me know if you want this added to the API.


Luke Edwards
Consulting Services Manager
0 Likes
Message 7 of 22

Anonymous
Not applicable

Hello Luke,

Done changes as requested but still showing error.

In image, have shown the Error comping in Error List tab stating "toolpath" is not declared.

Kindly have a look and advise.
Capture.JPG

0 Likes
Message 8 of 22

luke.edwards.autodesk
Community Manager
Community Manager

Ah, try removing the brackets:

For Each toolpath As PMToolpath in session.Toolpaths

 

C# uses brackets but VB doesn't... My mistake!


Luke Edwards
Consulting Services Manager
0 Likes
Message 9 of 22

Anonymous
Not applicable

Hello Luke,

Thanks for the information and it worked in addition to changing the bracket positions for AddRange also.

 

In addition, please can you advise what needs to be done in order to achieve task as shown in below image.
As you can see, I am trying to update Speed and feeds of multiple toolpath in one go by selecting the required ones only.

 

Many Thanks

Capture.JPG

0 Likes
Message 10 of 22

luke.edwards.autodesk
Community Manager
Community Manager
Accepted solution

You should be able to do something like:

For Each item As ListViewItem in ListView1.SelectedItems
    Dim name = item.Text
    session.Toolpaths(name).SurfaceSpeed = CDbl(txtSurfaceSpeed.Text)
    session.Toolpaths(name).CuttingFeed = CDbl(txtCuttingFeed.Text)
Next

where txtSurfaceSpeed and txtCuttingFeed are your two textboxes.


Luke Edwards
Consulting Services Manager
0 Likes
Message 11 of 22

Anonymous
Not applicable

Hello Luke,

Thanks for your help and it is working

0 Likes
Message 12 of 22

luke.edwards.autodesk
Community Manager
Community Manager
Great news! Any further issues, feel free to post.

Luke Edwards
Consulting Services Manager
0 Likes
Message 13 of 22

Anonymous
Not applicable

Hello Luke,

In the working exampled, i tried to add ToolDiameter column to be outputted in ListView but it came back with below error. I am not sure why this happened. Also will it be possible to add a property for Toolpath Depth of Cut, Tolerance and Toolpath Stepover

Capture.JPG

0 Likes
Message 14 of 22

luke.edwards.autodesk
Community Manager
Community Manager

I would suggest instead that you access the tool itself and read the property from there:

var tool = session.Tools[toolpath.ToolName];

var diameter = tool.Diameter;

 

I can look at adding the other ones for you.  Which toolpath strategies are you using?


Luke Edwards
Consulting Services Manager
0 Likes
Message 15 of 22

Anonymous
Not applicable

Hello Luke,

I tried using the solution provided but still it showing error.
please can advise on this.

devangp_0-1601375812185.png

 

0 Likes
Message 16 of 22

luke.edwards.autodesk
Community Manager
Community Manager

Hi, does the toolpath not have a tool assigned to it?  I think this is the only time when this can happen.


Luke Edwards
Consulting Services Manager
0 Likes
Message 17 of 22

Anonymous
Not applicable

Hello Luke,

 

You are correct, there was one toolpath where tool was not assigned to a toolpath.

By assigning it the error has been removed.

 

In order to eliminate the issue of tool not assigned would like to assign an If & Else loop, please can you advice what code will come :

If ****** Tool not assigned to toolpath ***** Then
         MsgBox("Tool Not Assigned")
Else
*****Will go in the current Loop to populate the toolpath


Many Thanks 

0 Likes
Message 18 of 22

Anonymous
Not applicable

Hello Luke,

 

Apologies, in addition to above, is there a code to output Max & Min X,Y,Z of a toolpath.

 

Many Thanks.

0 Likes
Message 19 of 22

luke.edwards.autodesk
Community Manager
Community Manager

Hi.  I have updated the API to handle this case.  It should return an empty string if there is no tool.  I have also added a Tool property that will return either the tool or null if there is no tool.

 

Regarding your other question, you have GetBlockLimits available on the PMProject.

 

But if you want the actual limits of the calculated toolpath then you would need to create a pattern from the toolpath and then output that to curves and get the bounds of that.  The first part isn't supported by the API though at the moment.  But if you have it as a PMPattern you can use ToPolylines and get the BoundingBox of each to find the true bounds.


Luke Edwards
Consulting Services Manager
0 Likes
Message 20 of 22

Anonymous
Not applicable

Hi Luke,

 

Thanks for the update.

One thing noticed that when populating the toolpath list in ListView, the order of toolpath are not populating in the order of toolpath which are there in Powermill. Is there any solution for that

 

Many Thanks

0 Likes