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: 

Combine Cut via API

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
1388 Views, 2 Replies

Combine Cut via API

Hey,

 

I am new to API programming and I have a question: How to set up Combine feature with two bodies, so that the outcome is "cut" instead of "join"? I just cant find where to read about Variables to pass via "createInput" for Combine feature. I think I need to add

 

"adsk.fusion.FeatureOperations.CutFeatureOperation" somewhere, however if I try to push it via createInput, I get an error.

 

 

========== My Python Code =============

TargetBody = root.bRepBodies.itemByName('EraserTest')

 

ToolBodies = adsk.core.ObjectCollection.create()

ToolBodies.add(root.bRepBodies.itemByName('MtRTest'))

 

CombineCutInput = root.features.combineFeatures.createInput(TargetBody, ToolBodies )

 

CombineCutFeats = features.combineFeatures

CombineCutInput = CombineCutFeats.createInput(TargetBody, ToolBodies)

CombineCutFeats.add(CombineCutInput)

=====================================

It combines the two bodies, but how to cut?

 

Thanks in advance!

Tags (1)
2 REPLIES 2
Message 2 of 3
liujac
in reply to: Anonymous

Hi,

 

It's able to set the operation property of CombineFeatureInput object to CutFeatureOperation. The script below demo how to create a combine feature with "Cut"operation.

 

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

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        
        root = app.activeProduct.rootComponent
        features = root.features
        
        TargetBody = root.bRepBodies.itemByName('EraserTest')
 
        ToolBodies = adsk.core.ObjectCollection.create()
        ToolBodies.add(root.bRepBodies.itemByName('MtRTest'))
         
        CombineCutInput = root.features.combineFeatures.createInput(TargetBody, ToolBodies )
         
        CombineCutFeats = features.combineFeatures
        CombineCutInput = CombineCutFeats.createInput(TargetBody, ToolBodies)
        CombineCutInput.operation = adsk.fusion.FeatureOperations.CutFeatureOperation
        CombineCutFeats.add(CombineCutInput)
        
        ui.messageBox('Hello script')

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

 

Regards,

Jack

Message 3 of 3
Anonymous
in reply to: liujac

Works like a charm, thanks!

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