Sizing problem when performing a coincident constraint

vitor.carneiro
Participant

Sizing problem when performing a coincident constraint

vitor.carneiro
Participant
Participant

Hello,

 

I would like help with the following problem.
I want to include a spline inside a sketch that already contains a line, and make two constraints: the first with the first point of the line and the spline, and the second, between the end point of the line and the middle of the spline.
But I encounter the problem of a line dimension error after the constraints (decreasing its size).
Here's the code and photo of the error found.

 

Note 1: I really need to insert the spline in the sketch, as this is just a test for another application, where it is necessary to perform this operation.

Note 2: I need the line to remain the same 8 cm as it initially has.

 

Thank you very much,
Vitor Urel

0 Likes
Reply
Accepted solutions (1)
312 Views
2 Replies
Replies (2)

kandennti
Mentor
Mentor
Accepted solution

Hi @vitor.carneiro .

 

How about adding a DistanceDimension in advance?

# Fusion360API Python script
import adsk.core, adsk.fusion, traceback

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

        sk = root.sketches.add(root.xYConstructionPlane)
        sk1 = root.sketches.add(root.xYConstructionPlane)

        points = adsk.core.ObjectCollection.create()
        pnts = [
            [0,0,0],
            [5,1,0],
            [6,4,0],
            [7,6,0],
            [2,3,0],
            [0,1,0],
            ]
        Pnt3D = adsk.core.Point3D
        for p in pnts:
            points.add(Pnt3D.create(p[0],p[1],p[2]))

        spline = sk1.sketchCurves.sketchFittedSplines.add(points)

        spline1 = sk.include(spline)
        spline2 = spline1.item(0)

        line = sk.sketchCurves.sketchLines.addByTwoPoints(
            Pnt3D.create(0,0,0),
            Pnt3D.create(8,0,0)
        )

        # DistanceDimension
        sk.sketchDimensions.addDistanceDimension(
            line.startSketchPoint,
            line.endSketchPoint,
            adsk.fusion.DimensionOrientations.AlignedDimensionOrientation,
            Pnt3D.create(4,1,0))

        sk.geometricConstraints.addCoincident(
            line.startSketchPoint,
            spline2.startSketchPoint
        )

        sk.geometricConstraints.addCoincident(
            line.endSketchPoint,
            spline2
        )

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

1.png

 

0 Likes

BrianEkins
Mentor
Mentor

If you want the line to remain exactly where it was before adding the coincident constraints, I think the best solution is to fix both endpoints of the line.  You can do that with something like this:

line.startSketchPoint.isFixed = True
line.endSketchPoint.isFixed = True
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
1 Like