coincident sketch constraint

coincident sketch constraint

Anonymous
Not applicable
858 Views
2 Replies
Message 1 of 3

coincident sketch constraint

Anonymous
Not applicable

Hi, I have the below code to add coincident constraints between the start point of two sketch lines and a center point of a projected circle. I use the two lines to create a section view. The code works for the first coincident constraint, but when it tries to do the second one I get this: "Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))". Why does it fail?

 

'Draws the first section line
		oSectionLine = oSectionSketch.SketchLines.AddByTwoPoints(
			oTG.CreatePoint2d(Point1.X,Point1.Y),
			oTG.CreatePoint2d(Point2.X,Point2.Y))
		
		'Draws the second section line
		oSectionLine2 = oSectionSketch.SketchLines.AddByTwoPoints(
			oTG.CreatePoint2d(Point1.X,Point1.Y),
			oTG.CreatePoint2d(Point3.X,Point3.Y))
			
		'Adds coincident constraints.		
		oSectionSketch.GeometricConstraints.AddCoincident(
			oCircularEntity.CenterSketchPoint,
			oSectionLine.StartSketchPoint)		
			
		oSectionSketch.GeometricConstraints.AddCoincident(
			oSectionLine2.StartSketchPoint,
			oCircularEntity.CenterSketchPoint)	

1.PNG

0 Likes
Accepted solutions (1)
859 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

This is really weird.. If I do it like the code abode then the code creates the constraints, but I get the above error message..I try to move the sketch lines, and they are constrained even tho I get error message..

 

When I simply put it into a Try, Catch, End Try config it works, but it is sketchy because something is obviosuly wrong, but I cant figure it out..!

0 Likes
Message 3 of 3

dg2405
Advocate
Advocate
Accepted solution

For two lines you have to use the "Merge" method instead of usinge the "AddCoincident".

Call oSectionLine.StartSketchPoint.Merge(oSectionLine2.StartSketchPoint)