Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.
Hi, all,
Inventor has a Box Object which is a mathematical utility object that represents a rectangular box whose faces are always parallel to the model X Y Z planes. Right now we are using its method such as "Box.contains(...)" for the purpose to identifying whether a part or component is within this box or not, for further processing.
But in many cases, we need some NON-rectangular boxes such as below.
So is it possible to define a mathematical boxes (such as adding or deducting some shaped boxes together) like these and use the mathematical "contains" method?
Hi @liminma8458,
This sounds like a tough one. Are you using the RangeBox of a ComponentOccurrence or just making a box and trying to find whats in it? Without knowing why the box needs to be non-rectangular or other details, my first thought is to think of this problem as finding a point in a polygon. The non-rectangular box would be the polygon and the point would be a point on the part. Below is a link that has C# code to find a 3D point in a 3D polygon.
https://www.codeproject.com/Articles/1070593/Point-Inside-D-Convex-Polygon-in-Csharp
And maybe if you provided a little more information on why the box needs to be non-rectangular, someone could come up with some work around that doesn't require a non-rectangular box? Hope this helps!
You may be able to use this technique, but I haven't tried using it with a TransientGeometry object. It would likely work for them too.
In the example, I'm using a the coordinates of a WorkPoint's Point object, as the input within the 'IsPointInside' Property. But you can just delete the Dim oPoint line and replace the oPoint.X etc with simple Double (numerical) values, if you want. It works the same either way. Getting the kOnContainment answer is a bit odd though. Not entirely sure how this is calculated.
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oBodies As SurfaceBodies = oPDef.SurfaceBodies
Dim oBody As SurfaceBody = oBodies.Item(1)
Dim oPoint As Point = oPDef.WorkPoints.Item(1).Point
Dim oCoords(2) As Double 'Use (2) for 3 doubles, because 0 is counted
oCoords(0) = oPoint.X
oCoords(1) = oPoint.Y
oCoords(2) = oPoint.Z
Dim oContEnum As ContainmentEnum = oBody.IsPointInside(oCoords,False)
Select Case oContEnum
Case ContainmentEnum.kInsideContainment
MsgBox("It is Inside the body.")
Case ContainmentEnum.kOnContainment
MsgBox("It is On the body.")
Case ContainmentEnum.kOutsideContainment
MsgBox("It is Outside the body.")
Case ContainmentEnum.kUnknownContainment
MsgBox("Its location is Unknown in relation to the body.")
End Select
I hope this helps.
If this solves your problem, or answers your questions, please click 'Accept As Solution".
Or, if this helps you reach your goal, please click 'LIKES" 👍.
Also, if you're interested, here are a few of the 'Ideas' I'd like to get implemented.
If you agree with any of them, please vote for them.
Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum
Wesley Crihfield
(Not an Autodesk Employee)
You can create several kinds of TransientGeometry objects that have volume, if you don't want to use visible geometry.
Some of the options are:
Box,OrientedBox,Cone,ElipticalCone,Cylinder,ElipticalCylinder,Torus, & Sphere
Wesley Crihfield
(Not an Autodesk Employee)
I know the API have Box,OrientedBox,Cone,ElipticalCone,Cylinder,ElipticalCylinder,Torus, & Sphere. But we need a mathematical TransientGeometry like a triangle body and a domed shape body such as below. And we don't need it visible, only for mathematically containing purpose.
Can't find what you're looking for? Ask the community or share your knowledge.