Create Groups in Python

Create Groups in Python

davemurrayrust
Enthusiast Enthusiast
339 Views
3 Replies
Message 1 of 4

Create Groups in Python

davemurrayrust
Enthusiast
Enthusiast

I'd like to create a bunch of Planes and Sketches, and then group them in Python. As far as I can tell, this can't be done through the API, it needs to be done through Text Commands. I've been following an example that does it for Surfaces (https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/feature-request-api-for-creating-and-man...) but I don't think that works for Sketches or Planes (I'm not certain, but I get a 'Command not available in this context' error when I commit them.

Is there an equivalent to `Commands.Start FusionCreateSurfaceGroupCommand` for Sketches and Planes? or should this command work?

Also - how can I find a list of commands I can call with `Commands.Start`? If I explore the command line, it doesn't seem able to give me a list (e.g. `Commands.Start /?` just says it starts commands, not which ones...)

0 Likes
340 Views
3 Replies
Replies (3)
Message 2 of 4

Jorge_Jaramillo
Advisor
Advisor

Hi,

 

The equivalents are:

- For sketchs groups: "Commands.Start FusionCreateSketchCustomGroupCommand"
- For planes groups: "Commands.Start FusionCreateWorkGeometryCustomGroupCommand"

Before calling each of them, it has to be selected the right object in the tree, otherwise Fusion will crash.

 

All the available commands are in the adsk.core.Application.get().userInterface.commandDefinitions collection.

If you run the following command (in the Text Commands window, with "Py" radio button enabled on the right):

adsk.core.Application.get().userInterface.commandDefinitions.count

you will get the number of commands currently available.  In my case it is 3027:

Jorge_Jaramillo_0-1771525316339.png

 

I hope this can help.

 

Regards,

Jorge Jaramillo

 

 

Message 3 of 4

davemurrayrust
Enthusiast
Enthusiast

That's super helpful, thanks!

 


@Jorge_Jaramillo wrote:

Before calling each of them, it has to be selected the right object in the tree, otherwise Fusion will crash.

Any idea how I do that? I can step through the group commands by hand now in the python prompt, but I can't figure out how to programatically select the Sketches object in the browser.

0 Likes
Message 4 of 4

Jorge_Jaramillo
Advisor
Advisor

Hi,

 


@davemurrayrust wrote:

Any idea how I do that? I can step through the group commands by hand now in the python prompt, but I can't figure out how to programatically select the Sketches object in the browser.


I'll try to some tests and let you know if I found something useful.

 

Regards,

Jorge Jaramillo

 

0 Likes