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

create a centerline by two points

Trying to add a centerline to a drawing view but it keeps failing at the centerlines.add method.  All I get is an ambiguous error message.  What am i missing?

 

DrawingDocument oDoc = (DrawingDocument)oInventorApp.ActiveDocument;
Sheet oSheet = oDoc.ActiveSheet;
DrawingView oView = oSheet.DrawingViews[1];
Centerlines oLines = oSheet.Centerlines;

DrawingSketch oSketch = oView.Sketches.Add();
SketchPoints oPoints = oSketch.SketchPoints;
oSketch.Edit();
SketchPoint pnt1 = oPoints.Add(oITransGeo.CreatePoint2d(0, 0), false);
SketchPoint pnt2 = oPoints.Add(oITransGeo.CreatePoint2d(216 * 2.54, 0), false);
oSketch.ExitEdit();

GeometryIntent oInt1 = oSheet.CreateGeometryIntent(pnt1);
GeometryIntent oInt2 = oSheet.CreateGeometryIntent(pnt2);

ObjectCollection oCollection = oInventorApp.TransientObjects.CreateObjectCollection();
oCollection.Add(oInt1);
oCollection.Add(oInt2);

Centerline line = oLines.Add(oCollection);