Read property from the design with Api

Read property from the design with Api

sandeep.guliani
Observer Observer
335 Views
1 Reply
Message 1 of 2

Read property from the design with Api

sandeep.guliani
Observer
Observer

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

0 Likes
336 Views
1 Reply
Reply (1)
Message 2 of 2

Rushikesh.kadam
Autodesk
Autodesk

@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.