Thursday, January 19, 2012

Set Your Drawing View Labels to Use the Model Part Number

Issue:
You'd prefer your view labels to use the model part number (or some other file property) rather than the default "View1", "View2", and so on. Re-naming the view labels manually is tedious and error prone. 



Solution:
You can change the view label default to use an iProperty from the model using these steps:
  • Open a drawing file
  • Go to the Manage tab
  • Click the Styles and Standards button
  • Click the Standard to work with from the top of the tree on the left pane
  • Activate the View Preferences tab in the right pane
  • Click the Edit button for Display field
  • Set the Type drop down to Properties-Model
  • Set the Properties drop down to Part Number (or something else)
  • Click the Add Text Parameter button to add this property to your view label

You can click the image below to enlarge it and see the picks and clicks.

Click to Enlarge



Here is a bit of iLogic Code to set the view name and browser node to the model part number also:


'start of ilogic code
Dim oApp As Application: oApp = ThisApplication
Dim oDoc As DrawingDocument:  oDoc = oApp.ActiveDocument

Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView

oSheets = oDoc.Sheets

For Each oSheet In oSheets
oViews = oSheet.DrawingViews
                For Each oView In oViews
                oModelName = _
                oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName
                oPartNumber = iProperties.Value(oModelName, "Project", "Part Number")
            oView.Name = oPartNumber
                Next
Next
'end of ilogic code



Update:
By request here is a rule that adds a custom iProperty to the view label with a dash separator.



'start of ilogic code
Dim oDoc As DrawingDocument:  oDoc = ThisDoc.Document

Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView

oSheets = oDoc.Sheets

For Each oSheet In oSheets
oViews = oSheet.DrawingViews
                For Each oView In oViews
                'capture the current view label
                ViewLabel = oView.Name
                oModelName = _
                oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName
                Try
            o_iProp = iProperties.Value(oModelName, "Custom", "My_iProp")        
            'add the the iProperty to the current view label, with a dash separator
                oView.Name = ViewLabel & " - " & o_iProp
            Catch
            'do nothing if error
                End Try
            Next
Next

'end of ilogic code