Part minimum dimensions, iproperties

Part minimum dimensions, iproperties

Anonymous
Not applicable
1,404 Views
9 Replies
Message 1 of 10

Part minimum dimensions, iproperties

Anonymous
Not applicable

I have used multibody design to create a simple frame structure. All frame members are turned into individual parts with the make components command. The make components command creates every part with a template that contains the following Rule to create custom iproperties for dimensions (length, width, height) and volume:

 

iProperties.Value("Custom", "XLength")=Round(Measure.ExtentsLength,3)
iProperties.Value("Custom", "XWidth")=Round(Measure.ExtentsWidth,3)
iProperties.Value("Custom", "XHeight")=Round(Measure.ExtentsHeight,3)
iProperties.Value("Custom", "XMass")=Round(iProperties.Mass,2)
iProperties.Value("Custom", "Dimensions")=CStr(Round(Measure.ExtentsLength,2))+" X "+CStr(Round(Measure.ExtentsWidth,2))+" X "+CStr(Round(Measure.ExtentsHeight,2))
iProperties.Value("Custom", "GrossVolume")=CStr(Round(Measure.ExtentsLength)*Round(Measure.ExtentsWidth)*Round(Measure.ExtentsHeight)/1000^3)

 

This works perfect as long as the component is correctly aligned. But if not the dimensions are not the minium dimensions like in the screenshot (199,194 x 30) but just extensions in x,y,z directions (183,559x77,357). Is there any possibility to get inventor to always find the minimum dimensions or align the component with its longest side to an axis?

0 Likes
1,405 Views
9 Replies
Replies (9)
Message 2 of 10

mcgyvr
Consultant
Consultant

@Anonymous wrote:

 

 

This works perfect as long as the component is correctly aligned. But if not the dimensions are not the minium dimensions like in the screenshot (199,194 x 30) but just extensions in x,y,z directions (183,559x77,357). Is there any possibility to get inventor to always find the minimum dimensions or align the component with its longest side to an axis?


Couldn't you just compare the values before you assign them to rank them how you want?

If Xlength > Ylength

Then

,etc....



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 3 of 10

Curtis_Waguespack
Consultant
Consultant

Hi @Anonymous, 
See the iLogic example at this link:

https://forums.autodesk.com/t5/inventor-forum/separate-multibody-part-inside-assembly/m-p/7171674#M648526

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

 

 

EESignature

Message 4 of 10

Anonymous
Not applicable

Hey guys, thank you for the fast answers.

Curtis your code works great and with the rule at assembly level I do not have to use a rule in every part file anymore. 

However I have one problem with this. When I use demote to seperate parts into subassemblies from the main assembly the rule does not go down into these subassemblies. Any idea to modify this?

 

0 Likes
Message 5 of 10

Anonymous
Not applicable

I was checking again but this does not seem to be the solution to the problem as the "dimensions box" is still drawn in x, y and z direction. If the part is not aligned right to theses axis I do not get the minimum dimensions. See the example attached with Curtis code. The right dimensions would be:

 

Lenght: 1500

Width: 303,8

Thickness: 4

 

but I get:

 

Length: 1500

Width: 281,5

Thickness: 121,6

 

So it does not give usefull results for Bill of Material / Cutting lists.

I wonder that these minimum dimensions do not exist as basic predefined variables in Inventor as everybody who uses cutting lists needs them.

0 Likes
Message 6 of 10

Curtis_Waguespack
Consultant
Consultant

Hi @Anonymous, 

 

Previously, I missed he part of your question about the the part extents needing to be aligned with the part.  I'm not sure I have a solution for that, but you might search and/or post to the Inventor Customization forum asking about that.

http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120


As for how to "hit" the part when it is demoted in a subassembly, you can use AllLeafOccurences as in this example.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim oDoc As Document
oDoc =  ThisApplication.ActiveDocument

Dim oAcompdef As ComponentDefinition
oAcompdef = oDoc.ComponentDefinition

'conversion factor cm To In
oCF = 0.393701

Dim oOcc As ComponentOccurrence
For Each oOcc In oAcompdef.Occurrences.AllLeafOccurrences
	
	oX = (oOcc.definition.RangeBox.MaxPoint.X _
		- oOcc.definition.RangeBox.MinPoint.X)*oCF
	oY = (oOcc.definition.RangeBox.MaxPoint.Y _
		- oOcc.definition.RangeBox.MinPoint.Y)*oCF
	oZ = (oOcc.definition.RangeBox.MaxPoint.Z _
		- oOcc.definition.RangeBox.MinPoint.Z)*oCF
	
	'[ get middle number
	If oX > oY And oX < oZ Or oX > oZ And oX < oY Then 	
		oMiddle = oX
		Goto Set_Width
	End If 
	
	If oY > oX And oY < oZ Or oY > oZ And oY < oX Then 
		oMiddle = oY
		Goto Set_Width
	End If 
	
	If oZ > oX And oZ < oY Or oZ > oY And oZ < oX Then 
		oMiddle = oZ
		Goto Set_Width
	End If 
	']

	Set_Width:
	iProperties.Value(oOcc.Name, "Custom", "Width") _
	= Round(oMiddle,3)

	'set length
	iProperties.Value(oOcc.Name, "Custom", "Length") _
	= Round(MaxOfMany(oX, oY, oZ),3)

	'set Thickness
	iProperties.Value(oOcc.Name, "Custom", "Thickness") _
	= Round(MinOfMany(oX, oY, oZ),3)
	
