Get CoincidentConstraint of line endpoints

Get CoincidentConstraint of line endpoints

commonmandan
Contributor Contributor
1,214 Views
6 Replies
Message 1 of 7

Get CoincidentConstraint of line endpoints

commonmandan
Contributor
Contributor

How do you get the Coincident Constraints for curves that are connected?

 

I drew a rectangle and I'm trying to get the Coincident Constraints for each corner.

 

sketch.geometricConstraints returns the horizontal and vertical constraints

 

for line in sketch.sketchCurves.sketchLines:

line.geometricConstraints returns either a horizontal and vertical constraint, depending on the line.

 

I also tried:

line.startSketchPoint.geometricConstraints

line.endSketchPoint.geometricConstraints

0 Likes
Accepted solutions (1)
1,215 Views
6 Replies
Replies (6)
Message 2 of 7

marshaltu
Autodesk
Autodesk

Hello,

 

There are no coincident constraints in the lines in your case. In fact, the lines which are contiguous just share "Point". When we draw a rectangle, 4 lines and 4 points are created. For example: the end point of line 1 is the start point of line 2. The end point of line 2 is the start point of line 3, and so on. It makes the rectangle can be changed as a whole. 

 

Thanks,

Marshal



Marshal Tu
Fusion Developer
>
0 Likes
Message 3 of 7

commonmandan
Contributor
Contributor

I guess what I'd like to know is how to get the coincident constraints for those shared points and know which objects are constrained together. I'm probably going the opposite direction as everyone else, the sketch already exists and I'm trying to figure out how everything is connected. Given a rectangle drawn in a sketch, I can hover on the corners and see there is a coincident constraint or the lack there of. How can I figure that out through the API, given any sketch? 

0 Likes
Message 4 of 7

marshaltu
Autodesk
Autodesk

Hello,

 

I saw what you were saying(there is a constraint when hover on the corners). It looks be a bug in our API implementation. I will log a defect against the issue in our internal system.

 

Thank you for reporting the issue.

 

Thanks,

Marshal



Marshal Tu
Fusion Developer
>
0 Likes
Message 5 of 7

ekinsb
Alumni
Alumni
Accepted solution

This is actually working as-designed, but I certainly understand your confusion.  I need to add a section to the API User's Guide that discusses how sketches work.  Here are some basics that help to explain what you're seeing.

 

Sketch geometry doesn't just exist on its own.  All sketch geometry is dependent on sketch points.  For a line, there are always two sketch points that define it's start and end position.  If you draw a single line in a sketch, it's somewhat obvious because the two sketch points are clearly displayed. If you drag one of the points, you are moving the point and the line just goes along for the ride.

 

 

 If you draw two lines then it looks a little different.  You only see points at the open ends and not where the lines connect.  However, the sketch UI is doing some things to try and simplify the display.  If you move the mouse over the point where the two lines connect then you'll see the point display and become available for selection or drag.  In this case, there are three points; one point defines the start of line 1, a point defines the end of line 1 and the start of line 2, and the last defines the end of line 2.  The important thing to know here is that the lines share the same sketch point at the connection.

 

 The picture below shows where three lines connect and share the same point and the point has been selected so the Coincident constraint symbols appear.  Where this is misleading is that there really aren't any coincident constraints here.  The thing that's tying these three lines together is the fact that they all depend on the same sketch point.  However, to provide a UI to be able to separate the lines, they chose to represent this as a coincident constraint.  What happens when you select the glyph and do Delete is that a new sketch point is created and one of the lines is modified so that it now depends on this new sketch point so that the two lines no longer share a sketch point.

 

 

 So if you have a give line and want to find what's connected to it you can use the startSketchPoint and endSketchPoint properties to get the points that the line is dependent on.  Other sketch geometry also has similar properties to get the points they depend on.  For example the SketchCircle object supports the centerSketchPoint property.

 

The SketchPoint object supports the connectedEntities property which returns all of the sketch entities that are dependent on that point. For the two line case, this will return the sketch line that you started with and the other sketch line.  Hopefully that gives you what you need.

 

 

 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 6 of 7

marc.a.grossman
Enthusiast
Enthusiast

I've got a related issue. I'm trying to make an offset from a profile that I'm eventually using to do a cut/extrude. The issue I'm having is that I need to pass in an objectCollection into sketch.offset(collection, directionPoint, dist). I'm trying to use findConnectedCurves but it's clearly not working.

 

Here's the relevant section of code:

        toothSketch = sketches.add(body1.faces.item(2))#the top face of the cylinder we extruded above
        lines = toothSketch.sketchCurves.sketchLines
        line1 = lines.addByTwoPoints(pt1, pt2)
        line2 = lines.addByTwoPoints(line1.endSketchPoint, pt3)
        line3 = lines.addByTwoPoints(line2.endSketchPoint, pt4)
        line4 = lines.addByTwoPoints(line3.endSketchPoint, line1.startSketchPoint)
        
        filletRad = 0.003 * in2cm

        # arc = toothSketch.sketchCurves.sketchArcs.addFillet(line1, line1.endSketchPoint.geometry, line2, line2.startSketchPoint.geometry, filletRad)
        # arc = toothSketch.sketchCurves.sketchArcs.addFillet(line2, line2.endSketchPoint.geometry, line3, line3.startSketchPoint.geometry, filletRad)
        # arc = toothSketch.sketchCurves.sketchArcs.addFillet(line3, line3.endSketchPoint.geometry, line4, line4.startSketchPoint.geometry, filletRad)
        # arc = toothSketch.sketchCurves.sketchArcs.addFillet(line4, line4.endSketchPoint.geometry, line1, line1.startSketchPoint.geometry, filletRad)



        curves = sketch.findConnectedCurves(line1)
        
        toothProfile = toothSketch.profiles.item(0)

The issue is that the findConnectedCurves is not finding the 4 lines that are definitely connected since they share start/end points. It is returning a collection with a circle in it and I have no idea why. Any thoughts? As you can see I even tried adding a fillet because I thought that might "connect" them better.

0 Likes
Message 7 of 7

marc.a.grossman
Enthusiast
Enthusiast

I found the issue. I was using sketch.findConnectedCurves() instead of my "sketch" object toothSktech.findConnectedCurves(). 

0 Likes