<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: API is returning 0 tool paths where there are some.  (Solved) in PowerShape and PowerMill API Forum</title>
    <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9102771#M736</link>
    <description>&lt;P&gt;Do you have a small example application that could show this happening?&lt;/P&gt;</description>
    <pubDate>Wed, 23 Oct 2019 08:56:45 GMT</pubDate>
    <dc:creator>luke.edwards.autodesk</dc:creator>
    <dc:date>2019-10-23T08:56:45Z</dc:date>
    <item>
      <title>API is returning 0 tool paths where there are some.</title>
      <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9073904#M732</link>
      <description>&lt;P&gt;My code uses the API "Session.Toolpaths.Count" to return the tool path count, but many times this returns 0 tool paths when there ARE many uncalculated tool paths in the current session.&amp;nbsp; Does anyone know why this would happen?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 16:32:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9073904#M732</guid>
      <dc:creator>jeff.davis</dc:creator>
      <dc:date>2019-10-08T16:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: API is returning 0 tool paths where there are some.</title>
      <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9074639#M733</link>
      <description>&lt;P&gt;Hi Jeff&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you able to give an example of this happening?&amp;nbsp; Please ensure you are using the latest API version from NuGet.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It could be that you are using commands to create or import entities using Execute.&amp;nbsp; If you do this then the API can become skewed with what is in the project.&amp;nbsp; If this happens you can do:&lt;/P&gt;
&lt;PRE&gt;powerMill.ActiveProject.Refresh()&lt;/PRE&gt;
&lt;P&gt;If so, then let me know what command you are using, perhaps there is a suitable replacement within the API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Luke&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 21:27:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9074639#M733</guid>
      <dc:creator>luke.edwards.autodesk</dc:creator>
      <dc:date>2019-10-08T21:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: API is returning 0 tool paths where there are some.</title>
      <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9076456#M734</link>
      <description>&lt;P&gt;Thanks for helping me Luke.&lt;/P&gt;&lt;P&gt;I'll give a more complete description of what I'm doing.&amp;nbsp; I'm building an offline toolpath calculation farm.&amp;nbsp; We call it a "Crunching Farm".&amp;nbsp; I'm building this in VB.Net, and it's the first time using the API instead of the old OLE from Delcam.&lt;/P&gt;&lt;P&gt;I did get the newest API from NuGet.&amp;nbsp; My UI has two parts, one is for the users to submit their jobs to the Crunching Farm.&amp;nbsp; The other part is the server side, showing how many servers there are and what they are doing.&lt;/P&gt;&lt;P&gt;I use SQL server database to hold the jobs and keep track of the status of them.&lt;/P&gt;&lt;P&gt;So I have the users side built already.&amp;nbsp; It is simple because all I do is check to see if the current session has tool paths and if so do a save as to a jobs folder on the database server.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So you can see from my uploaded screen shots my "ProcessJob" code and the two test files I have in the database to work on.&lt;/P&gt;&lt;P&gt;It's strange because I can process tool paths before the save as command happened but loading the files after the save as produces "0 tool paths" in my code.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 15:14:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9076456#M734</guid>
      <dc:creator>jeff.davis</dc:creator>
      <dc:date>2019-10-09T15:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: API is returning 0 tool paths where there are some.  (Solved)</title>
      <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9082078#M735</link>
      <description>&lt;P&gt;Well I figured out how to stop the false reading of the toolpaths, but I don't know why I had to do this..&lt;/P&gt;&lt;P&gt;Doing a bunch of testing I found out that having the "LoadProject" and "ToolPath.Count" in the same subroutine was causing the return of 0 toolpaths.&amp;nbsp; I just made a new subroutine and move the calculate toolpath into this and the issue was fixed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;          'Setup the API and connect to PM
            Dim PM As New PMAutomation(Autodesk.ProductInterface.InstanceReuse.UseExistingInstance)
            Dim Session As PMProject = PM.ActiveProject
            PM.DialogsOff()

            'Load the job into PowerMill 
            Dim SourcePath As New Autodesk.FileSystem.Directory(JobPathSource)
            PM.LoadProject(SourcePath)

            'Update database and start to Calculate the toolpaths
            SqlStatusUpdate.Parameters.Item("@ServerName").Value = ServerName
            SqlStatusUpdate.Parameters.Item("@StatusWaiting").Value = 0
            SqlStatusUpdate.Parameters.Item("@StatusProcessing").Value = 1
            SqlStatusUpdate.Parameters.Item("@StatusComplete").Value = 0
            SqlStatusUpdate.Parameters.Item("@Filename").Value = JobPathName
            Connect_CruncherJobs.Open()
            SqlStatusUpdate.ExecuteNonQuery()
            Connect_CruncherJobs.Close()

            'Added message box to stop program for testing purpose
            MsgBox("There are " &amp;amp; Session.Toolpaths.Count &amp;amp; " Toolpaths")

            For I As Int32 = 0 To Session.Toolpaths.Count - 1
                Dim toolpath As PMToolpath = Session.Toolpaths(I)
                If toolpath.IsCalculated = False Then
                    toolpath.Calculate()
                End If
            Next&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Oct 2019 18:58:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9082078#M735</guid>
      <dc:creator>jeff.davis</dc:creator>
      <dc:date>2019-10-11T18:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: API is returning 0 tool paths where there are some.  (Solved)</title>
      <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9102771#M736</link>
      <description>&lt;P&gt;Do you have a small example application that could show this happening?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2019 08:56:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9102771#M736</guid>
      <dc:creator>luke.edwards.autodesk</dc:creator>
      <dc:date>2019-10-23T08:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: API is returning 0 tool paths where there are some.  (Solved)</title>
      <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9106529#M737</link>
      <description>&lt;P&gt;OK I had some time to create a repeatable small application that shows this issue.&lt;/P&gt;&lt;P&gt;In VB.net I created a project.&amp;nbsp; I added a single button and the code is below.&amp;nbsp; This issue happens when I load a job from the API.&amp;nbsp; If I remove the code that loads the job and already have the job loaded in a powermill session then all toolpath is found.&lt;/P&gt;&lt;P&gt;My work around was to place the code to calculate the toolpath outside of this subroutine and into it's own subroutine because I needed the code to load a job.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Imports Autodesk.ProductInterface.PowerMILL