Next oOcc

EESignature

Message 7 of 10

OliverTilbury
Enthusiast
Enthusiast

Dear @Curtis_Waguespack,

 

sorry, I know this is an old thread but I am just getting your ilogic code to work (thank you very much for that), but just have two questions...

 

Question 1) 

 

I changed this bit...

'conversion factor cm To In
oCF = 0.393701

to this

 


'conversion factor cm To mm
oCF = 10

So that I get mm in the part list not cm

The native units of all my parts and assemblies is mm though.

So why do you think ilogic defaults the values cm?

 

i.e. until I do the x 10 conversion 18mm thickness is entered in the component iProperty as 1.8

 

 

Question 2)

Simple when you know I guess but how can I remove the trailing zeros in the generated numbers?

 

 

Thank you very much and kind regards,

 

 

Oliver

0 Likes
Message 8 of 10

Curtis_Waguespack
Consultant
Consultant

Hi @OliverTilbury,

 

Inventor's internal units is always centimeters, regardless of the document's linear units setting, so we need to use a conversion factor, or use the documents Units Of Measure.

 

This simple example does some math internally to the code, but coverts it using the document's Units of Measure. So while 6+4 = 10cm, it will return 3.937 in when in an inch based part or 100 when in a mm based part, etc.

 

'do math internally
'internal units are always cm's
oValue = 6 + 4

Dim oUOM = ThisDoc.Document.UnitsOfMeasure

'get the doucument's unit string
oUnitString = oUOM.GetStringFromType(oUOM.LengthUnits)

'use the document's unit of measure to covert the value
oValue = oUOM.GetStringFromValue(oValue, oUnitString)

'show user
MessageBox.Show(oValue, "iLogic")

 

Formattiing output to remove trailing zeros can be done a number of ways, I think the Val function provides a clean way to do this.... but you might test this a bit to make sure I'm not telling you wrong.

 

'do math internally
'internal units are always cm's
Dim dValue As Double
dValue = 6 + 4.01

Dim oUOM = ThisDoc.Document.UnitsOfMeasure

'get the doucument's unit string
oUnitString = oUOM.GetStringFromType(oUOM.LengthUnits)

'use the document's unit of measure to covert the value
sValue = oUOM.GetStringFromValue(dValue, oUnitString)

'get numerical value from string
'trims tailing zeros ( I think)
sValue = Val(sValue)

'show user
MessageBox.Show(sValue , "iLogic")

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

Message 9 of 10

OliverTilbury
Enthusiast
Enthusiast

Hi @Curtis_Waguespack,

 

Thank you for this.

 

That makes sense now re Inventors using cm as it's internal units.

 

I have few issues / questions though. Thank you:

 

1) I added in the code you suggest to convert the units and while it appears to now correctly produce mm values (as that is my document units), I get an error message and not sure what is causing this (FYI: I removed the piece of code that did the conversion to replace it with your new code). 

 

2) The trailing zero code appears not to work (i.e. still show trailing zeros). 

 

 

3) And finally - sorry 😕 - I get one strange thing happening (please see attached a 'tester' assembly with an assortment of odd parts to put the code though its paces! 🙂 ) - where by a part (called 'Leg test') which is a sort of square club shape and with dims L.800 x W.80 x T. 80 is producing results L.800 x W.250 x T. 80. If I make the size L.800 x W.80 x T.120 it then produces the correct values in the iProperties. Weird. I even made another similar 'leg' part and it does exactly the same thing. Yet another part I have ('Tricky test piece-3') which has the same Width and Thickens extents dim does work. 

 

Are you able to suggest why this might be?

 

4) General question: This is my first foray into ilogic (forced as I want to get this cut-list functionality out of Inventor!). But can you recommend any good resources to learn the basics? Even somewehre that is a good Index where is can look up functions (is that the right term) like 'Dim', 'oValue' etc.

 

And - silly question possibly - are 'macros' a different and separate thing to 'iLogic' in Inventor or is 'macro' just used occasionally to refer to ilogic?

 

 

Thank you VERY much and kind regards,

 

 

Oliver

 

 

0 Likes
Message 10 of 10

OliverTilbury
Enthusiast
Enthusiast

I have found the right combination of settings in the Parts List Format Column dialog to remove the trailing zeros.

 

Just thought I'd share.

 

Thanks

Remove trailing zeros.JPG