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: 

Crash extruding to Construction Plane

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
chris.monachanZWSCF
319 Views, 3 Replies

Crash extruding to Construction Plane

I have a consistent crash when trying to extrude a profile to a construction plane where the construction plane is given as a ToEntityExtentDefinition in setOneSideExtent in the ExtrudeFeatureInput. 

 

I don't have code to hand but if people can't reproduce I can put some together. Basically I've tried everyway and it always crashes. In the UI this operation works fine, but not through the API. 

 

As a work-a-round I now create a temp body, extrude to that face and then get rid of the body. This seems like an easy fix to me as it's a crash and should be fairly simple to see what's going on if you have the Fusion source in-front of you when it crashes.

BTW in my case, this is in parametric design mode and the target plane and the source sketch profile are at angles.

Labels (5)
3 REPLIES 3
Message 2 of 4

Hi @chris.monachanZWSCF .

 

I made a sample that looks like this.
It did indeed crash. (Fusion360 ver2.0.10564)

# Fusion360API Python script
import adsk.core, adsk.fusion, traceback

def run(context):
    ui = adsk.core.UserInterface.cast(None)
    try:
        app: adsk.fusion.Application = adsk.core.Application.get()
        app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)

        ui = app.userInterface
        des: adsk.fusion.Design = app.activeProduct
        root: adsk.fusion.Component = des.rootComponent

        # create Plane
        sktPlane: adsk.fusion.ConstructionPlane = initPlane(
            root,
            [1,2,3],
            [3,2,1],
            [2,3,1],
        )

        # create Plane
        targetPlane: adsk.fusion.ConstructionPlane = initPlane(
            root,
            [5,6,4],
            [7,6,5],
            [4,5,7],
        )

        # create Sketch
        skt: adsk.fusion.Sketch = initSketchCircle(sktPlane, [1,2,0], 1)

        # create ExtrudeFeature
        exts: adsk.fusion.ExtrudeFeatures = root.features.extrudeFeatures
        extIpt: adsk.fusion.ExtrudeFeatureInput = exts.createInput(
            skt.profiles[0],
            adsk.fusion.FeatureOperations.NewBodyFeatureOperation
        )

        TOENTITY = adsk.fusion.ToEntityExtentDefinition
        ent: adsk.fusion.ToEntityExtentDefinition = TOENTITY.create(targetPlane, True)
        extIpt.setOneSideExtent(ent, adsk.fusion.ExtentDirections.PositiveExtentDirection)

        exts.add(extIpt) # <- Crash

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


def initSketchCircle(
    plane: adsk.fusion.ConstructionPlane,
    center: list,
    radius: float) -> adsk.fusion.Sketch:

    comp: adsk.fusion.Component = plane.parent
    skt: adsk.fusion.Sketch = comp.sketches.add(plane)

    circles: adsk.fusion.SketchCircles = skt.sketchCurves.sketchCircles
    circles.addByCenterRadius(
        adsk.core.Point3D.create(center[0],center[1],center[2]),
        radius)
    
    return skt

def initPlane(
    comp: adsk.fusion.Component,
    ary1: list,
    ary2: list,
    ary3: list,
    ) -> adsk.fusion.ConstructionPlane:

    skt: adsk.fusion.Sketch = comp.sketches.add(comp.xYConstructionPlane)
    skt.isLightBulbOn = False

    pnts: adsk.fusion.SketchPoints = skt.sketchPoints
    PNT3D = adsk.core.Point3D
    [pnts.add(PNT3D.create(v[0],v[1],v[2])) for v in [ary1,ary2,ary3]]

    planes: adsk.fusion.ConstructionPlanes = comp.constructionPlanes
    planeIpt: adsk.fusion.ConstructionPlaneInput = planes.createInput()
    planeIpt.setByThreePoints(
        skt.sketchPoints[1],
        skt.sketchPoints[2],
        skt.sketchPoints[3]
    )

    return planes.add(planeIpt)
Message 3 of 4
BrianEkins
in reply to: kandennti

I can also reproduce the problem and a bug has been logged.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 4 of 4

Hey, thanks for putting the time in to construct a repro. I work in C++ and on a complex Fusion Add-In project so it's often difficult for me to pull out individual bits of code.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report