Cancel
Showing results for 
Search instead for 
Did you mean: 

Get Collision curves by C# API

Creator
Creator

Hello Experts,

 

Is it possible to get collsion results (collision curve) by C# API?

 

if Yes, Please share the details.

 

Thanks in advance.

 

Thanks,

Ravi

7 REPLIES

Re: Get Collision curves by C# API

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi Ravi,

 

Do you mean the collision contour that is generated when you press Show/Hide Colliding Contour?

 

Best Regards,

DianaG

Re: Get Collision curves by C# API

Creator
Creator

Hello Diana,

 

Yes, I am interested to get collision contour that is generated when you press Show/Hide Colliding Contour.

 

Thanks,

Ravi

Re: Get Collision curves by C# API

Legend
Legend

Hello @Ravi104484

 

Check the code below and see if it is what you need. It will display all collision contours in graphics viewer. 

 

            TxCollisionQueryParams collisionParams = new TxCollisionQueryParams();
            collisionParams.StopQueryAfterFirstCollision = false;
            collisionParams.Mode = TxCollisionQueryParams.TxCollisionQueryMode.DefinedPairs;
            collisionParams.ReportLevel = TxCollisionQueryParams.TxCollisionReportLevel.LowestLevel;
            collisionParams.FindPenetrationRegions = true;
            TxCollisionQueryResults collisionResults = TxApplication.ActiveDocument.CollisionRoot.GetCollidingObjects(collisionParams);
            ArrayList collisionStates = collisionResults.States;

            foreach (TxCollisionState state in collisionStates)
            {
                TxPenetrationRegion[] penetrationRegionVector = state.PenetrationRegions;

                foreach (TxPenetrationRegion penetrationRegion in penetrationRegionVector)
                {
                    TxManipulatorCreationData manipData = new TxManipulatorCreationData("manipulator", new TxTransformation());
                    TxManipulator manip = TxApplication.ActiveDocument.PhysicalRoot.CreateCollisionContour(manipData);

                    TxVector[] intersectionCurveVector = penetrationRegion.IntersectionCurve;
                    ArrayList intersectionCurveList = new ArrayList(intersectionCurveVector);
                    TxManipulatorPolylineElementData polyData = new TxManipulatorPolylineElementData(new TxTransformation(), intersectionCurveList);
                    manip.AddElement(polyData);
                }
                
            }

            TxApplication.RefreshDisplay();

Regards

Re: Get Collision curves by C# API

Siemens Phenom Siemens Phenom
Siemens Phenom

Hello Ravi,

 

FredCastro gave you the right example. You can also play with the properties of TxManipulatorPolylineElementData and change its color, state, pickability, etc.

 

Thank you @FredCastro

 

Best Regards,

DianaG

Re: Get Collision curves by C# API

Creator
Creator

Hello FredCastro,

 

Thanks a lot for your help and inputs.

 

Thanks,

Ravi

Re: Get Collision curves by C# API

Creator
Creator

Hello Diana,

 

Thanks a lot for your help and inputs.

 

Thanks,

Ravi

Re: Get Collision curves by C# API

Legend
Legend

@Ravi104484

 

Nice to know it helped you!

 

@DianaG

 

You're welcome! I'm actually thinking in an API to estimate a volume based on the collected points from the collision contour. It doesn't need to be a 3D solid, I just want to get a volume value and compare with a threshold. 

 

Do you have any suggestions on that?