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

(Not an Autodesk Employee)