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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I rotate this key board?

Message 1 of 7
544 Views, 6 Replies

How can I rotate this key board?

Hi, I want to rotate this mac book cad model and I succeeded in rotating laptop except keyboard, because I can't get occurrence of the keyboard. How can I get occurrence of the keyboard and rotate it?

Screen Shot 2019-02-26 at 13.04.39.pngScreen Shot 2019-02-26 at 13.03.39.png 

Message 2 of 7
in reply to: orzorzorz619

I do not see if there is any different way required for keyboard as well. May be you would like to check if initial transform you are getting from occurrence is correct for keyboard or not.

Shyam Goyal
Sr. Software Dev. Manager
Message 3 of 7
in reply to: goyals

I checked count of occurrences list and it's 2. Occurrences.asList.item(2) are None. So definitely I can't get keyboard's occurrence. Please check my code and picture

Message 4 of 7
in reply to: orzorzorz619

The component.occurrences method only returns the top-level occurrences in the component, so it could be that your keyboard is just a body, or it could be a sub-component of something else.  It's very difficult to say why the keyboard isn't part of the list of occurrences from just the screenshot.  Would you be willing to share a copy of the model? Or, failing that, a screen shot that shows the design tree, fully expanded?

Message 5 of 7
in reply to: p.seem

I see. I attached the mac book cad file.

Message 6 of 7
in reply to: orzorzorz619

Yes, it looks like that was what was going on.  The body and lid are each their own component, but each of the keys is just a body within the root component. 


Components and bodies are quite different in the Fusion architecture, and 'Occurrences' are instances of a component.  You'd need to use a different method to iterate through all of the bodies, but then the body and lid wouldn't be included in that list.  I would recommend you create a new component and move all of the key bodies into it (see attached file).  Then I think you'll find the keyboard is also included in the rootComponent.occurrences list.


Folks in the design forum generally recommend one body per component, so you might even go further and turn each key into a component, and make them all sub-component of the keyboard.  But that step isn't necessary to make your script work.


I hope that helps.

Message 7 of 7
in reply to: p.seem

It does work. I really appreciate you.

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