AlternateName Example
Sub Example_AlternateName_Add_Aec() ' This example list the multi-view block styles in the current ' drawing, and allows the user to add an alternate name to each ' style (if an alternate name does not already exist). ' Use this example with a drawing that contains one or more ' multi-view block styles. Dim app As New AecBaseApplication Dim doc As AecBaseDocument Dim mvblockStyles As AecMVBlockStyles Dim mvblockStyle As AecMVBlockStyle Dim msg As String Dim altname As String Dim reply As Integer app.Init ThisDrawing.Application Set doc = app.ActiveDocument ' Get the collection of multi-view block styles in the drawing. Set mvblockStyles = doc.mvblockStyles ' If there are no multi-view block styles defined in the ' drawing, alert user and then exit. If mvblockStyles.count = 0 Then msg = "There are no multi-view block styles in the drawing. " MsgBox msg, vbExclamation, "AlternateName Example" Exit Sub End If ' List the name and alternate name of each multi-view block ' style in the current drawing. If AlternateName is blank, ' allow user to set it. For Each mvblockStyle In mvblockStyles msg = "MV block style name: " & mvblockStyle.Name & vbCrLf altname = mvblockStyle.AlternateName If altname = "" Then msg = msg & " There is no alternate name for " & mvblockStyle.Name & vbCrLf & " Add one at Command prompt?" reply = MsgBox(msg, vbYesNo, "Set alternate name at Command prompt?") ' Prompt user to enter an alternate name, if they chose ' to do so. If reply = vbYes Then doc.Utility.Prompt list altname = doc.Utility.GetString(True, "Alternate name --> ") mvblockStyle.AlternateName = altname End If Else msg = msg & " Alternate name: " & mvblockStyle.AlternateName & vbCrLf MsgBox msg, vbInformation, "AlternameName Example" End If Next
End Sub