Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Edit Sketch via API

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
scottmoyse
483 Views, 5 Replies

Edit Sketch via API

It looks to me like this isn't possible. But I would like to be able to loop through a heap of sketches, then once I find one with a specific attribute, 'select' it for manual editing by the user. 

 

But it looks like in most cases you can't call native Fusion commands on objects you have selected via the API... or am I missing a trick here?


Scott Moyse
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature


Design & Manufacturing Technical Services Manager at Cadpro New Zealand

Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project

5 REPLIES 5
Message 2 of 6
BrianEkins
in reply to: scottmoyse

You can start ANY command using the API.  However, most commands don't use the current selection or need additional input besides a selection so just starting the command doesn't cause anything to happen except for the command dialog to pop up, waiting for input.  There are a few commands that don't require any input or they do use the active selection and that's enough for them to do whatever they do without requiring any additional input.  The edit sketch command happens to be one of these.  Here's an untested example of how it would work.

sk = root.Sketches.ItemByName('MySketch')
ui.activeSelections.clear()
ui.activeSelections.add(sk)
skCmd = ui.commandDefinitions.itemById('SketchActivate')
skCmd.execute()

 

 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 6
scottmoyse
in reply to: BrianEkins

Legend. Thanks. I'll give that a try.

Scott Moyse
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature


Design & Manufacturing Technical Services Manager at Cadpro New Zealand

Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project

Message 4 of 6
yosef.ali.omar
in reply to: BrianEkins

when following this code i get this error the rootLogger object has no occurrence ItemByName I am wondering where I want wrong here is what i used 

 

 

     

 

        sk = root.sketches.ItemByName('Sketch1')
        #Activating SKETCH
        #choose the section sketch as active
        ui.activeSelections.clear()
        ui.activeSelections.add(sk)


        skCmd=ui.commandDefinitions.itemById('SketchActivate')
        skCmd.execute()

 

Message 5 of 6
kandennti
in reply to: yosef.ali.omar

Hi @yosef.ali.omar .

 

This is due to the fact that the first letter of the method name is capitalized.

sk = root.sketches.itemByName('Sketch1')
Message 6 of 6
yosef.ali.omar
in reply to: kandennti

Thank you, yes that fixed it

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report