- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Requirement:
I hope someone can outline the python code workflow to set a coincident constraint between the end-point of a line (lineA) and the mid-point of another line (lineB). I'm still new to the Fusion API and have tried everything I could think of with my limited experience.
Problem:
1) I cannot see anywhere in the API that I can acquire a SketchPoint reference to my SketchLine (lineB) mid-point, which led me to believe this may well be the wrong approach anyway.
2) Failed attempt A: I created a Point3D from the calculated mid-point coordinates (mp:Point3D), but the sketch.geometricConstraints.addCoincident() method requires SketchPoint arguments. I tried it anyway, but as expected the following call raised a runtime type error:
sketch.geometricConstraints.add(lineA.endSketchPoint, mp, ,,)
3) Failed attempt B: Like 2, I created a Point3D from the calculated mid-point coordinates and used sp:SketchPoint = sketch.sketchPoints.add(mp:Point3D) to get a SketchPoint instance with the correct coordinates. As assumed, it creates a new unique SketchPoint on the sketch which has no relationship to lineB. So, when I tried the following call it made the new SketchPoint coincident with LineA.endSketchPoint and did not affect lineB:
sketch.geometricConstraints.add(lineA.endSketchPoint, sp, ,,)
Code Snippets:
# Code for (2) above that raised runtime type error
lineA:SketchPoint
lineB:SketchPoint
mp:Point3D = lineMidPoint(lineB) # A method I wrote myself
sketch.geometricConstraints.addCoincident(lineA.endSketchPoint, mp)
# Code for (3) above created the coincident constraint between the 'wrong' sketch entities
lineA:SketchPoint
lineB:SketchPoint
mp:Point3D = lineMidPoint(lineB) # A method I wrote myself
smp:SketchPoint = sketch.sketchPoints.add(mp)
sketch.geometricConstraints.addCoincident(lineA.endSketchPoint, smp)
Solved! Go to Solution.