CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz]
CZ | EN | DE
Login or
registration
  Visitors: 7804

CAD tip CAD tip # 9263:

   
Question CAD 
 %  platform  category 
Q - question

iLogic code for exploding a component pattern in Inventor.

A - answer L.Larsen from Kingsbury, Inc. has sent us a core of an iLogic code for exploding a component pattern (see the Tip 8956).

Here is an extended version of this code which allows to select a pattern in the assembly tree and then makes all its members "independent" in a single step:

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

        Dim oPattern As OccurrencePattern
        oPattern = GetPattern(oDoc)
        If oPattern Is Nothing Then
            MsgBox("Nothing for explode")
            Return
        End If

        Dim t As Transaction = ThisApplication.TransactionManager.StartTransaction(ThisDoc.Document, "Pattern explode")
        Try
            'MAKE EACH ELEMENT INDEPENDENT, STARTING AT THE SECOND ELEMENT.
            Dim i As Integer
            'COUNT HOW MANY ELEMENTS ARE IN THE PATTERN, AFTER 2
            For i = 2 To oPattern.OccurrencePatternElements.Count
                'MAKE ALL ELEMENTS INDEPENDANT
                oPattern.OccurrencePatternElements.Item(i).Independent = True

            Next
            'DELETE THE PATTERN, LEAVING ONLY THE INDEPENDENT COPIES AND THE ORIGINAL ELEMENT
            oPattern.Delete()
            t.End()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
            t.Abort()
        End Try
    End Sub

    Private Function GetPattern(ByVal oDoc As AssemblyDocument) As OccurrencePattern
        Dim pattern As OccurrencePattern
        'pattern = oDoc.ComponentDefinition.OccurrencePatterns.Item("Component Pattern 1:1")
        pattern = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrencePatternFilter, "Select pattern for explode")
        Return pattern
    End Function
Inventor
100% *  CAD 
24.5.2013    12815×  
Prices - CAD eShop:
applies to: Inventor ·

See also:
Tip 12046:Random shape and appearance of an Inventor part or assembly.
Tip 11542:How to reset the top browser node name back to the file name?


Back   All CAD Tips



Have we helped you? If you want to support the CAD Forum web service, consider buying one of our CAD applications, or our custom software development offerings, or donating via PayPal (see above). You may also add a link to your web - like this "fan" link: CAD Forum - tips, utilities, blocks for Autodesk products
CAD:    OS:    Categ: 
Text:  FAQ glossary   



Featuring:
Publish interactive 3D PDF models from AutoCAD, Inventor or Revit with Share3D More info


Please use these tips at your own risk.
Arkance Systems is not responsible for possible problems that may occur as a result of using any of these tips.
TOPlist