Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Find the intersection of two surfaces?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
cpicke
1323 Views, 2 Replies

Find the intersection of two surfaces?

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?

2 REPLIES 2
Message 2 of 3
Vladimir.Ananyev
in reply to: cpicke

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.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
cpicke
in reply to: Vladimir.Ananyev

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report