Extract Plate Dimensions from Part

Extract Plate Dimensions from Part

joris.engelbertink
Enthusiast Enthusiast
1,475 Views
8 Replies
Message 1 of 9

Extract Plate Dimensions from Part

joris.engelbertink
Enthusiast
Enthusiast

Hi All,

 

I would like to extract the Plate Dimensions from a Part file with iLogic, but I sometimes get faulty results when working with Multibody Parts that are "Made Components" to an Assembly. The orientation can be rotated to the x-, y- and z-planes and ExtentsLength, ExtentsWidth and ExtentsHeight do not give me the right results.

 

Does someone has the iLogic experience to get proper results in this workflow?  

 

Thanks in advance!

 

Grt, Joris

0 Likes
Accepted solutions (1)
1,476 Views
8 Replies
Replies (8)
Message 2 of 9

dutt.thakar
Collaborator
Collaborator

@joris.engelbertink 

There are multiple ways of doing it, it depends on what you are trying to achieve, I have two things for you. You can create the Parameters Length, Width, and Height for the plate in the main part and use them after doing make components in the derived part by linking them. See the below snap for details.

 

Second way if you want to use iLogic Measure functions only. I would advise you to create planes and use them for Measuring, give appropriate names to planes like for Length  "LengthPlane1" and "LengthPlane2" and use it in the Measure.MinimumDistance Snippet. You will have to include the Planes also after using make components in a similar way like parameters.

 

MeasureLog.PNG

 

This will give you always correct dimensions even if your plate is rotated at any orientation.

 

Hope this will be helpful.

 

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes
Message 3 of 9

WCrihfield
Mentor
Mentor

Here are a couple of links to another idea that may peak your interests, that you may be able to use.

SurfaceBody.OrientedMinimumRangeBox Property 

OrientedBox Object 

And here is an example which uses this property:

https://help.autodesk.com/view/INVNTOR/2021/ENU/?caas=caas/discussion/t5/Inventor-Customization/Crea...

 

You can get the length of each of the three vectors of the OrientedMinimumRangeBox, as your size dimensions.

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.

If you have time, please... Vote For My IDEAS 💡and Explore My CONTRIBUTIONS

Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 9

WCrihfield
Mentor
Mentor

@joris.engelbertink 

Here is a better example, more suited to your request.

The following iLogic rule (local or external) works for Part files only (as is).  It assumes the part only has one body (but can be set up do loop through all bodies), gets the first solid body, then gets its OrientedMinimumRangeBox, then gets its data, then extracts the lengths of its three vectors as the overall size of the body.  Then it displays a simple MsgBox showing you the result.  I used math to convert the database default units from Centimeters to Inches.

Here's the code:

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject Then
	MsgBox("This rule only works for Part Documents.",vbOKOnly, "WRONG DOCUMENT TYPE")
	Exit Sub
End If
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oBody As SurfaceBody
If oPDef.SurfaceBodies.Count > 0 Then
	oBody = oPDef.SurfaceBodies.Item(1)
Else
	MsgBox("This Part has no bodies. Exiting.", , "")
	Exit Sub
End If

If Not oBody.IsSolid Then
	MsgBox("The body is not Solid. Exiting.", , "")
	Exit Sub
End If

Dim oCorner As Point
Dim oV1, oV2, oV3 As Vector
oBody.OrientedMinimumRangeBox.GetOrientedBoxData(oCorner, oV1, oV2, oV3)
Dim oDim1 As Double = oV1.Length / 2.54
Dim oDim2 As Double = oV2.Length / 2.54
Dim oDim3 As Double = oV3.Length / 2.54

MsgBox("First Body Size:  " & oDim1 & " x " & oDim2 & " x " & oDim3,,"")

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 9

WCrihfield
Mentor
Mentor

@joris.engelbertink 

And this version takes it one step further, filtering the resulting vector lengths from smallest to largest, so you may more accurately name each dimension, in case that is important or applies to your application.

In many cases the smallest dimension is always going to be the Thickness of the material (especially when working with "Plates").  And often the longest of the three dimensions is the Length (or material cut-length).  So the remaining dimension can either be labeled as Width, Height, Depth, Gerth, etc.

So here is the same code that takes it that next step further, in case you needed it.

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject Then
	MsgBox("This rule only works for Part Documents.",vbOKOnly, "WRONG DOCUMENT TYPE")
	Exit Sub
End If
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oBody As SurfaceBody
If oPDef.SurfaceBodies.Count > 0 Then
	oBody = oPDef.SurfaceBodies.Item(1)
Else
	MsgBox("This Part has no bodies. Exiting.", , "")
	Exit Sub
End If

If Not oBody.IsSolid Then
	MsgBox("The body is not Solid. Exiting.", , "")
	Exit Sub
End If

Dim oCorner As Point
Dim oV1, oV2, oV3 As Vector
oBody.OrientedMinimumRangeBox.GetOrientedBoxData(oCorner, oV1, oV2, oV3)
Dim oDim1 As Double = oV1.Length / 2.54
Dim oDim2 As Double = oV2.Length / 2.54
Dim oDim3 As Double = oV3.Length / 2.54

Dim oThickness As Double = MinOfMany(oDim1, oDim2, oDim3)
Dim oLength As Double = MaxOfMany(oDim1, oDim2, oDim3)
Dim oWidth As Double
Dim oDims() As Double = {oDim1, oDim2, oDim3}
For Each oDim In oDims
	If oDim <> oThickness And oDim <> oLength Then
		oWidth = oDim
	End If
Next

MsgBox("First Body Size:  " & vbCrLf & _
"Thickness = " & oThickness & vbCrLf & _
"Length = " & oLength & vbCrLf & _
"Width = " & oWidth, , "")

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 9

joris.engelbertink
Enthusiast
Enthusiast

Hi,

 

Thats an interesting approach, although I get an error message:

 

"Public member 'OrientedMinimumRangeBox' on type 'SurfaceBody' not found."

 

Any ideas?

 

Thanks

 

Joris

0 Likes
Message 7 of 9

WCrihfield
Mentor
Mentor
Accepted solution

Ah. The help page for that Property of that object (SurfaceBody.OrientedMinimumRangeBox Property ), says it was introduced in the 2021 version.  Seems to me that it has been available one or two releases earlier than that though.  This may be why it isn't working for you.  If you're using an earlier version of Inventor, this may not be available to you yet.

If your parts were always rectangular and aligned with the origin planes, you could probably just use the regular RangeBox similarly to how I've used the OrientedMinimumRangeBox, if that's not the situation you may have to use a different method.  If you parts were still rectangular, but just not oriented with the origin planes, and you are using a version later than maybe 2018 or so, you may be able to assign names to the faces of your model, then use the NameEntities interface to get those specific faces within the code, instead of creating a bunch of planes.

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 8 of 9

joris.engelbertink
Enthusiast
Enthusiast

 

 

0 Likes
Message 9 of 9

Jusdoo
Contributor
Contributor

I have developed an app "iChords - Plate Formatter"  for Inventor in Autodesk App Store which links the length, the width and the thickness to the user length, width  and thickness parameters which can be shown in BOM. Hope it can save you some time. 

 

iChords - Plate Formatter 

0 Likes