Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Ilogic Code to Show Dimensions of an Assembly

el_jefe_de_steak
Collaborator

Ilogic Code to Show Dimensions of an Assembly

el_jefe_de_steak
Collaborator
Collaborator

I would like to see the maximum dimensions of an assembly. How can I do this with iLogic?

0 Likes
Reply
Accepted solutions (2)
911 Views
3 Replies
Replies (3)

el_jefe_de_steak
Collaborator
Collaborator

Here is the code I found on another forum post that will do this for you.

 

Dim dims(0 To 2) As Decimal
dims(0) = Measure.ExtentsLength
dims(1) = Measure.ExtentsHeight
dims(2) = Measure.ExtentsWidth

MessageBox.Show("Complete" & vbLf & "Length: " & dims(0).ToString & vbLf & "Width: " & dims(1).ToString & vbLf & "Height: " & dims(2).ToString, "Get Size")
0 Likes

machiel.veldkamp
Collaborator
Collaborator
Accepted solution

Hi,

 

Try this:

 

Public Sub Main()
	Dim oDoc As AssemblyDocument
	oDoc = ThisApplication.ActiveDocument

	Dim i As Integer	'Use i as a counter.
	Dim param As Parameter

	Dim CurrentValue As Double
	Dim BigValue As Double = 0
	Dim ParamName As String
	
	' loop through all parameters 
	For Each param In oDoc.ComponentDefinition.Parameters
		CurrentValue = param.Value
		If CurrentValue > BigValue
			BigValue = CurrentValue
			ParamName = param.Name
		End If
		
	Next
	MessageBox.Show(ParamName & " is the biggest parameter with a value of: " & BigValue * 10 & "mm", "Test123") 'I do BigValue * 10 to convert from cm to mm. 


End Sub

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

___________________________
0 Likes

el_jefe_de_steak
Collaborator
Collaborator
Accepted solution

The question is meant to be in regards to the overall lengths of an assembly. Sorry for not clarifying that...

 

I think it's a little cleaner and less code to just show the maximum of an array than to use an if loop to find the largest value. However, this approach does not work in some instances.

 

 

Dim dimensionArray(0 To 2) As Decimal
dimensionArray(0) = Measure.ExtentsLength
dimensionArray(1) = Measure.ExtentsHeight
dimensionArray(2) = Measure.ExtentsWidth

MessageBox.Show("The maxiumum size of this assembly is: " & dimensionArray.Max.ToString & " in")