<?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 Powermill Automation API in PowerShape and PowerMill API Forum</title>
    <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/powermill-automation-api/m-p/7230652#M1328</link>
    <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I´m newbie with Powermill API and i want to ask some help.&lt;/P&gt;&lt;P&gt;I have a little C# form menu with two buttons (For the moment) the first button works fine, but the second not work and get me an error.&lt;/P&gt;&lt;P&gt;Some body can help me please?&lt;/P&gt;&lt;P&gt;I attacht 2 images about the error i say.&lt;/P&gt;&lt;P&gt;Many thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;kindly regards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Erik&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="ERROR1.jpg" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/378282iCDFA74F5B39B9403/image-size/large?v=v2&amp;amp;px=999" role="button" title="ERROR1.jpg" alt="ERROR1.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="ERROR2.jpg" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/378283i55912C86931C88D8/image-size/large?v=v2&amp;amp;px=999" role="button" title="ERROR2.jpg" alt="ERROR2.jpg" /&gt;&lt;/span&gt;&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;//====================&lt;BR /&gt;//POWERMILL AUTOMATION&lt;BR /&gt;//====================&lt;BR /&gt;using System;&lt;BR /&gt;using System.Collections.Generic;&lt;BR /&gt;using System.ComponentModel;&lt;BR /&gt;using System.Data;&lt;BR /&gt;using System.Drawing;&lt;BR /&gt;using System.Linq;&lt;BR /&gt;using System.Text;&lt;BR /&gt;using System.Windows.Forms;&lt;BR /&gt;using Delcam.ProductInterface.PowerMILL;&lt;BR /&gt;using Delcam.ProductInterface;&lt;BR /&gt;using Delcam.Geometry;&lt;/P&gt;&lt;P&gt;namespace CS_FORM_TEST1&lt;BR /&gt;{&lt;BR /&gt;public partial class Form1 : Form&lt;BR /&gt;{&lt;BR /&gt;public Form1()&lt;BR /&gt;{&lt;BR /&gt;InitializeComponent();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;private void Form1_Load(object sender, EventArgs e)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;private void button1_Click(object sender, EventArgs e)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;PMAutomation powerMILL = new PMAutomation(Delcam.ProductInterface.InstanceReuse.UseExistingInstance);&lt;BR /&gt;PMProject pSession = powerMILL.ActiveProject;&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;private void button2_Click(object sender, EventArgs e)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;Delcam.FileSystem.File importFile = new Delcam.FileSystem.File(@"C:\Users\*****\Desktop\HOLES.dgk");&lt;BR /&gt;PMModel myModel = pSession.Models.CreateModel(importFile);&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&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;</description>
    <pubDate>Sat, 15 Jul 2017 21:43:00 GMT</pubDate>
    <dc:creator>lopezerik73</dc:creator>
    <dc:date>2017-07-15T21:43:00Z</dc:date>
    <item>
      <title>Powermill Automation API</title>
      <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/powermill-automation-api/m-p/7230652#M1328</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I´m newbie with Powermill API and i want to ask some help.&lt;/P&gt;&lt;P&gt;I have a little C# form menu with two buttons (For the moment) the first button works fine, but the second not work and get me an error.&lt;/P&gt;&lt;P&gt;Some body can help me please?&lt;/P&gt;&lt;P&gt;I attacht 2 images about the error i say.&lt;/P&gt;&lt;P&gt;Many thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;kindly regards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Erik&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="ERROR1.jpg" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/378282iCDFA74F5B39B9403/image-size/large?v=v2&amp;amp;px=999" role="button" title="ERROR1.jpg" alt="ERROR1.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="ERROR2.jpg" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/378283i55912C86931C88D8/image-size/large?v=v2&amp;amp;px=999" role="button" title="ERROR2.jpg" alt="ERROR2.jpg" /&gt;&lt;/span&gt;&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;//====================&lt;BR /&gt;//POWERMILL AUTOMATION&lt;BR /&gt;//====================&lt;BR /&gt;using System;&lt;BR /&gt;using System.Collections.Generic;&lt;BR /&gt;using System.ComponentModel;&lt;BR /&gt;using System.Data;&lt;BR /&gt;using System.Drawing;&lt;BR /&gt;using System.Linq;&lt;BR /&gt;using System.Text;&lt;BR /&gt;using System.Windows.Forms;&lt;BR /&gt;using Delcam.ProductInterface.PowerMILL;&lt;BR /&gt;using Delcam.ProductInterface;&lt;BR /&gt;using Delcam.Geometry;&lt;/P&gt;&lt;P&gt;namespace CS_FORM_TEST1&lt;BR /&gt;{&lt;BR /&gt;public partial class Form1 : Form&lt;BR /&gt;{&lt;BR /&gt;public Form1()&lt;BR /&gt;{&lt;BR /&gt;InitializeComponent();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;private void Form1_Load(object sender, EventArgs e)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;private void button1_Click(object sender, EventArgs e)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;PMAutomation powerMILL = new PMAutomation(Delcam.ProductInterface.InstanceReuse.UseExistingInstance);&lt;BR /&gt;PMProject pSession = powerMILL.ActiveProject;&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;private void button2_Click(object sender, EventArgs e)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;Delcam.FileSystem.File importFile = new Delcam.FileSystem.File(@"C:\Users\*****\Desktop\HOLES.dgk");&lt;BR /&gt;PMModel myModel = pSession.Models.CreateModel(importFile);&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&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;</description>
      <pubDate>Sat, 15 Jul 2017 21:43:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powershape-and-powermill-api/powermill-automation-api/m-p/7230652#M1328</guid>
      <dc:creator>lopezerik73</dc:creator>
      <dc:date>2017-07-15T21:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: Powermill Automation API</title>
      <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/powermill-automation-api/m-p/7232426#M1329</link>
      <description>&lt;P&gt;move this line just below your class declaration:&lt;/P&gt;
&lt;PRE&gt;PMAutomation powerMILL = new PMAutomation(Delcam.ProductInterface.InstanceReuse.UseExistingInstance);&lt;/PRE&gt;
&lt;P&gt;and add another definition of the active session at the beginning of the button2_click event:&lt;/P&gt;
&lt;PRE&gt;PMProject pSession = powerMILL.ActiveProject;
                Delcam.FileSystem.File importFile = new Delcam.FileSystem.File(@"C:\Users\*****\Desktop\HOLES.dgk");
                PMModel myModel = pSession.Models.CreateModel(importFile);&lt;/PRE&gt;
&lt;P&gt;your problem is that the code inside of button2_click doesn't know what "pSession" is because it is being defined only in the other button's method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should work:&lt;/P&gt;
&lt;PRE&gt;public partial class Form1 : Form
        {
            PMAutomation powerMILL = new PMAutomation(Delcam.ProductInterface.InstanceReuse.UseExistingInstance);

            public Form1()
            {
                InitializeComponent();
            }

            private void Form1_Load(object sender, EventArgs e)
            {

            }

            private void button1_Click(object sender, EventArgs e)
            {
                PMProject pSession = powerMILL.ActiveProject;
            }

            private void button2_Click(object sender, EventArgs e)
            {
                PMProject pSession = powerMILL.ActiveProject;
                Delcam.FileSystem.File importFile = new Delcam.FileSystem.File(@"C:\Users\*****\Desktop\HOLES.dgk");
                PMModel myModel = pSession.Models.CreateModel(importFile);
            }
        }&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Jul 2017 12:37:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powershape-and-powermill-api/powermill-automation-api/m-p/7232426#M1329</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-07-17T12:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: Powermill Automation API</title>
      <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/powermill-automation-api/m-p/7232475#M1330</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First &amp;nbsp;at all many thanks for your answer and help me nbaranowski.&lt;/P&gt;&lt;P&gt;Your solution is not correct at all.&lt;/P&gt;&lt;P&gt;Now when execute the code start automatically the Powermiil and not when press the button for start it.&lt;/P&gt;&lt;P&gt;But the second button works nice and import the file correctly.&lt;/P&gt;&lt;P&gt;Many thanks again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kindly regards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Erik&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 12:56:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powershape-and-powermill-api/powermill-automation-api/m-p/7232475#M1330</guid>
      <dc:creator>lopezerik73</dc:creator>
      <dc:date>2017-07-17T12:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: Powermill Automation API</title>
      <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/powermill-automation-api/m-p/7232517#M1331</link>
      <description>&lt;P&gt;You have the object set to "UseExistingInstance" so i assumed your session was already open.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can just move another copy of the PMAutomation object into the button2_click to get what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is tested and works:&lt;/P&gt;
