Powermill api, plugin gets stuck on UseExistingInstance

Powermill api, plugin gets stuck on UseExistingInstance

adrian.motea
Enthusiast Enthusiast
1,599 Views
3 Replies
Message 1 of 4

Powermill api, plugin gets stuck on UseExistingInstance

adrian.motea
Enthusiast
Enthusiast

Hi, i noticed a problem with all my plugins made in vb.net using windows forms.

 

if i have a pmill running that is making a toolpath calculation, and i open another pmill,

the code gets stuck at this line

PMillInstance = New PMAutomation(Autodesk.ProductInterface.InstanceReuse.UseExistingInstance)

and it doesn't proceed until the first pmill finishes.

 

Same thing happens also when i try to enable the plugin, it just get stuck with execution on the same line.

 

the code is inside the initialise sub 

 

Public Sub Initialise(Token As String, pServices As PowerMILL.PluginServices, ParentWindow As Integer) Implements PowerMILL.IPowerMILLPlugin.Initialise

PMillInstance = New PMAutomation(Autodesk.ProductInterface.InstanceReuse.UseExistingInstance)

...

end sub

 

anyone has any idea why this might happen ?

 

Thanks in advance

0 Likes
Accepted solutions (1)
1,600 Views
3 Replies
Replies (3)
Message 2 of 4

ondrej.mikulec
Advocate
Advocate
Accepted solution

Hi,
Your code looks like you already got pServices from Plugin Framework. Then I think you don't need to initialize PMAutomation from API.
Actually, PMillInstance = New PMAutomation(Autodesk.ProductInterface.InstanceReuse.UseExistingInstance) doesn't differentiate between instances of PMs so you could have pServices from the correct one and the PMAutomation from the other. 
From the code (open source in the internet) the New PMAutomation(Autodesk.ProductInterface.InstanceReuse.UseExistingInstance)  is just using Marshal.GetActiveObject(CLASS_ID) where the CLASS_ID is  "PowerMILL.Application". In this case, you will just get the first instance of the Powermill which was run first. 
If you want to connect to the correct instance, look at the  New PMAutomation(powerMillComObject).

0 Likes
Message 3 of 4

adrian.motea
Enthusiast
Enthusiast
Thanks,
indeed all data needed was already there, and no need to do "new pmautomation..."

Thanks again
0 Likes
Message 4 of 4

nguyenthinhvt95
Advocate
Advocate

Do you have any sample with this code? 

New PMAutomation(powerMillComObject)

0 Likes