How to create construction plane perpendicular to a line

How to create construction plane perpendicular to a line

maurizio_manzi
Advocate Advocate
277 Views
2 Replies
Message 1 of 3

How to create construction plane perpendicular to a line

maurizio_manzi
Advocate
Advocate

Hello,
I have a line:

line = sketch.sketchCurves.sketchLines.addByTwoPoints(startPoint, endPoint).
The line is slanted in space.
How can I create a construction plane at the "endPoint", perpendicular to the line?
 
Best regards
Maurizio
0 Likes
Accepted solutions (1)
278 Views
2 Replies
Replies (2)
Message 2 of 3

kandennti
Mentor
Mentor
Accepted solution

Hi @maurizio_manzi -San.

 

How about something like this?

# Fusion360API Python script

import traceback
import adsk.core as core
import adsk.fusion as fusion

def run(context):
    ui: core.UserInterface = None
    try:
        app: core.Application = core.Application.get()
        ui = app.userInterface
        des: fusion.Design = app.activeProduct
        root: fusion.Component = des.rootComponent

        # sketch
        skt: fusion.Sketch = root.sketches.add(root.xYConstructionPlane)

        # points
        stPnt: fusion.SketchPoint = skt.sketchPoints.add(
                core.Point3D.create(1,2,3),
        )

        edPnt: fusion.SketchPoint = skt.sketchPoints.add(
                core.Point3D.create(4,5,6),
        )

        # line
        sktLine: fusion.SketchLine = skt.sketchCurves.sketchLines.addByTwoPoints(
            stPnt,
            edPnt,
        )

        # plane
        planeIpt: fusion.ConstructionPlaneInput = root.constructionPlanes.createInput()
        planeIpt.setByDistanceOnPath(
            sktLine,
            core.ValueInput.createByReal(1),
        )

        plane: fusion.ConstructionPlane = root.constructionPlanes.add(
            planeIpt,
        )

        ui.messageBox("Done")

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
0 Likes
Message 3 of 3

maurizio_manzi
Advocate
Advocate

Thank you very much. It works fine!