Get ProcessID Issue.

Get ProcessID Issue.

hx
Advocate Advocate
641 Views
3 Replies
Message 1 of 4

Get ProcessID Issue.

hx
Advocate
Advocate

I Open two PowerMILL 2017. and I can see the process ids are 6416 and 11828.

 

 

Pm Process ID.png 


When I use the PMAutomation.GetListOfPmComObjects() method to get the PmComOberjects and read then Property ProcessID is PMAutomation.

All the Process Id are reutrn the first instance id. not the right one.

 

Get PM Instances.png

here is my code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Autodesk.ProductInterface;
using Autodesk.ProductInterface.PowerMILL;

namespace PMAutomaticTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private List<PMAutomation> PMAutoLists = new List<PMAutomation>();
        private void button1_Click(object sender, EventArgs e)
        {
            List<object> lisCom  = PMAutomation.GetListOfPmComObjects();
            foreach (var item in lisCom)
            {
                this.PMAutoLists.Add(new PMAutomation(item));
            }

            //var firstAuto = (PMAutomation)PMAutoLists.First<PMAutomation>();
            //firstAuto.IsVisible = false;
            //MessageBox.Show("Done");

            foreach (var pm in PMAutoLists)
            {
                this.listBox1.Items.Add(string.Format("PM:{0} ProcessID:{1}", pm.MainWindowId, pm.ProcessId));
            }

        }
    }
}
0 Likes
642 Views
3 Replies
Replies (3)
Message 2 of 4

luke.edwards.autodesk
Community Manager
Community Manager

Hi, I can see that this is the case.  Unfortunately it is not possible to query PowerMill to find out its process id.  We attempt to guess it at present but obviously this does not work.  I can request this functionality to be added to PowerMill but I am not sure where it will fit in their development priorities.

How do you plan to use the Process Id?


Luke Edwards
Consulting Services Manager
0 Likes
Message 3 of 4

hx
Advocate
Advocate

Users can be distinguished by process id intuitively, which PowerMILL process is currently associated

0 Likes
Message 4 of 4

luke.edwards.autodesk
Community Manager
Community Manager

I have created a Pull Request on the open source to resolve this issue:

https://github.com/Autodesk/PowerShapeAndPowerMillAPI/pull/9

 

We will get it pulled, built and a new beta version with this fix in should be available through NuGet later today or tomorrow.


Luke Edwards
Consulting Services Manager
0 Likes