Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a code below,
however the ending iProperties need to be set to precision 0, and no units, leading or trailing zeros, however I believe I may need to interject a custom parameters first, and let the iProp equal these.
Let
Run code to get L W T
L= Custom Para L
W= Custom Para W
T= Custom Para T
Set Precision on Custom Para L W T
Custom iProp Length = Custom Para L
Custom iProp Width = Custom Para W
Custom iProp Thickness = Custom Para T
Imports system.Collections
Public Sub Main()
' Get the active assembly.
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
' Get the assembly component definition.
Dim oAsmDef As AssemblyComponentDefinition
oAsmDef = oAsmDoc.ComponentDefinition
' Get all of the leaf occurrences of the assembly.
Dim oLeafOccs As ComponentOccurrencesEnumerator
oLeafOccs = oAsmDef.Occurrences.AllLeafOccurrences
' Iterate through all part occurrences in assembly.
Dim oOcc As ComponentOccurrence
For Each oOcc In oLeafOccs
L = Math.Abs(oOcc.RangeBox.MaxPoint.X - oOcc.RangeBox.MinPoint.X) * 10
W = Math.Abs(oOcc.RangeBox.MaxPoint.Y - oOcc.RangeBox.MinPoint.Y) * 10
H = Math.Abs(oOcc.RangeBox.MaxPoint.Z - oOcc.RangeBox.MinPoint.Z) * 10
Dim oList As New ArrayList
oList.Add(L)
oList.Add(W)
oList.Add(H)
Call oList.Sort()
iProperties.Value(oOcc.Name,"Custom", "Length") = oList.Item(2)& " mm"
iProperties.Value(oOcc.Name,"Custom", "Width") = oList.Item(1)& " mm"
iProperties.Value(oOcc.Name, "Custom", "Thickness") = oList.Item(0) & " mm"
Next
End Sub
Solved! Go to Solution.