syuntoku14 / fusion2urdf

A Fusion 360 Script to export URDF
MIT License
454 stars 151 forks source link

Fix multiple components export #18

Closed alansrobotlab closed 5 years ago

alansrobotlab commented 5 years ago

Multiple changes to utils/utils.py to support exporting multiple copies of components:

  1. moved renaming old components to outside of copy_body, after all copies complete (otherwise you're renaming a copy of a component before you're finished, which affects all copies of that component)
  2. removed all the same_occs code (not necessary, and I think that's the reason that the method was creating X^2 old_components when there were multiple copies)
  3. renamed old_occs parameter to occs to avoid confusion with oldOccs array.
  4. you will definitely see a speedup. :-)

simple test design uploaded here: https://drive.google.com/open?id=1AGhEM4f63KbEJ8FhI6pkWpO6sjfRcVbK

Before this change, running the script would result in 16 copies of occuranced_link, and the four new components occuranced_link_1-4 would be overlaid over each other in the first position (among other things).

After this change, only one copy of each occuranced_link_1-4 is created, and each component is correctly positioned and exported even if it is one of multiple copies.

I've only tested out this change on two designs. I'd suggest testing it out yourself on a few different models, but the logic looks good, and it's working great for me.

Thanks!

Alan

alansrobotlab commented 5 years ago

apologies, I had two different changes in this one. closing it. I'll resubmit them separately.