API Call woodwork application Python (WW4I)

API Call woodwork application Python (WW4I)

cavallerin
Enthusiast Enthusiast
388 Views
5 Replies
Message 1 of 6

API Call woodwork application Python (WW4I)

cavallerin
Enthusiast
Enthusiast

How can I create an instance for woodwork 4 inventor addin inside a python script?

 

import win32com.client as wc

# istanzio l'applicazione di inventor
try:
    inv = wc.GetActiveObject('Inventor.Application')
    ww = inv.woodworkApplication

except:
    inv = wc.Dispatch('Inventor.Application')
    inv.Visible = True
0 Likes
Accepted solutions (1)
389 Views
5 Replies
Replies (5)
Message 2 of 6

Michael.Navara
Advisor
Advisor
Accepted solution

Hi @cavallerin 

Woodwork is an add-in for Inventor, not built-in component.

All you can try is to get its Automation property and look, if it provides any API functions. Unfortunately this property usually returns NULL or some unknown object.

 

0 Likes
Message 3 of 6

cavallerin
Enthusiast
Enthusiast

Ok thx a lot it worked, but to get the WW4I object I use this calling:

 

 

 

ww = inv.ApplicationAddIns.Item(49).Automation

 

 

 
where 49 is the progressive number of the addin in my system.
Maybe I'm wrong, but does Inventor use internal Id(s) to identify this objects? Is there a way to get it?
 
 
 
0 Likes
Message 4 of 6

Michael.Navara
Advisor
Advisor

If number 49 works now, you can obtain its ClientId and use it instead of this index. This Client id is persistent for whole lifecycle of the addin.

ww4iClientId=inv.ApplicationAddins.Item(49).ClientId

 

ww = inv.ApplicationAddIns.ItemById(ww4iClientId).Automation
# Or
ww = inv.ApplicationAddIns.ItemById('WW4I-CLIENTID-GUID-HERE').Automation

 

Sorry I'm not familiar with python. Excuse me if there are some syntax error.

Message 5 of 6

cavallerin
Enthusiast
Enthusiast

{FEF38B5F-CACF-4647-8EE5-1F642F03C610}

got it!

But what do you mean by "This Client id is persistent for whole lifecycle of the addin." ?

 

A colleague of mine can set the same UUID?

 

0 Likes
Message 6 of 6

Michael.Navara
Advisor
Advisor

It means this ClientId is the same for all versions of WW. It should be stable for future versions.