Get Item from ObjectsEnumerator C#

Get Item from ObjectsEnumerator C#

Anonymous
Not applicable
715 Views
3 Replies
Message 1 of 4

Get Item from ObjectsEnumerator C#

Anonymous
Not applicable

Hello.

I am using C# API.

I want to get intersection point from 2 curves.

 

SketchArc arc1 = ...(definition)

SketchLine chkLine1 = ...(definition)

LineSegment2d oLineSegment1 = chkLine1.Geometry;
ObjectsEnumerator objsEnum = oLineSegment1.IntersectWithCurve(arc1.Geometry);

int num1 = objsEnum.Count

 

After executing, I can see 1 line and 1 arc in Inventor.

If I check num1 in debug mode it shows 1 (intersection exists)

But cannot get point information.

From another posting there are some examples in VB like this

 

Set oInterPoint = oLineSegment.IntersectWithCurve(oSketchCircle.Geometry).Item(1)

oInterPoint.x = ...

This is VB so there is ObjectsEnumerator.Item() method.

 

In C# I cannot find method for Item[], or GetItem(), ...

If I can get intersection point coordinates it's OK however...

 

0 Likes
Accepted solutions (2)
716 Views
3 Replies
Replies (3)
Message 2 of 4

JelteDeJong
Mentor
Mentor
Accepted solution

did you try:

oLineSegment.IntersectWithCurve(oSketchCircle.Geometry)[1]

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 4

Anonymous
Not applicable

OK. It works. Thanks.

I need one more question for intersection. CurveCurveIntersection

 

below code is not working now in C#.

Would you give me solution?

 

SketchSpline sp1 = App2DSpline(aryPnt1, oSketch1);
SketchSpline sp2 = App2DSpline(aryPnt2, oSketch1);

BSplineCurve2d spDef1 = sp1.Geometry;
BSplineCurve2d spDef2 = sp2.Geometry;

Point2d intPt = (Point2d)oTransGeom.CurveCurveIntersection(spDef1, spDef2)[1];

double xx1 = intPt.X;
double yy1 = intPt.Y;

0 Likes
Message 4 of 4

Anonymous
Not applicable
Accepted solution

I found solution.

Below code works.

Thank you.

 

SketchSpline sp1 = App2DSpline(aryPnt1, oSketch1);
SketchSpline sp2 = App2DSpline(aryPnt2, oSketch1);

BSplineCurve spDef1 = sp1.Geometry3d;
BSplineCurve spDef2 = sp2.Geometry3d;


Inventor.Point intPt =oTransGeom.CurveCurveIntersection(spDef1, spDef2)[1];

double xx1 = intPt.X;
double yy1 = intPt.Y;