I'm working in ORD 2021 R1. Wondering if there is any way to remove individual annotation groups from the cross sections? I originally annotated all drawing models with EAV and have ultimately decided I wanted to remove it. We can add individual annotation groups to all drawing models but I don't see a way to remove individual groups, only remove all groups at once. Does anyone have a workaround for this?
Hi Matt,
There is a way to do this via VBA. As every Annotation Group placement instance has a unique Named Group, you can use vba to get the Named Group from a selected element and delete all elements that are part of the same one. You could then get it to iterate through all Drawing models to delete other instances of it.
Unfortunately no native tools for this...yet.
Regards,
Mark
OpenRoads Designer 2023 | Microstation 2023.2 | ProjectWise 2023
The VBA code below should do what you need. To run:
Sub deleteAnnoAll() Dim oScanEnumerator As ElementEnumerator, oScanEnumerator0 As ElementEnumerator, ph As PropertyHandler Dim oGroupName As String, ph0 As PropertyHandler, oElement As Element, oSelected As Element, oModel As ModelReference If ActiveModelReference.Type = msdModelTypeDrawing Then For Each oModel In ActiveDesignFile.Models If oModel.Type = msdModelTypeDrawing Then countDrawings = countDrawings + 1 End If Next If ActiveModelReference.AnyElementsSelected = False Then CadInputQueue.SendCommand "beep" ShowMessage "ERROR - No elements selected", , msdMessageCenterPriorityError, True GoTo finish Else Set oScanEnumerator0 = ActiveModelReference.GetSelectedElements oScanEnumerator0.MoveNext Set oSelected = oScanEnumerator0.Current If oSelected.ModelReference.IsAttachment = False And oSelected.ModelReference.Name = ActiveModelReference.Name Then Set ph0 = CreatePropertyHandler(oSelected) If ph0.SelectByAccessString("Groups[0].Description") = True Then oSearch = InStr(ph0.GetDisplayString, "\") oGroupName = Left(ph0.GetDisplayString, oSearch) If ph0.GetDisplayString = "" Then CadInputQueue.SendCommand "beep" ShowMessage "ERROR - Selected element is not Civil Annotation", , msdMessageCenterPriorityError, True GoTo finish End If Else CadInputQueue.SendCommand "beep" ShowMessage "ERROR - Selected element is not Civil Annotation", , msdMessageCenterPriorityError, True GoTo finish End If Else CadInputQueue.SendCommand "beep" ShowMessage "ERROR - Only elements in active model can be used for this tool", , msdMessageCenterPriorityError, True GoTo finish End If ' Save current model name 'currMod = ActiveModelReference.Name Dim oScanCriteria As New ElementScanCriteria ' Cycle through models and delete matching annotation group elements For Each oModel In ActiveDesignFile.Models If oModel.Type = msdModelTypeDrawing Then totmodels = totmodels + 1 count1 = 0 oScanCriteria.IncludeOnlyVisible oScanCriteria.ExcludeNonGraphical Set oScanEnumerator = oModel.Scan(oScanCriteria) oRun = 1 'oModel.Activate ShowTempMessage msdStatusBarAreaMiddle, "Processing Drawing model " + CStr(totmodels) + " of " + CStr(countDrawings) + "..." Do While oScanEnumerator.MoveNext Set oElement = oScanEnumerator.Current countTot = countTot + 1 If oElement.IsGraphical = True And oElement.ModelReference.Name = oModel.Name And oElement.ModelReference.IsAttachment = False Then Set ph = CreatePropertyHandler(oElement) If ph.SelectByAccessString("Groups[0].Description") = True Then oSearch = "" oSearch = InStr(ph.GetDisplayString, "\") oNew = Left(ph.GetDisplayString, oSearch) If StrComp(oNew, oGroupName, vbBinaryCompare) = 0 Then oModel.RemoveElement oElement count = count + 1 count1 = count + 1 End If End If End If Loop If count1 > 0 Then countMod = countMod + 1 End If End If Set oElement = Nothing Set oModel = Nothing Set oScanEnumerator = Nothing Next ' Return to original model 'ActiveDesignFile.Models(currMod).Activate CadInputQueue.SendCommand "beep" If count > 0 Then ShowMessage CStr(count) + " total annotation element(s) deleted from " + CStr(countMod) + " Drawing models." & vbNewLine & vbNewLine + "Removed Annotation Group: " + vbNewLine + Left(ph0.GetDisplayString, oSearch - 1), , msdMessageCenterPriorityInfo, True Else ShowMessage "No associated Civil Annotation found in any Drawing models", , msdMessageCenterPriorityWarning, True End If End If Else CadInputQueue.SendCommand "beep" ShowMessage "ERROR - Tool can only be run in a Drawing model", , msdMessageCenterPriorityError, True End If GoTo finish skip: finish: CommandState.StartDefaultCommand Exit Sub End Sub
Awesome Derek, looks good.
I'm thinking of enhancing this to provide a dialog with a list of currently found Annotation Group instances instead of needing to pre-select an element from a group as another option. Hopefully will have that done in the not too distant future.
Mark,
This looks like a great solution. I didn't find this on the OpenCivil Product Ideas site. Have you thought about adding it there so perhaps it can be added to the product itself? I'm certain it would get a lot of votes.
I submitted this to the Ideas page a week or two ago. Looks like it's still under review or maybe didn't go through yet. But I did get a confirmation email. I had also submitted Enhancement Request 977276 a few months ago.
Matt Eiben
Andrew Wagner said:For now, I have to hard code the name of the annotation group. As I learn more VBA,
I recommend a couple changes as alternatives that might help you in your VBA experience and the longevity of this script and future work.
1. Instead of setting the value of oGroupName in line 24, move that line up to line 2 to make it more obvious and so make the sub more repurposable.
2. Instead of setting the value of oGroupName at all within this sub, have the sub receive that value as an argument and rename the sub: Sub deleteAnnoByGroupName(oGroupName As String). As for using it, create a new sub that does nothing but call this sub with the desired group name: deleteAnnoByGroupName "Design Annotations\XS Edge of Pavement\"
Same here - i have about a dozen that haven't shown up from a few ago.