&lt;PRE&gt;//====================
//POWERMILL AUTOMATION
//====================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Delcam.ProductInterface.PowerMILL;
using Delcam.ProductInterface;
using Delcam.Geometry;


namespace CS_FORM_TEST1
{
    public partial class Form1 : Form
    {
        

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {

            PMAutomation powerMILL = new PMAutomation(Delcam.ProductInterface.InstanceReuse.CreateNewInstance);

        }

        private void button2_Click(object sender, EventArgs e)
        {
            PMAutomation powerMILL = new PMAutomation(Delcam.ProductInterface.InstanceReuse.UseExistingInstance);
            PMProject pSession = powerMILL.ActiveProject;
            Delcam.FileSystem.File importFile = new Delcam.FileSystem.File(@"C:\Users\*******\Desktop\HOLES.dgk");
            PMModel myModel = pSession.Models.CreateModel(importFile);

        }
    }
}&amp;nbsp;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Jul 2017 13:25:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powershape-and-powermill-api/powermill-automation-api/m-p/7232517#M1331</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-07-17T13:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: Powermill Automation API</title>
      <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/powermill-automation-api/m-p/7232597#M1332</link>
      <description>&lt;P&gt;Many thanks nbaranowski.&lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://forums.autodesk.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now works perfect as i want.&lt;/P&gt;&lt;P&gt;I try now to add more options to my little API.&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kindly regards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Erik&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 13:33:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powershape-and-powermill-api/powermill-automation-api/m-p/7232597#M1332</guid>
      <dc:creator>lopezerik73</dc:creator>
      <dc:date>2017-07-17T13:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: Powermill Automation API</title>
      <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/powermill-automation-api/m-p/10436224#M1333</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Khoa_NguyenDang_0-1625155273932.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/936677i41181BEA24D658B3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Khoa_NguyenDang_0-1625155273932.png" alt="Khoa_NguyenDang_0-1625155273932.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have the same Problem but can not fix with your method&lt;/P&gt;&lt;P&gt;Please help me&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 16:01:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powershape-and-powermill-api/powermill-automation-api/m-p/10436224#M1333</guid>
      <dc:creator>Khoa_NguyenDang</dc:creator>
      <dc:date>2021-07-01T16:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: Powermill Automation API</title>
      <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/powermill-automation-api/m-p/10437894#M1334</link>
      <description>&lt;P&gt;Hi, what version of PowerMill are you running?&amp;nbsp; Can you open task manager and see if pmill.exe is running when you get this error?&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 07:53:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powershape-and-powermill-api/powermill-automation-api/m-p/10437894#M1334</guid>
      <dc:creator>luke.edwards.autodesk</dc:creator>
      <dc:date>2021-07-02T07:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: Powermill Automation API</title>
      <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/powermill-automation-api/m-p/10438167#M1335</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3204420"&gt;@luke.edwards.autodesk&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am using Power 2022 and PowerMill API 1.1.53&lt;/P&gt;&lt;P&gt;I aldready open PowerMill when run Form&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 09:59:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powershape-and-powermill-api/powermill-automation-api/m-p/10438167#M1335</guid>
      <dc:creator>Khoa_NguyenDang</dc:creator>
      <dc:date>2021-07-02T09:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: Powermill Automation API</title>
      <link>https://forums.autodesk.com/t5/powershape-and-powermill-api/powermill-automation-api/m-p/10447501#M1336</link>
      <description>&lt;P&gt;Hi, does it give a stack trace in the error report?&amp;nbsp; That would help me work out which line it is failing on.&lt;/P&gt;
&lt;P&gt;One thing to check, is it PowerMill you are running or PowerMill Viewer?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 17:54:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powershape-and-powermill-api/powermill-automation-api/m-p/10447501#M1336</guid>
      <dc:creator>luke.edwards.autodesk</dc:creator>
      <dc:date>2021-07-06T17:54:09Z</dc:date>
    </item>
  </channel>
</rss>

