- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to make a simple script which will go through the sheets of my drawing file, find all of the centerline or centermark annotations (eventually I will add dimensions too) and will check them for being attached, if they are not attached then they will be put on an Orphan dims layer which isn't printed.
The code I have below seems to work for centermarks but doesn't seem to work for centerlines for some reason even though the subs are apparently very similar.
My next step will be to add Else statements to the subroutines in this script to force the annotation back to it's original state in the event that it becomes reattached. However in order to do that, I need to know the Users style settings to record their "Default" layer for said annotation. How do I retrieve that?
I'm very new to scripting so if anyone can give me any advice in general then that would be massively appreciated.
Sub Main()
oHideOption = InputRadioBox("Select an option:", _
"Hide Orphan Dimensions", "Show Orphan Dimensions", True, "iLogic")
Dim oDoc As Document = ThisDoc.Document
Try
oOrphanLayer = oDoc.StylesManager.Layers.Item(1).Copy("Orphan Dims")
Catch
oOrphanLayer = oDoc.StylesManager.Layers.Item("Orphan Dims")
End Try
If oHideOption = True Then
For Each oSheet In oDoc.Sheets
HideCenterlines(oSheet, oOrphanLayer)
HideCentermarks(oSheet, oOrphanLayer)
Next
Else
oOrphanLayer.Visible = True
End If
oDoc.Update
End Sub
Sub HideCenterlines(oSheet, oOrphanLayer)
Try
Dim oDrawingCTM As Centerline
For Each oDrawingCTL In oSheet.Centerlines
If oDrawingCTL.Attached = False Then
oDrawingCTL.Layer = oOrphanLayer
End If
Next
Catch
MessageBox.Show("Error in HCL")
End Try
End Sub
Sub HideCentermarks(oSheet, oOrphanLayer)
Try
Dim oDrawingCTM As Centermark
For Each oDrawingCTM In oSheet.Centermarks
If oDrawingCTM.Attached = False Then
oDrawingCTM.Layer = oOrphanLayer
End If
Next
Catch
MessageBox.Show("Error in HCM")
End Try
End Sub
Solved! Go to Solution.