
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I am into an ilogic to get extents of part and sheet metal from Assembly. I have ended up in a logic in which i can get the part extents from Assembly but the value of Sheet metal extents are different. For this I am running a seperate ilogic to get sheetmetal dimensions. I tried options to combine these two ilogic to run a single rule for an assembly comprising of both part and sheetmetal components.
Can anyone provide a suggestion to combine these two seperate rules together using an If else loop?
I am posting the two rules which I have been using.
For sheetmetal extents:
Sub Main()
'Determines if there is a flat pattern
Dim oDoc As PartDocument
oDoc = ThisDoc.Document
'ensure this part has a flat pattern
Dim oSMDef As SheetMetalComponentDefinition
oSMDef = oDoc.ComponentDefinition
If oSMDef.FlatPattern Is Nothing Then
'Warns the user there is no flat pattern
'MessageBox.Show("This file has no flat pattern", "iLogic")
Else
Extents
End If
End Sub
Sub Extents()
extents_length = SheetMetal.FlatExtentsLength
extents_width = SheetMetal.FlatExtentsWidth
LengthFrac = Round(SheetMetal.FlatExtentsLength, 0)
WidthFrac = Round(SheetMetal.FlatExtentsWidth, 0)
Dim oValue As String
Dim param As Parameter
If extents_width > extents_length Then
oValue = (WidthFrac & " x " & LengthFrac & " x " & Thickness)
iProperties.Value("Custom", "StockSize") = oValue
Else
oValue = (LengthFrac & " x " & WidthFrac & " x " & Thickness)
iProperties.Value("Custom", "StockSize") = oValue
End If
End Sub
In Assembly to get part extents:
Public Sub Main()
' Reading the current assembly.
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
' Reading current assembly component definition.
Dim oAsmDef As AssemblyComponentDefinition
oAsmDef = oAsmDoc.ComponentDefinition
' Reading Child part(leaf occurrences) of the assembly.
Dim oLeafOccs As ComponentOccurrencesEnumerator
oLeafOccs = oAsmDef.Occurrences.AllLeafOccurrences
' Iterate through all part occurrences in assembly.
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)
iProperties.Value(oOcc.Name,"Custom", "Width") = oList.Item(1)
iProperties.Value(oOcc.Name, "Custom", "Thickness") = oList.Item(0)
Smallest = oList.Item(0)
Middle = oList.Item(1)
Largest = oList.Item(2)
iProperties.Value(oOcc.Name, "Custom", "StockSize") = Largest & " x " & Middle & " x " & Smallest & " "
Next
End Sub
Can anyone suggest a way to combine both?
Thanks in advance.
Regards,
Aswin Mathai
Solved! Go to Solution.