Help with API - description model

Help with API - description model

Marek_Skotak
Advocate Advocate
767 Views
3 Replies
Message 1 of 4

Help with API - description model

Marek_Skotak
Advocate
Advocate

Hi All,

 

 im writing one python macro and i would need read this parameter from a model. 

 

Can someone help me with this please? 

 

Snímek obrazovky 2020-11-22 v 10.45.26.png

 

Thanks very much. 

 

Postprocessor writer, CNC trainer, .NET programmer, www.cadcam-softcz.cz
0 Likes
Accepted solutions (3)
768 Views
3 Replies
Replies (3)
Message 3 of 4

PinRudolf
Advocate
Advocate
Accepted solution

Note that you grab the occurrence when you're selecting something from a design. Make sure to find the component before getting the properties. The code should look something like this:

 

occurrence.component.description

 

Message 4 of 4

Marek_Skotak
Advocate
Advocate
Accepted solution

 

There is a part of code for a looking component description which i used. For everyone who will looking it 🙂 

 

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

 
        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)    
        # get all components in this design
        allComps = design.allComponents
        for comp in allComps:
          ui.messageBox('comp description = ' + comp.description)


      
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Postprocessor writer, CNC trainer, .NET programmer, www.cadcam-softcz.cz