Saturday, December 24, 2011

Autodesk Inventor iLogic Code to List Names of Drawing Views

Autodesk Inventor "iLogic Rule file” to list the view names in a Autodesk Inventor drawing.
I was revising a drawing & wanted to add a new view to the drawing with a view name.

Instead of looking at all the sheets & list the names of existing views to chose the unique name for new view.
I write this illogic which will list all the existing view names in my drawing (It does sorting as well) & make it easier to name my new view.

Here is the procedure to use the illogic rule

1)      Download ViewNames.iLogicVb into a safe location.

2)      Goto Manage >> iLogic >> Edit iLogic Tree

3)      Right click on the “External Rules in Files” & select “Add External Rule”.


4)      Browse & select to the downloaded file in the “Open Rule File(s)” Dialog & it will appear in the iLogic Tree Editor’s “External” tab.



5)      To use the iLogic Right click on ViewNames & select “Run Rule”.

Following Dialog will list the names of existing views.

Steps 1 to 4 are required at 1st time only.
For further use follow step 5 only.

Please run this only in a drawing document. I have not written it to handle any error codes.


iLogic Code:

'Programmed by: - Sanjay Yallure
     Dim strViewNames(0 To 100) As String
    Dim As Integer
    Dim As Integer
    Dim bolRearrange As Boolean
    Dim strTempViewname As String
    Dim oDoc As DrawingDocument
     oDoc = ThisApplication.ActiveDocument
    Dim oSheets As Sheets
    Dim oSheet As Sheet
    oSheets oDoc.Sheets
    Dim oViews As DrawingViews
    Dim oView As DrawingView
     i = 0
    For Each oSheet In oSheets
        oViews oSheet.DrawingViews
        For Each oView In oViews
            'MsgBox oView.Name
            'Write #1, oView.Name
            strViewNames(i) = oView.Name
            i + 1
        Next
    Next
    Do
        bolRearrange False
        For = 0 To - 1
            If strViewNames(j) < strViewNames(+ 1) Then
                strTempViewname strViewNames(j)
                strViewNames(j) = strViewNames(+ 1)
                strViewNames(+ 1) = strTempViewname
                bolRearrange True
            Else
            End If
        Next j
    Loop While bolRearrange True
        Dim strViewNamesList As String
    For = 0 To i+1
        strViewNamesList strViewNamesList strViewNames(j) & vbCrLf
    Next j
    MsgBox (strViewNamesList, vbInformation, "Viewnames")



04 Sept 2012:
Here is the Ilogic with error handling incorporated.
ViewNames1.iLogicVb



No comments: