How to get intersect point between a line and an assembly using the API

How to get intersect point between a line and an assembly using the API

Anonymous
Not applicable
443 Views
1 Reply
Message 1 of 2

How to get intersect point between a line and an assembly using the API

Anonymous
Not applicable
Hello.

Is there anyway of getting the intersection point between a line and any part of an assembly?
The ideia is to use the eye and target (from camera object) points of the API to draw a line and find the point where the user is looking. That point should be the closest point that the line drowned intersects in the whole assembly.
Don't know if I'm making myself clear enough.

Best regarst.
0 Likes
444 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Ok, so I found the API method FindUsingRay() but I don't know how to get the point from the objectEnumerator because in C# theres no Item property in the objectEnumerator.
I want to get the first 3d coordinate of the point where the view intersects the assembly.
At the moment my code is this:

AssemblyDocument asmDoc = default(AssemblyDocument) ;
asmDoc = (AssemblyDocument) _invApp.ActiveDocument;

AssemblyComponentDefinition oCompDef = default(AssemblyComponentDefinition) ;
oCompDef = (AssemblyComponentDefinition)asmDoc.ComponentDefinition;

Camera cam = _invApp.ActiveView.Camera;
TransientGeometry tg = _invApp.TransientGeometry ;

Inventor.Point Tp = tg.CreatePoint(cam.Target.X, cam. Target.Y, cam.Target.Z);
Inventor.Point Ep = tg.CreatePoint(cam.Eye.X, cam.Eye.Y, cam.Eye.Z);

UnitVector oUVec = Ep. VectorTo(Tp).AsUnitVector();

ObjectsEnumerator objFound = null, pointFound = null;

OCompDef.FindUsingRay(Ep,oUVec,0.001,out objFount, out pointFound, true) ;

//The problem is that in C# the pointFound.Item(0) doesn't work
0 Likes