Public Class Form1

    Private Sub CmdProcess_Click(sender As Object, e As EventArgs) Handles CmdProcess.Click

        'Setup the API and connect to PowerMill
        Dim PM As New PMAutomation(Autodesk.ProductInterface.InstanceReuse.UseExistingInstance)
        Dim Session As PMProject = PM.ActiveProject
        PM.DialogsOff()

        'Load job into PowerMill
        Dim SourcePath As New Autodesk.FileSystem.Directory("\\beavertn-svr-py\teamshare\Jeff D\SAMPLE 1")
        PM.LoadProject(SourcePath)

        For I As Int32 = 0 To Session.Toolpaths.Count - 1
            Dim Toolpath As PMToolpath = Session.Toolpaths(I)
            If Toolpath.IsCalculated = False Then
                Toolpath.Calculate()
            End If
        Next

    End Sub
End Class&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Oct 2019 15:33:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9106529#M737</guid>
      <dc:creator>jeff.davis</dc:creator>
      <dc:date>2019-10-24T15:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: API is returning 0 tool paths where there are some.  (Solved)</title>
      <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9107727#M738</link>
      <description>&lt;P&gt;The problem here is that the "PM.LoadProject()" command doesn't refresh your "Session" variable.&lt;/P&gt;&lt;P&gt;So either you use&lt;/P&gt;&lt;PRE&gt;Session.Refresh()&lt;/PRE&gt;&lt;P&gt;after loading the project or you initialize your "Session" variable &lt;U&gt;after&lt;/U&gt; you loaded the project&lt;/P&gt;&lt;PRE&gt;PM.LoadProject(SourcePath)
Dim Session As PMProject = PM.ActiveProject&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Oct 2019 05:33:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9107727#M738</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-10-25T05:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: API is returning 0 tool paths where there are some.  (Solved)</title>
      <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9108258#M739</link>
      <description>&lt;P&gt;You can even simplify it into one line:&lt;/P&gt;
&lt;PRE&gt;Dim session = PM.LoadProject(SourcePath)&lt;/PRE&gt;
&lt;P&gt;Luke&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 09:43:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9108258#M739</guid>
      <dc:creator>luke.edwards.autodesk</dc:creator>
      <dc:date>2019-10-25T09:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: API is returning 0 tool paths where there are some.  (Solved)</title>
      <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9108744#M740</link>
      <description>&lt;P&gt;Yes, refreshing the session did the trick.&amp;nbsp; It's still not clear to me why moving the tool path processing code out to a subroutine and calling that sub made this work for me.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 13:35:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9108744#M740</guid>
      <dc:creator>jeff.davis</dc:creator>
      <dc:date>2019-10-25T13:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: API is returning 0 tool paths where there are some.  (Solved)</title>
      <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9112490#M741</link>
      <description>&lt;P&gt;I wouldn't advise using the Refresh.&amp;nbsp; I would advise the line of code I showed:&lt;/P&gt;
&lt;PRE&gt;Dim session = PM.LoadProject(ProjectPath)&lt;/PRE&gt;
&lt;P&gt;It would have worked using the subroutine call presumably because you did the following inside the subroutine:&lt;/P&gt;
&lt;PRE&gt;Dim session = PM.ActiveProject&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Oct 2019 14:35:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powershape-and-powermill-api/api-is-returning-0-tool-paths-where-there-are-some/m-p/9112490#M741</guid>
      <dc:creator>luke.edwards.autodesk</dc:creator>
      <dc:date>2019-10-28T14:35:54Z</dc:date>
    </item>
  </channel>
</rss>

