How to get the Planar Sketch's data like Line Dimension (Starting and Ending point) | Inventor API

How to get the Planar Sketch's data like Line Dimension (Starting and Ending point) | Inventor API

hariharanhZXJ8L
Contributor Contributor
774 Views
6 Replies
Message 1 of 7

How to get the Planar Sketch's data like Line Dimension (Starting and Ending point) | Inventor API

hariharanhZXJ8L
Contributor
Contributor

I need to get the line dimension inside the PlanarSketch(2D Sketch) of a part file.

 

Can someone help me to resolve my query ?

 

Thanks

HARI

0 Likes
Accepted solutions (1)
775 Views
6 Replies
Replies (6)
Message 2 of 7

A.Acheson
Mentor
Mentor

Here is a sample that might be of help. If you need further assistant can you please post the code your using and images of what help you require. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 7

hariharanhZXJ8L
Contributor
Contributor

Thanks for your reply,

 

Actually I need to recreate the sketch that i have already with Inventor and then i need to modify dimensions on that with the recreated file.

Data I need is the exact location(x,y), center point, reference contstains and dimension of sketch entity.

 do you have any idea ?

0 Likes
Message 4 of 7

Dev_rim
Advocate
Advocate

Hi,

If you want only take data from sketch lines, you can reach the data from PlanarSketch.SketchLines

Every SketchLine object contains Geometry and Geometry3d properties. If you need 2 dimension coordinates of the line you can use Geometry object, and the good news is this object is a LineSegment2d object.So you can directly reach the data about StartPoint, MinPoint, Endpoint and direction. 

devrimyoyen_0-1660808983102.png

So for example you can reach the start point of the "sketch" entity like :

 

Point2d startPoint = sketch.SketchLines[LINE_ID].Geometry.StartPoint;

 

 

Also you can use these way for other sketch entities. Then the code will like this,

 

Point2d startPoint = sketch.SketchEntities[ENTITY_ID].Geometry.StartPoint;

 

 

Also in every Planarsketch object there are properties named 

DimensionConstraints

and

GeometricConstraints

 

You can find every dimension and constraint from here.

 

For the origin point of the sketch there is an another property named OriginPointGeometry in PlanarSketch object.

If it is not the thing you want you can find the plane object of your sketch and get it's root point.

Point is on PlanarSketch.PlanarEntityGeometry.RootPoint

 

If you want to edit all of this information you have to create same type objects and fill them into the new sketch you created. 

 

I hope this will help.

 

Devrim.

If my answer is solved your problem, please mark it as Solution

Freundliche Grüße / Kind Regards
0 Likes
Message 5 of 7

hariharanhZXJ8L
Contributor
Contributor

Hello,

 

Thanks for your message, It solve my requirement 50% and Thank you very much for that.

I  need to get the Constrains data of each Entity.

eg: Line1 and Line2 are in perpendicular Constrain.

hariharanhZXJ8L_0-1660810246985.png

 

do you have any idea ? 

 

Thanks

HARI

0 Likes
Message 6 of 7

Dev_rim
Advocate
Advocate
Accepted solution

For every type of entity in the sketch you can reach the constraints with Constraints property.

 

SketchConstraintsEnumerator constraints = sketch.SketchEntities[ENTITY_ID].Constraints;

 

And inside of object looks like this:

devrimyoyen_0-1660810810872.png

Red marked item is a Planar Sketch

Blue Marked one is a Sketch Entity

and the Blue line and the black marked one is a Constraint Object. You can reach different kind of constraints from there.

If you want to know entities of constrain , for example this is a ParallelConstraint:

devrimyoyen_1-1660811034658.png

You can easily see EntityOne and EntityTwo are SketchLines. You can reach these objects directly like:

SketchLine entity1 = sketch.SketchEntities[ENTITY_ID].Constraints[ID].EntityOne;
SketchLine entity2 = sketch.SketchEntities[ENTITY_ID].Constraints[ID].EntityTwo;

 

If you want to reach them directly from the sketch object:

SketchLine entity1 = sketch.GeometricConstraints[ID].EntityOne;
SketchLine entity2 = sketch.GeometricConstraints[ID].EntityTwo;

 

PlanarSketch.GeometricConstraints will return all geometric constraints in the whole sketch!

 

I hope this will be %100 percent Solution 🙂

 

Devrim,

 

If my answer is solved your problem, please mark it as Solution

Freundliche Grüße / Kind Regards
Message 7 of 7

hariharanhZXJ8L
Contributor
Contributor

Great ! Thanks !