Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding

Component .partNumber throw error

jeanfabre
Enthusiast

Component .partNumber throw error

jeanfabre
Enthusiast
Enthusiast

Hi,

 

 how can one access the part number of a given component?

 

I did actually set my component to have a part number,

 

Autodesk_Fusion_360__Startup_License__and_New_Message_-_Autodesk_Community.png

 The api doc mentions that property .partNumber but it throws an error when I try to query for it.

 

    if component.partNumber:
  File "/Applications/Fusion360.app/Contents/Api/Python/packages/adsk/fusion.py", line 16086, in <lambda>
    __getattr__ = lambda self, name: _swig_getattr(self, Occurrence, name)
  File "/Applications/Fusion360.app/Contents/Api/Python/packages/adsk/fusion.py", line 57, in _swig_getattr
    raise AttributeError(name)
AttributeError: partNumber

 

Any help appreciated 🙂

 

 Bye,

 

 Jean

 

 

 

0 Likes
Reply
Accepted solutions (1)
512 Views
3 Replies
Replies (3)

JesusFreke
Advocate
Advocate
Accepted solution

Based on the error message, your "component" variable does not contain a component, but rather, an occurrence.

 

__getattr__ = lambda self, name: _swig_getattr(self, Occurrence, name)

 

And Occurrence does not have a .partNumber attribute.

 

What you probably want in this case is component.component.partNumber

 

I would also recommend you rename your variable to occurrence, for clarity 🙂

2 Likes

jeanfabre
Enthusiast
Enthusiast

Hi,

 

 yes, I started getting a grasp on occurences few minutes ago, and now I understand I was mistaking Components and Occurences. I am still shady as to how I should understand the actual browser listing inside the fusion UI. I think the UI is confusing now, since I can create a new Component in the UI, but it actually becomes an Occurence as you work on it, with the exception of the rootComponent which can only be an occurence in another design. So inside the fusion UI and browser, an occurence is always named "XXX:i" where XXX is the name of the component and i the occurence index of it.

 

Am I on the right path?

 

thanks for your help, I am already storming through my parser now 🙂 dumping all Occurences of a design into xml, with their transform matrix, Component part number,  and various meta data like planes and axis, joints,  so that I can reconstruct it inside Unity

 

Have a good day!

 

 Jean

0 Likes

BrianEkins
Mentor
Mentor

The Fusion help system is down at the moment so I can't provide a link, but in the user manual there is a topic on "Document and Assembly Structure" that should help.  The UI is confusing because it refers to everything as a "Component" even when that isn't actually the case.  I also presented a class at AU a couple of years ago that goes into more detail.

https://www.autodesk.com/autodesk-university/class/Components-Components-Components-Depth-Look-Inter...

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
1 Like