Intersect faces with a line (transform problem?)

Intersect faces with a line (transform problem?)

MGO-Norsyn
Advocate Advocate
1,337 Views
1 Reply
Message 1 of 2

Intersect faces with a line (transform problem?)

MGO-Norsyn
Advocate
Advocate

Hi

 

I am creating a piece of code which takes a blind flange (pipe fitting) as input and tries to get a point on the opposite face of the face on which the connector is situated. The pipe fitting has one connector and a single extrusion as a body (the method must work on any geometry). I am creating a line with origin at the connector point and then trying to intersect it with the solid's faces. The goal is to get the point directly opposite the connector on the extrusion.

 

I wrote the following code:

 primaryConnector = null;
 foreach (Connector connector in connectorSet) primaryConnector = connector;
 //Connector information extraction
 XYZ endPointOriginFlangeBlind = primaryConnector.Origin;
 //Extraction of the direction of the connector and reversing it
 XYZ reverseConnectorVector = primaryConnector.CoordinateSystem.BasisZ.Multiply(-1);
 Line detectorLine = Line.CreateUnbound(endPointOriginFlangeBlind, reverseConnectorVector);
 //Begin geometry analysis
 GeometryElement geometryElement = familyInstance.get_Geometry(options);
 
 foreach (GeometryObject geometry in geometryElement)
 {
    GeometryInstance instance = geometry as GeometryInstance;
    if (null != instance)
    {
	foreach (GeometryObject instObj in instance.SymbolGeometry)
        {
            Solid solid = instObj as Solid;
            if (null == solid || 0 == solid.Faces.Size || 0 == solid.Edges.Size)
            {
                continue;
            }

	    // Get the faces
            foreach (Face face in solid.Faces)
            {
                SetComparisonResult intersectionPoint = face.Intersect(detectorLine);
                sbFittings.Append(intersectionPoint.ToString());
            }
        }
    }
}

The intersection results all come out as Disjoint.

 

My current prime suspect is incorrect handling of transform of the geometry ie. I think that I look at faces in a different transform as the line is created in.

 

Please help getting the line to intersect with the faces. Thank you.

0 Likes
Accepted solutions (1)
1,338 Views
1 Reply
Reply (1)
Message 2 of 2

MGO-Norsyn
Advocate
Advocate
Accepted solution

The problem was here:

 

foreach (GeometryObject instObj in instance.SymbolGeometry)

Needs to be:

 

foreach (GeometryObject instObj in instance.GetInstanceGeometry())

 

0 Likes