Creating A Construction Plane at a Specific Point Along Path in Python

Creating A Construction Plane at a Specific Point Along Path in Python

grant.n.deljevic
Community Visitor Community Visitor
767 Views
2 Replies
Message 1 of 3

Creating A Construction Plane at a Specific Point Along Path in Python

grant.n.deljevic
Community Visitor
Community Visitor

I'm trying to create a construction plane along a 3d path at specific points with the python API. The way I'm currently trying is to create a construction plane at these points, and then use the Point3D.asVector as a tangent for the construction plane. The issue I'm having is that the ConstructionPlaneInput.setByTangent method requires a "BRepFace" type object, which I see no way to get from a spline path and point.

If anyone knows how I'd go about creating a construction plane that way, any help would be appreciated. 

0 Likes
768 Views
2 Replies
Replies (2)
Message 2 of 3

dieselguy65
Collaborator
Collaborator

My understanding.  A construction plane is a flat surface. 

Not really sure a construction plane is what your are looking for here. 

Can you post up the work?

0 Likes
Message 3 of 3

BrianEkins
Mentor
Mentor

I'm not 100% sure this is what you want, but here's some code that will create 3 construction planes along a path in a sketch where their offset value is defined as a distance from the start of the path.

def planeAlongPath():
    try:
        app = adsk.core.Application.get()
        ui: adsk.core.UserInterface = app.userInterface
        des: adsk.fusion.Design = app.activeProduct
        root = des.rootComponent

        sk = root.sketches.itemByName('Sketch2')
        line = sk.sketchCurves.sketchLines[0]

        path = adsk.fusion.Path.create(line, adsk.fusion.ChainedCurveOptions.connectedChainedCurves)
        
        # Assume you want to create planes positioned 2 cm, 5 cm, and 10 cm along the path.

        # Determine the length of the path to use in computing the proportional value.
        length = 0
        for pathEnt in path:
            curve: adsk.fusion.SketchCurve = pathEnt.entity
            length += curve.length

        # Create a construction plane at 2 cm, 5 cm, and 10 cm along the path.
        # Distances are always in cm in the Fusion API. If you want inches you
        # would do a conversion from inches to centimeters and pass in that
        # value. For example for 2 inches: (2/2.54)/length 
        offsets = [2 / length , 5 / length, 10 / length]
        for offset in offsets:
            planeInput = root.constructionPlanes.createInput()
            planeInput.setByDistanceOnPath(path, adsk.core.ValueInput.createByReal(offset))
            pl = root.constructionPlanes.add(planeInput)
            pl.name = f"Plane offset {offset * length}"
    except:
        ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes