I am using API with Inventor Professional 2012. I wish to intersect one surface with another, and then to analyze the resulting curve by stepping along it parametrically, but I am having trouble getting the curve in the first place. So my question here is with regards to intersecting a surface with another surface. For sake of argument, let us suppose that I am intersecting a regular plane with a tapered cylinder, and that I have made certain that the two entities do not miss one another. Then I would expect one or two curves as output (this is like generating conic sections).
Here are the two functions that I have tried:
1) plane.IntersectWithSurface(oSurface);
2) oTG.SurfaceSurfaceIntersection(oSurface,oPlane);
My code snippet is roughly as follows (in c sharp, sorry):
ObjectsEnumerator out1;
ObjectsEnumerator out2;
Inventor.Point planePoint = oTG.CreatePoint(0,0,0);
Inventor.Vector planeNormal = oTG.CreateVector(-Math.Sin(theta), -Math.Cos(theta), 0)
Inventor.Plane plane = oTG.CreatePlane(planePoint,planeNormal);
Object oSurface = face.get_Surface(face.SurfaceType) as Object;
out1 = plane.IntersectWithSurface(oSurface);
for (i = 0; i < out1.Count; i++)
{
// this function never returns anything!
}
Inventor.Object oPlane = plane as Inventor.Object;
out2 = oTG.SurfaceSurfaceIntersection(oSurface,oPlane);
for (i = 0; i < out2.Count; i++)
{
// this function returns the correct number of entities but
// I do not know how to typecast them! E.g., something like this:
// drawingCurve = out2[i] as Inventor.DrawingCurve;
}
Has anybody here ever used either function with success? I wonder if you could post some simple examples involving these functions to help me?
Solved! Go to Solution.
Solved by Vladimir.Ananyev. Go to Solution.
Namespace Microsoft.VisualBasic allows to define returned COM object types.
ObjectsEnumerator out2; out2 = oTG.SurfaceSurfaceIntersection( oFace.Geometry, oPlane, 0.01); for (int i = 1; i <= out2.Count; i++) { Object obj = out2[i]; //get object from collection //find out COM object type name string st = Microsoft.VisualBasic.Information.TypeName(obj); Console.WriteLine(st); // e.g. EllipseFull }
Hope this could help you.
This worked, thanks!
Interestingly, the types tend to be Line, Circle or BSplineCurve for the mostpart. I tested it by rotating a shape comprising in part of an ellipse, then intersected it by a regular plane in which the axis of rotation was entirely contained, so that the intersection would have yielded the original ellipse. The function returned a BSplineCurve.