SurfaceSurfaceIntersection with two cylinders returns null

SurfaceSurfaceIntersection with two cylinders returns null

eric.mathews7BV6E
Contributor Contributor
1,156 Views
7 Replies
Message 1 of 8

SurfaceSurfaceIntersection with two cylinders returns null

eric.mathews7BV6E
Contributor
Contributor

I'm trying to find the intersection between two cylinders using the "SurfaceSurfaceIntersection" transient geometry tool. The help file is a little lacking. I have to assume the cylinder object starts at the "BasePoint" and extends forever in the specified "Direction". I don't know if this is true or not. However; I've played around with the input objects, changing the direction of the cylinder, and it always returns null, regardless of the inputs. What am I doing wrong?

 

This png file illustrates the two cylinders. The opening cylinder is the hole on the right side of the rolled or casing cylinder. They intersect in the model.

 

Thanks.

 

TransientGeometry _tg = Inventor.Application.TransientGeometry;

// Set a reference to the opening cylinder axis.
// This is a 30° line extending to the right.
LineSegment _openingAxis = _tg.CreateLineSegment(_tg.CreatePoint(0, 0, 0), _tg.CreatePoint(59.392058, 34.29, 0));

// Set a reference to the opening cylinder.
Cylinder _openingCylinder = _tg.CreateCylinder(_openingAxis.StartPoint, _openingAxis.Direction, 2.12 / 2);

// Set a reference to the case cylinder. 
// I've tried 1 and -1 for the Z-Axis value.
 Cylinder _caseCylinder = _tg.CreateCylinder(_tg.CreatePoint(0, 0,0), _tg.CreateUnitVector(0, 0, -1), 37 / 2);

// Set a reference to the intersection object. This always returns null.
ObjectsEnumerator _objects = _tg.SurfaceSurfaceIntersection(_openingCylinder, _caseCylinder);

 

 

 

 

0 Likes
Accepted solutions (1)
1,157 Views
7 Replies
Replies (7)
Message 2 of 8

WCrihfield
Mentor
Mentor

hi @eric.mathews7BV6E.  This might possibly just be a case of accuracy.  For instance, the Double data type can hold values all the way out to around 15 places to the right of the decimal point.  If the values are not an exact match, then it may not be finding the intersection.  Also, in your last line of code, where it is using the TransientGeometry.SurfaceSurfaceIntersection method, try specifying a tolerance as the third input, such as "0.01" (without the quotes).

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 8

eric.mathews7BV6E
Contributor
Contributor

I appreciate the response. I've tried all kinds of craziness including a tolerance up to 0.1. Evidently, the surface intersection function is bugged when a cylinder is involved. I've tested it against a plane object and it returns null as well, but two plane objects return an intersection.

        static void _geometricObjectsTest()
        {
            TransientGeometry _tg = _inventor.Application.TransientGeometry;

            // Set a reference to the opening cylinder axis.
            // This is a 30° line extending to the right.
            // I've used Z-Axis values ranging from 10000 to -10000 and the CurveSurfaceIntersection function always works.
            LineSegment _openingAxis = _tg.CreateLineSegment(_tg.CreatePoint(0, 0, 0), _tg.CreatePoint(59.392058, 34.29, 0));

            Circle _circle = _tg.CreateCircle(_tg.CreatePoint(0, 0, 0), _tg.CreateUnitVector(0, 0, -1), 37 / 2);

            ObjectsEnumerator _objects = _tg.CurveCurveIntersection(_openingAxis, _circle);

            foreach (object _item in _objects)
            { Point _p = (Point)_item; }

            // Set a reference to the opening cylinder.
            Cylinder _openingCylinder = _tg.CreateCylinder(_openingAxis.StartPoint, _openingAxis.Direction, 2.12 / 2);

            // Set a reference to the case cylinder. 
            // I've tried 1 and -1 for the Z-Axis value.
            Cylinder _caseCylinder = _tg.CreateCylinder(_tg.CreatePoint(0, 0, 0), _tg.CreateUnitVector(0, 0, -1), 37 / 2);

            Plane _p1 = _tg.CreatePlane(_tg.CreatePoint(0, 0, 0), _tg.CreateVector(0, 1, 0));
            Plane _p2 = _tg.CreatePlane(_tg.CreatePoint(0, 0, 0), _tg.CreateVector(1, 0, 0));

            // Returns null.
            //ObjectsEnumerator _surfaceObjects = _tg.SurfaceSurfaceIntersection(_openingCylinder, _caseCylinder);

            // Returns null.
            // ObjectsEnumerator _surfaceObjects = _tg.SurfaceSurfaceIntersection(_openingCylinder, _p2);

            // Works!
            ObjectsEnumerator _surfaceObjects = _tg.SurfaceSurfaceIntersection(_p1, _p2);

            foreach (object _item in _surfaceObjects)
            { Point _p = (Point)_item; }

            ObjectsEnumerator _curveObjects = _tg.CurveSurfaceIntersection(_openingAxis, _caseCylinder);

            foreach (object _item in _curveObjects)
            { Point _p = (Point)_item; }
        }

 

