
Not applicable
11-23-2018
02:26 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm just learning Fusion 360's API and writing one of my first scripts.
In my script I created a new sketch on the zx plane and added 3 points to this sketch in 3d space.
It then creates a new plane using the 3 points and adds a new sketch on the new plane.
It then draws 3 lines on the new sketch.
When I run the script and then make "My New Plane" visible I expect to see the 3 lines align with plane, however they are perpendicular to the plane.
Here is my code:
import adsk.core, adsk.fusion, traceback def run(context): ui = None try: app = adsk.core.Application.get() ui = app.userInterface # Create a document. doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType) product = app.activeProduct design = adsk.fusion.Design.cast(product) # Get the root component of the active design rootComp = design.rootComponent # Create sketch on the xz construction plane sketches = rootComp.sketches sketch = sketches.add(rootComp.xZConstructionPlane) # Create 3 points position1 = adsk.core.Point3D.create(0, 0, 0) point1 = sketch.sketchPoints.add(position1) position2 = adsk.core.Point3D.create(0, 1, 2) point2 = sketch.sketchPoints.add(position2) position3 = adsk.core.Point3D.create(0, -1, 2) point3 = sketch.sketchPoints.add(position3) # Create construction plane input planeInput = rootComp.constructionPlanes.createInput() # Add construction plane by three points planeInput.setByThreePoints(point1, point2, point3) newPlane = rootComp.constructionPlanes.add(planeInput) newPlane.name = 'My New Plane' # Create new sketch on new plane newSketch = sketches.add(newPlane) newSketch.name = 'My New Sketch' # Draw 3 lines on new sketch newLine1 = newSketch.sketchCurves.sketchLines.addByTwoPoints(position1, position2) newLine2 = newSketch.sketchCurves.sketchLines.addByTwoPoints(position2, position3) newLine3 = newSketch.sketchCurves.sketchLines.addByTwoPoints(position3, position1) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
What am I doing wrong?
Can anyone explain why newLine1, newLine2 and newLine3 are not on newPlane?
Or what I need to do differently to make sure they do appear on newPlane?
Solved! Go to Solution.