CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor and other Autodesk products [www.cadforum.cz]
Cesky English Deutsch
Login/Register:
 Visitors: 2207 

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    3443x  
Comments   Tell a friend
applies to: Inventor ·

See also:


Back   All CAD Tips All CAD tips&tricks

RENAME on steroids - complex renaming of AutoCAD objects. « | » How to borrow a network license in 3ds Max Design?

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:
Increase your productivity with our set of BIM add-on functions for Autodesk Revit
CADstudio Revit Tools More info


Please use these tips at your own risk.
CAD Studio (Xanadu) is not responsible for possible problems that may occur as a result of using any of these tips.
TOPlist