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: 

Read property from the design with Api

1 REPLY 1
Reply
Message 1 of 2
sandeep.guliani
91 Views, 1 Reply

Read property from the design with Api

Dear Fusion-Community,

 

I want to read/extract the properties from any design. I am trying to write a script that can help me read specifications like length, breadth, radius, height, angle etc.

From the samples, I could learn and find the count of Features.

 

       ui  = app.userInterface  
       product = app.activeProduct
       design = adsk.fusion.Design.cast(product)
       sketch = design.rootComponent.sketches
    #all Features
        features = design.rootComponent.features
     #Hole Features
        holff = features.holeFeatures
    #Features count
        print(holff.count)
 
     #Extrude Features
        extff = features.extrudeFeatures
    #Features count
        print(extff.count)

 

But I want to extract the specifications of a specific feature details. 

I am looking for some help and guidance.

 

Thanks

1 REPLY 1
Message 2 of 2

@sandeep.guliani One can get read a property from the respective feature object. Here is a sample script to know the properties of a hole feature like diameter, center, and length.

#Author-
#Description-

import adsk.core, adsk.fusion, adsk.cam, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)
        features = design.rootComponent.features
        for hole_feature in features.holeFeatures:
            app.log(str(f'--------{hole_feature.name}------'))
            app.log(str(f'Dia: {hole_feature.holeDiameter.expression}'))
            app.log(str(f'Center: {hole_feature.position.x}, {hole_feature.position.y}, {hole_feature.position.z}'))
            app.log(str(f'Length: {hole_feature.extentDefinition.distance.expression}'))


    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

Here is a link to HoleFeature object help document https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-GUID-3315b7ea-f85d-417c-ad31-2d328b72f6a5

If you go through the correct property you will find the required value.

 

Similarly, you need to refer to other feature objects' properties to read the value.

 

Here is a link for ExtrudeFeature object https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-GUID-62d132d3-2ae9-4d74-91d1-f2eee3d68f5d

 

Hope it helps.

 

Regards,

If my reply was helpful, please click the "Accept as Solution" button. It helps others get the answer quickly! A "Like" is always welcomed




Rushikesh Kadam
Senior QA Engineer
Quality Assurance
Autodesk, Inc.


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