- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I did research on Geometric Constraints.AddCoincident in the form, but I couldn't find a solution to my problem.
- I select a part in assembly.
- I choose two planes ( A and B Plane )that are perpendicular to each other from selected part.
- I create a point using AddByProjectingEntity on A plane and I create a line on B plane.
I want to carry the line to the point where I created it. For this I use GeometricConstraints.AddCoincident. But the line didn't join with the point, as I did in Inventor.
Thanks in advance.
My Code:
private void AddCoincident()
{
Inventor.Application application = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application");
AssemblyDocument oAsmDoc = (AssemblyDocument)application.ActiveDocument;
TransientGeometry oTG = application.TransientGeometry;
ComponentOccurrence componentOccurrence = application.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select a Part");
PartComponentDefinition oCompDef = (PartComponentDefinition)componentOccurrence.Definition;
WorkPlane Face1 = (WorkPlane)application.CommandManager.Pick(SelectionFilterEnum.kWorkPlaneFilter, "Select Face1");
PlanarSketch sktch = oCompDef.Sketches.Add(Face1, true);
SketchPoint oSketchCenterPoint = (SketchPoint)sktch.AddByProjectingEntity(oCompDef.WorkPoints["Center Point"]);
//double Cons = oSketchCenterPoint.Geometry3d.X;
WorkPlane Face2 = (WorkPlane)application.CommandManager.Pick(SelectionFilterEnum.kWorkPlaneFilter, "Select Face2");
PlanarSketch sktch1 = oCompDef.Sketches.Add(Face2, true);
Point2d P1 = oTG.CreatePoint2d(0, 0);
Point2d P2 = oTG.CreatePoint2d(5, 0);
SketchLine line = sktch1.SketchLines.AddByTwoPoints(P1, P2);
//pipe.EndSketchPoint.Merge(oSketchCenterPoint1);
sktch1.Edit();
sktch1.GeometricConstraints.AddCoincident(line.StartSketchPoint as SketchEntity, oSketchCenterPoint as SketchEntity);
}
Solved! Go to Solution.