Using API, change centerlines to sketchlines

Using API, change centerlines to sketchlines

Anonymous
Not applicable
808 Views
2 Replies
Message 1 of 3

Using API, change centerlines to sketchlines

Anonymous
Not applicable

Hi everyone,

 

キャプチャ.PNG

 

I have created these all sketch lines using Inventor API.

oLines  = oSketch1.SketchLines.AddByTwoPoints(oTransGeom.CreatePoint2d(startpointX,startpointY), oTransGeom.CreatePoint2d(endPointX,endPointY));

 

Now I want change  the line (circled in red color) in centerlines. And this is how I have done:

 

ObjectCollection oFitPoints = mInventorApp.TransientObjects.CreateObjectCollection();
Point2d oPoint1 = oTransGeom.CreatePoint2d(3, 5);

oFitPoints.Add(oPoint1);

 

Point2d oPoint2 = oTransGeom.CreatePoint2d(4, 0);

oFitPoints.Add(oPoint2);

 

Centerlines oCenterLines = default(Centerlines);
oCenterLines.Add(oFitPoints, ObjectTypeEnum.kLinearGeneralDimensionObject, LineTypeEnum.kLongDashDottedLineType, false);

 

Since the centerlines couldn’t be add in the sketch lines I got the null exception error.

So, how do I change centerlines into sketch lines so that I could draw it using API.

 

Suggest me please.

 

With regards,

Prarthana

 

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

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi 15985329236,

 

Here's a quick example of toggling a line to/from a centerline type.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

' Get the first item in the select set.  
'This assumes a line is selected 
Dim oSketchEnt As SketchEntity
Try
oSketchEnt = ThisApplication.ActiveDocument.SelectSet.Item(1)
Catch
MessageBox.Show("Select a line, and only a line.", "iLogic")
Return
End Try

Dim oLine As SketchLine
oLine = oSketchEnt

' Toggle the centerline property.
If oLine.Centerline Then
	oLine.Centerline = False
Else
	oLine.Centerline = True
End If

EESignature

Message 3 of 3

Anonymous
Not applicable

Thank you very much. 🙂

Act. I had opened the forum to post the same answer which I did it by myself in the same way

and saw your post 🙂

 

Thank you for your help.

 

 

 

0 Likes