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

10 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

Phenom
Phenom

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

Phenom
Phenom

@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? 

Re: Get Collision curves by C# API

Pioneer
Pioneer

Hi FredCastro !

 

For this code:

collisionParams.Mode = TxCollisionQueryParams.TxCollisionQueryMode.DefinedPairs;

 I have tested the other collisionParams.Mode :

collisionParams.Mode = TxCollisionQueryParams.TxCollisionQueryMode.All;

It seems that there is no difference between them when the code runs,do you know how they make a difference to collision set ?

Re: Get Collision curves by C# API

Phenom
Phenom

Hello @Remond

 

When you use "defined pairs", only checked collision sets will be considered in collision analysis. When you use "all", all objects in current study will be considered in collision analysis (it is the same as the "All displayed objects" flag in collision viewer, as shown below):

 

2018-10-18 10_59_45-Process Simulate on eMServer 14.1 - [555-10450-401].jpg

 

You probably got the same results because both analysis are resulting in same colliding objects.

 

Regards!