Message 1 of 4
Get ProcessID Issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I Open two PowerMILL 2017. and I can see the process ids are 6416 and 11828.
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.
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));
}
}
}
}
