Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

About Box Object in API

4 REPLIES 4
Reply
Message 1 of 5
liminma8458
590 Views, 4 Replies

About Box Object in API

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?

Capture1.PNG   Capture2.PNG

Thanks
Limin
Inventor pro 2023 64 bit update 2.1; Windows 10 pro 64 bit version 21H2; Office 2013 32 bit
4 REPLIES 4
Message 2 of 5
ianteneth
in reply to: liminma8458

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!

Message 3 of 5
WCrihfield
in reply to: ianteneth

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.

  • Add more capabilities to the 'Customize' dialog box (exe. Add Tab & Add Panel) Click Here
  • MessageBox, InputBox, and InputListBox Size & Format Options Click Here
  • Constrain & Dimension Images In Assembly Sketches & Drawing Sketches (TitleBlocks & SketchedSymbols) Click Here
  • Save Section View Status In DesignViewRepresentation (So It Can Be Used In The Drawing) Click Here
  • Add SolidBodies Folder In iLogic Rule Editor Model Tab Click Here
  • Convert All Views To Raster Before Autosave Stores To 'OldVersions' Folder Click Here
  • SetDesignViewRepresentation - Fix limitations for DrawingView of a Part Click Here
  • Create DocumentSubTypeEnum Click Here

Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 5
WCrihfield
in reply to: WCrihfield

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

EESignature

(Not an Autodesk Employee)

Message 5 of 5
liminma8458
in reply to: WCrihfield

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.

 Capture_1.PNG  Capture_2.PNG Capture_3.PNG

Thanks
Limin
Inventor pro 2023 64 bit update 2.1; Windows 10 pro 64 bit version 21H2; Office 2013 32 bit

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report