How to tell if a component is a parametric design, or not?

How to tell if a component is a parametric design, or not?

Dave.SendItCNC
Contributor Contributor
609 Views
2 Replies
Message 1 of 3

How to tell if a component is a parametric design, or not?

Dave.SendItCNC
Contributor
Contributor
The following python code works great to dump component names and values, until its used on a design which includes non-parametric components. In that case, fusion.py correctly reports 'RuntimeError: 3: this is not a parametric design" from _fusion.Component__get_modelParameters.
 
So, does anybody know  how to tell if a component is not a parametric design, so as to avoid referencing the modelParameters property?
 
...
for comp in design.allComponents:
    if comp.modelParameters:
        for param in comp.modelParameters:
            logger.print('Component: {} param: {} = {}'.format(comp.name,param.name,param.value))
0 Likes
Accepted solutions (1)
610 Views
2 Replies
Replies (2)
Message 2 of 3

BrianEkins
Mentor
Mentor
Accepted solution

You can determine this but it's not a property of a component but is a setting of the Design.  The entire design is either parametric or not.  You use the designType property of the Design object.  It can be one of two values: adsk.fusion.DesignTypes.DirectDesignType or adsk.fusion.DesignTypes.ParametricDesignType.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 3

Dave.SendItCNC
Contributor
Contributor
Brian, thanks! Works great now.
 
...
 
 
for comp in design.allComponents:
    if comp.parentDesign.designType == adsk.fusion.DesignTypes.ParametricDesignType:
        for param in comp.modelParameters:
        logger.print('Component: {} param: {} = {}'.format(comp.name,param.name,param.value))
    else:
        logger.print('Component: {} is not a parametric design'.format(comp.name,param.name,param.value))