Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Coincident constrain between (sketch block point/sketch block insertion point) and (grounded/projected point)

taher.basha
Enthusiast

Coincident constrain between (sketch block point/sketch block insertion point) and (grounded/projected point)

taher.basha
Enthusiast
Enthusiast

Hi everyone,

 

I am trying to create coincident constrain between sketch block insertion point and grounded point/center point

I have tried all the ways. One of them is down

 

PartDocument pd = invApp.ActiveDocument as PartDocument;
PartComponentDefinition pcd = pd.ComponentDefinition;
PlanarSketch sk = pcd.Sketches["Sketch1"];
SketchBlock sb = sk.SketchBlocks[1];

SketchPoint pt = sb.Definition.InsertionPoint;

SketchEntity cpt = sk.AddByProjectingEntity(pcd.WorkPoints[1]);

sk.GeometricConstraints.AddCoincident((SketchEntity)pt, cpt);

 

attaching the model. 

 

coincident.PNG

0 Likes
Reply
Accepted solutions (1)
394 Views
1 Reply
Reply (1)

WCrihfield
Mentor
Mentor
Accepted solution

Hi @taher.basha.  Apparently the bottom end of that line is not recognized as the 'insertion point' of that block, because when I opened your part and corrected the code, it constrained the point at the other end of that line to the projected origin point.  The 'InsertionPoint' you were getting from the SketchBlock was in the context of the SketchBlockDefinition, not the main PlanarSketch, so it would not allow you to constrain to it directly.  You need to use a method of the SketchBlock named GetObject(), to get the object that it represents in the context of the main PlanarSketch before you can use it for a constraint.  Here is the code I used.  This code is in iLogic...so vb.net, instead of C#, though.  I hope you can translate it OK.

Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oSk As PlanarSketch = oPDef.Sketches.Item(1)
Dim oSb As SketchBlock = oSk.SketchBlocks.Item(1)
Dim oBInsSpt As SketchPoint = oSb.Definition.InsertionPoint
Dim oInsSpt As SketchPoint = oSb.GetObject(oBInsSpt)
Dim oOrigPt As SketchPoint = oSk.AddByProjectingEntity(oPDef.WorkPoints.Item(1))
oSk.GeometricConstraints.AddCoincident(oInsSpt, oOrigPt)

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)