Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all, I’m trying to create a construction plane in a Component (COMP2).
I would like to create it starting from two lines that belong to two sketches that have been created in another component COMP1.
I receveid this error :
The construction is possible from the user interface:
So I think that there is some mistake in my code.
Thank you for the help.
Dino
Here is my code:
import adsk.core, adsk.fusion, traceback def run(context): try: app = adsk.core.Application.get() ui = app.userInterface product = app.activeProduct design = adsk.fusion.Design.cast(product) # define root component rootComp = design.rootComponent # create new components: COMP1 COMP2 transform = adsk.core.Matrix3D.create() occ1 = rootComp.occurrences.addNewComponent(transform) comp1 = occ1.component comp1.name = "COMP1" occ2 = rootComp.occurrences.addNewComponent(transform) comp2 = occ2.component comp2.name = "COMP2" # create two line on COMP1 # Create a new sketch on the xy plane on COMP1 sketches = comp1.sketches; xyPlane = rootComp.xYConstructionPlane sketch1 = sketches.add(xyPlane) xzPlane = rootComp.xZConstructionPlane sketch2 = sketches.add(xzPlane) # Draw two lines on COMP1 lines1 = sketch1.sketchCurves.sketchLines lines2 = sketch2.sketchCurves.sketchLines line1 = lines1.addByTwoPoints(adsk.core.Point3D.create(0, 0, 0), adsk.core.Point3D.create(3, 0, 3)) line2 = lines2.addByTwoPoints(adsk.core.Point3D.create(0, 0, 0), adsk.core.Point3D.create(0, 0, 3)) # plane collection on the COMP2 planes2 = comp2.constructionPlanes # Create construction plane input planeInput2 = planes2.createInput() # Add construction plane by two edges planeInput2.setByTwoEdges(line1, line2) plane = planes2.add(planeInput2) plane.name = "PLANE-COMP2" except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.