iLogic component move to new/existing subassembly?

iLogic component move to new/existing subassembly?

rob
Advocate Advocate
427 Views
2 Replies
Message 1 of 3

iLogic component move to new/existing subassembly?

rob
Advocate
Advocate

Objective is a simplified model for small file size and easy appearance manipulation after export to DWG, RFA, etc.

 

Top assembly may contain 100 parts, 80 of which are steel and receive common finish/appearance, remaining 20 parts are timber and receive common finish/appearance.  I would like to join all the steel components even as one body, and all the timber components as one body.

 

Top assembly is currently built by iLogic placement to specific coordinate locations, ground/fixed.  One conceived workflow is to demote all the steel components to a subassembly and shrinkwrap it; this presumably results in a multibody part with more features than necessary, but at least would be treated as one component.  Likewise for the timber.

 

Happy to consider other workflows; but if not: can components be demoted via iLogic to an existing or new subassembly?  How?

IV Pro 2020.2
0 Likes
428 Views
2 Replies
Replies (2)
Message 2 of 3

Ralf_Krieg
Advisor
Advisor

Hello

 

Don't know if this workflow is optimal, but demoting is possible. There's an VBA example in the API help, you can adapt.

 

Public Sub Demote()
    ' Get the active assembly document
    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument

    Dim oDef As AssemblyComponentDefinition
    Set oDef = oDoc.ComponentDefinition

    ' Get the occurrence to be demoted
    Dim oOcc As ComponentOccurrence
    Set oOcc = oDef.Occurrences.Item(1)

    ' Create a new sub-assembly to demote the occurrence into
    Dim oNewSubAssy As AssemblyDocument
    Set oNewSubAssy = ThisApplication.Documents.Add(kAssemblyDocumentObject, , False)

    Dim oMat As Matrix
    Set oMat = ThisApplication.TransientGeometry.CreateMatrix

    ' Create an instance of the new sub-assembly
    Dim oSubAssyOcc As ComponentOccurrence
    Set oSubAssyOcc = oDef.Occurrences.AddByComponentDefinition(oNewSubAssy.ComponentDefinition, oMat)

    ' Get the model browser
    Dim oPane As BrowserPane
    Set oPane = oDoc.BrowserPanes.Item("Model")

    ' Get the browser node that corresponds to the new sub-assembly occurrence
    Dim oSubAssyNode As BrowserNode
    Set oSubAssyNode = oPane.GetBrowserNodeFromObject(oSubAssyOcc)

    ' Get the last visible child node under the sub-assembly occurrence
    Dim oTargetNode As BrowserNode
    Dim i As Long
    For i = oSubAssyNode.BrowserNodes.Count To 1 Step -1
        If oSubAssyNode.BrowserNodes.Item(i).Visible Then
            Set oTargetNode = oSubAssyNode.BrowserNodes.Item(i)
            Exit For
        End If
    Next

    ' Get the browser node that corresponds to the occurrence to be demoted
    Dim oSourceNode As BrowserNode
    Set oSourceNode = oPane.GetBrowserNodeFromObject(oOcc)

    ' Demote the occurrence
    Call oPane.Reorder(oTargetNode, False, oSourceNode)
End Sub

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 3

rob
Advocate
Advocate

Thanks, will have a go at it with that and update status.

IV Pro 2020.2
0 Likes