Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
I am looking for some advise on how to get rid of constraints that are visible in the UI but can not be retrieved via API.
The starting point is something like this. A spline which is cut by a line.
Afterwards overlaps are trimmed.
Which creates the following constraints.
Having those constraints hinders to properly fillet the edge points. Without those constrains everything works as expected. I am not able to find or retrieve the coincident constraints. sketch.geometricConstraints returns no results.
Here is my sample code
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
app = adsk.core.Application.get()
ui = app.userInterface
design = adsk.fusion.Design.cast(app.activeProduct)
if not design:
ui.messageBox('No active Fusion 360 design', 'No Design')
return
try:
# Get the root component of the active design.
rootComp = design.rootComponent
# Cleanup, delete all existing sketches
sketches = rootComp.sketches
while sketches.count > 0:
sketches.item(0).deleteMe()
# Cleanup, delete all construction planes.
cnstrionPlanes = rootComp.constructionPlanes
while cnstrionPlanes.count > 0:
cnstrionPlanes.item(0).deleteMe()
sketches = rootComp.sketches
xyPlane = rootComp.xYConstructionPlane
cnstrionPlanes = rootComp.constructionPlanes
cnstrionPlaneInput = cnstrionPlanes.createInput()
cnstrionPlaneInput.setByOffset(xyPlane, adsk.core.ValueInput.createByReal(1))
xyCnstrionPlane = cnstrionPlanes.add(cnstrionPlaneInput)
# Create a new sketch on the yz construction plane.
sketch: adsk.fusion.Sketch = sketches.add(xyCnstrionPlane)
sketch.name = 'Segment '
lines = sketch.sketchCurves.sketchLines
# Create an object collection for a spline.
pointsss = adsk.core.ObjectCollection.create()
pointsss.add(adsk.core.Point3D.create(5,3,0))
pointsss.add(adsk.core.Point3D.create(7,5,0))
pointsss.add(adsk.core.Point3D.create(9,3,0))
# Create the spline.
spline2 = sketch.sketchCurves.sketchFittedSplines.add(pointsss)
# Create line which cuts spline
line = lines.addByTwoPoints(adsk.core.Point3D.create(4,4,0), adsk.core.Point3D.create(10,4,0))
# Delete part of line which is within the spline
line.trim(adsk.core.Point3D.create(7,4,0), True)
# Get newly created lines
linePart1 = lines.item(lines.count - 1)
linePart2 = lines.item(lines.count - 2)
# Get the spline and trim everything below line
spline = sketch.sketchCurves.item(sketch.sketchCurves.count-1)
spline2.trim(adsk.core.Point3D.create(5,3,0), True)
spline = sketch.sketchCurves.item(sketch.sketchCurves.count-1)
spline.trim(adsk.core.Point3D.create(9,3,0), True)
spline = sketch.sketchCurves.item(sketch.sketchCurves.count-1)
# I CANNOT FIND ANY COINCIDENT CONSTRAINT EITHER IN SPLINE NOR IN LINEPARTS
# Delete all constraints available
sketch.geometricConstraints.item(0).deleteMe()
sketch.geometricConstraints.item(0).deleteMe()
sketch.geometricConstraints.item(0).deleteMe()
print(str(spline.startSketchPoint.geometry.x) + " " + str(spline.startSketchPoint.geometry.y) + " " + str(spline.startSketchPoint.geometry.z))
print(str(spline.endSketchPoint.geometry.x) + " " + str(spline.endSketchPoint.geometry.y) + " " + str(spline.endSketchPoint.geometry.z))
print(str(linePart1.startSketchPoint.geometry.x) + " " + str(linePart1.startSketchPoint.geometry.y) + " " + str(linePart1.startSketchPoint.geometry.z))
print(str(linePart1.endSketchPoint.geometry.x) + " " + str(linePart1.endSketchPoint.geometry.y) + " " + str(linePart1.endSketchPoint.geometry.z))
print(str(linePart2.startSketchPoint.geometry.x) + " " + str(linePart2.startSketchPoint.geometry.y) + " " + str(linePart2.startSketchPoint.geometry.z))
print(str(linePart2.endSketchPoint.geometry.x) + " " + str(linePart2.endSketchPoint.geometry.y) + " " + str(linePart2.endSketchPoint.geometry.z))
sketch.sketchCurves.sketchArcs.addFillet(spline, spline.startSketchPoint.geometry, linePart2, linePart2.endSketchPoint.geometry, .6)
sketch.sketchCurves.sketchArcs.addFillet(spline, spline.endSketchPoint.geometry, linePart1, linePart2.startSketchPoint.geometry, .6)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Thank you very much 🙂
Solved! Go to Solution.