Extrude-Cut in API (and also Interactively)

Extrude-Cut in API (and also Interactively)

Anonymous
Not applicable
1,575 Views
2 Replies
Message 1 of 3

Extrude-Cut in API (and also Interactively)

Anonymous
Not applicable

I am writing a simple command, wish takes a profile and calls Extrude-with-Cut-boolean. For this the code I have written is:

 

    def Execute(self, selectedProfile):
 
        if not isinstance(selectedProfile,adsk.fusion.Profile):
            return;
            
        app = adsk.core.Application.get();
        doc = app.activeDocument
        d = doc.design
        rootComp = d.rootComponent
        
        extrudes = rootComp.features.extrudeFeatures
        extrudeInput = extrudes.createInput(selectedProfile, adsk.fusion.FeatureOperations.CutFeatureOperation)
        distance = adsk.core.ValueInput.createByReal(.5);
        extrudeInput.setDistanceExtent(False, distance);
        extrude = extrudes.add(extrudeInput)

 

But it fails saying that, 'No body to intersect/cut' was found. But I had drawn cut-profile-sketch on a face of a body. That body should have been the obvious choice to cut with the computed tool-body.

 

Interactively also it fails. After searching some posts here, it seems that its bit inconsistent. sometimes it works.

 

CutFails.png

 

Any clues?

Accepted solutions (1)
1,576 Views
2 Replies
Replies (2)
Message 2 of 3

david_reaume
Autodesk
Autodesk
Accepted solution

To perform a cut in the scenerio you're dealing with, you'll need a negative value for the distance.  Choosing the cut operation does not automatically flip the positive direction of the extrude to point into the body to be cut.

 

So you should try:

distance = adsk.core.ValueInput.createByReal(-.5);

 

Happy Coding!

 

DaVeR

DaVeR
0 Likes
Message 3 of 3

Anonymous
Not applicable

Perfect!!! Thanks a lot.

0 Likes