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: 

How to use .setAllExtent() for extrusion feature

4 REPLIES 4
Reply
Message 1 of 5
harrykeeninventor
487 Views, 4 Replies

How to use .setAllExtent() for extrusion feature

I'm extruding some profiles on different planes and on some planes it trys to extrude the profile in a direction tangent to the sketch plane and fails. So i'm trying to set the direction as a

 

adsk.fusion.ExtentDirections.PositiveExtentDirection

 

but I don't understand what the parameter value should be in the .setAllExtent method - i'm miss understanding this help page I think;

 

http://help.autodesk.com/view/NINVFUS/ENU/?guid=GUID-3e9bcf4c-7f75-4b5d-860a-827e4c342d3e

 

Full code here;

 

 

        # Create extrusion input
        extrudes = rootComp.features.extrudeFeatures
        extInput = extrudes.createInput(profiles, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
    
        # Define distance of extrude
        distance = adsk.core.ValueInput.createByReal(feature['distance'] / 10)
        # Set the distance extent to be symmetric
        extInput.setDistanceExtent(True, distance)

        # Set the extrude to be a solid
        # extInput.isSolid = True

        # extent_def = adsk.fusion.ExtentDirections.PositiveExtentDirection

        # Set direction
        extInput.setAllExtent(1)

        # Create the extrusion
        ext = extrudes.add(extInput)

Any help much appreciated and an example would be even more appreciated!

 

Thanks

 

4 REPLIES 4
Message 2 of 5
ekinsb
in reply to: harrykeeninventor

Based on your description, it sounds like the API isn't checking your input to make sure it's valid.  The profiles that you input for an extrusion should all be co-planar.  If you're able to input profiles that lie in planes oriented differently then it's not validating the input correctly.  If you use the Extrude command interactively, you'll see that it has this limitation and using the API to create an extrusion is no different.

 

I could have misunderstood what you're doing though.  If I'm correct can you confirm that's what you're trying to do and I'll log a bug so that it this will get caught earlier when you specify the profile.  If I did misunderstand, I'll be happy to look at is closer if you can provide some more details.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 5
harrykeeninventor
in reply to: ekinsb

Hi Brian, thanks for getting back to me.

 

I see what your saying. I'm trying to extrude sketches on different planes with in the same script, but i'm doing it with two different extrude calls and setting up two different extrude inputs;

 

Screen Shot 2016-06-30 at 10.56.53 AM.png

 

As you can see there are two sketches here, i've imported both using createDXF2DImportOptions on the xYConstructionPlane, it doesn't seem to matter which ConstructionPlane I import on to the first sketch extrudes and the second doesn't.

 

It's quite difficult to debug. I don't know if the coplanar issue you mention here applies?

 

In this example the "profiles" used in the extrusion input is an object collection but it redefines and clears the object collection before adding new profiles for each extrude (in this case it's only one profile each time).

Message 4 of 5
ekinsb
in reply to: harrykeeninventor

Since you're creating them as separate extrusions it should work.  Is it possible to post a simple reproducible sample that we can look at?  It's hard to tell if there's something wrong in your program or possibly an issue with geometry that was imported.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 5 of 5
harrykeeninventor
in reply to: ekinsb

Very early test code, but i'll try and explain.

 

If you unzip the attachment and load the .py file into fusion from that location as a script then it should reference the other files it needs from that directory.

 

If you run the code  on an empty "design" you should see the error;

 

Failed:
Traceback (most recent call last):
  File "{}/ucf-fusion-loader.py", line 115, in run
    ext = extrudes.add(extInput)
  File "/Users/harry/Library/Application Support/Autodesk/webdeploy/production/cb5e8e435f8356e046bf6e45ad1bd4086fde57c7/Autodesk Fusion 360.app/Contents/Api/Python/packages/adsk/fusion.py", line 8289, in add
    return _fusion.ExtrudeFeatures_add(self, *args)
RuntimeError: 5 :   The path is tangent to the profile.
    Try adjusting the path or rotating the profile.+Tool body creation failed

 

The code is basically reading in a .json file and building the different features it describes.

 

Thanks for your help.

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