Another solution that my client wanted was to present all the view names and allow the user to select which view he/she wanted to represent the scale in the title block.
Like the first solution, we cycled through each sheet on the drawing and looked at the view name. If the view name begins with "VIEW" then it was used to build a one dimensional array. We also concatenated the view scale with the view name to satisfy the needs of seeing both the view name and the view scale.
' Cycle thru each sheet. Build array of View Name and View Scale. For Each oSheet In oSheets oViews = oSheet.DrawingViews For Each oView In oViews oViewName = oView.Name If Left(oViewName,4) = "VIEW" Then oScale = oView.Scale oConc = oViewName & ": @ " & oScale oViewList.Add(oConc) End If Next Next
We then sorted the array and set a MultiValue list using that array.
' Sort array oViewList.Sort ' Set Multi-Value List from array MultiValue.List("ViewList") = oViewList
Next we presented an input box to the user using the MultiValue list.
' Present Input Box for user selection selected = InputListBox("Select a view from the list", _MultiValue.List("ViewList"), oViewList.item(0), Title := "Views", _ListName := "View Name @ Scale")
Next we extracted the view name and view scale from the user selection.
' Extract View Name and View Scale from user selectiondelimpos = InStr(selected, "@") oSelectedView = Left(selected,delimpos - 1) oSelectedScale = Right(selected,Len(selected)-delimpos)
Finally, the view scale was pushed to a custom iProperty that was displayed in the drawing title block.
' Set custom iProperty based on user selection iProperties.Value("Custom", "Scale") = RoundToFraction(oSelectedScale, 1/8, _RoundingMethod.Round) & ":1"
The full code is listed here:
' Setting Variables Dim oDrawDoc As DrawingDocument = ThisDrawing.Document Dim oSheet As Sheet Dim oSheets As Sheets oSheets = oDrawDoc.Sheets Dim oView As DrawingView Dim oViews As DrawingViews Dim oScale As Double Dim oViewName As String Dim oConc as String Dim oSelectedView As String Dim oSelectedScale As String Dim oViewList As New ArrayList ' Cycle thru each sheet. Build array of View Name and View Scale. For Each oSheet In oSheets oViews = oSheet.DrawingViews For Each oView In oViews oViewName = oView.Name If Left(oViewName,4) = "VIEW" Then oScale = oView.Scale oConc = oViewName & ": @ " & oScale oViewList.Add(oConc) End If Next Next ' Sort array oViewList.Sort ' Set Multi-Value List from array MultiValue.List("ViewList") = oViewList ' Present Input Box for user selection selected = InputListBox("Select a view from the list", _ MultiValue.List("ViewList"), oViewList.item(0), Title := "Views", _ ListName := "View Name @ Scale") ' Extract View Name and View Scale from user selection delimpos = InStr(selected, "@") oSelectedView = Left(selected,delimpos - 1) oSelectedScale = Right(selected,Len(selected)-delimpos) ' Set custom iProperty based on user selection iProperties.Value("Custom", "Scale") = RoundToFraction(oSelectedScale, 1/8, _ RoundingMethod.Round) & ":1" ' Update iLogicVb.UpdateWhenDone = True
PS - Sorry about the formatting. I can't seem to get those extra spaces out of the sections where I've broken up the code.
Please leave a comment and let me know what you think.
Randy
"Opportunity is missed by most people because it is dressed in overalls and looks like work." - Thomas Edison