0 Likes
Message 4 of 8

WCrihfield
Mentor
Mentor

Hi @eric.mathews7BV6E.  Just as a test on my end, I started a new, empty part document.  Then created two separate 2D sketches on the same origin WorkPlane, containing just one circle each, with the second circle overlapping the first circle a bit.  Then I extruded each circle separately, as a surface (instead of solid), at same height and direction.  Then I typed up this iLogic rule to try this method on those two cylinder faces.

WCrihfield_0-1712154554006.png

Dim oPDoc As PartDocument = ThisDoc.Document
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oWSurfaces As WorkSurfaces = oPDef.WorkSurfaces
Dim oWS1 As WorkSurface = oWSurfaces.Item(1)
Dim oWS2 As WorkSurface = oWSurfaces.Item(2)
Dim oCyl1 As Inventor.Cylinder = oWS1.SurfaceBodies.Item(1).Faces.Item(1).Geometry
Dim oCyl2 As Inventor.Cylinder = oWS2.SurfaceBodies.Item(1).Faces.Item(1).Geometry
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oObjsEnum As ObjectsEnumerator = Nothing
Try
	oObjsEnum = oTG.SurfaceSurfaceIntersection(oCyl1, oCyl2, 0.01)
Catch e As Exception
	Logger.Error(e.Message & vbCrLf & e.StackTrace)
End Try
If oObjsEnum IsNot Nothing AndAlso oObjsEnum.Count > 0 Then
	For Each oObj In oObjsEnum
		Logger.Info("TypeName(oObj) = " & TypeName(oObj))
	Next 'oObj
End If

...and when I ran it, I got the following results in the iLogic Log window.  This just proves that this method will work on two cylinder objects that have parallel axis, and their outer surfaces intersect each other in Inventor 2024.0.1.  I have not tested if the two cylinders were perpendicular axis to each other yet.

INFO| 9: >>---------------------------
INFO|TypeName(oObj) = Line
INFO|TypeName(oObj) = Line

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 8

WCrihfield
Mentor
Mentor

Follow-up...

I just modified those two original WorkSurfaces so that one is perpendicular to the other, and both cylinder surfaces completely intersect with each other (not just partially).

WCrihfield_0-1712155480248.png

Then I ran the same exact iLogic rule on them, and got the following result.

INFO| 10: >>---------------------------
INFO|TypeName(oObj) = BSplineCurve
INFO|TypeName(oObj) = BSplineCurve

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 8

WCrihfield
Mentor
Mentor

If I change them so that one cylinder is concentric to the other, but one is smaller than the other, there will not be any intersection.  This seems like what may have been going on in your first code here, because it looked like the second cylinder was being defined along the same axis, but with a different radius, as the first cylinder.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 8

eric.mathews7BV6E
Contributor
Contributor
Accepted solution
Okay, apparently, the cylinders must be created from geometry in a model for the SurfaceSurfaceIntersection function to work properly. And pure mathmatical cylinders created by the transient geometry aren't acceptable arguments for that function.
0 Likes
Message 8 of 8

WCrihfield
Mentor
Mentor

Oddly enough, I am getting the same results as you, when both Cylinder objects are created using the TransientGeometry.CreateCylinder method.  I must have tried around 40 or more permutations of point locations, UnitVector variations, and radius variations, and kept getting no intersections.  This does not seem right, since it says that Cylinder objects are one of the types allowed as input, and Cylinder objects themselves are 'transient' mathematical objects, and the Cylinder object does not appear to have any 'length' (along its axis), and only direction (always just 1 unit in length).  This may be a bug in that method, not sure.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)