Identify Sheet Sets in AutoCAD through VBA

Identify Sheet Sets in AutoCAD through VBA

Anonymous
Not applicable
2,233 Views
2 Replies
Message 1 of 3

Identify Sheet Sets in AutoCAD through VBA

Anonymous
Not applicable

Hello,

As part of our standards, we do not accept Sheet Sets to be used in drawings.  I am trying to come up with VBA code to flag these sheet sets but I am having some difficulties locating the object.  What I have been doing is cycling through the objects in the drawing dictionary to see if there is any existing.  Works sometimes, and sometimes it doesn't.  It doesn't seem VBA has much in the way of classes for sheet sets.  If anyone could help, it would be greatly appreciated.

 

0 Likes
2,234 Views
2 Replies
Replies (2)
Message 2 of 3

norman.yuan
Mentor
Mentor

The information about whether a drawing is in a Sheet Set is not stored in drawing itself (so searching drawing dictionaries will not "works sometimes, and sometime it doesn't"). It stores in Sheet set file (*.dst file). If your office does not use Sheet Set, there is no need to do anything to the drawing itself.

 

On the other hand, if you do want to programmatically work with sheet set, be it cearing a sheet set, or creating sheet set, you can do it with VBA: simply add reference to "AcSmComponentsXX" type library, XX corresponds to your AutoCAD version.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 3

ambrosl
Autodesk
Autodesk

That isn't completely accurate, there is information stored in a drawing to prevent it from being imported into another sheet set.  The information stored in a drawing that was previously imported into a sheet set can be found in the AcSheetSetData dictionary.  This information can be accessed using VBA by doing something like the following:

 

Sub GetSheetSetDataInDrawing()
  On Error Resume Next
  
  ' Get the AcSheetSetData dictionary
  Dim acDictObj As AcadDictionary
  Set acDictObj = ThisDrawing.Dictionaries("AcSheetSetData")
  
  ' If there is no error then get the data of the dictionary
  If Err.Number = 0 Then
    Dim acXrecObj As AcadXRecord
    Dim xType As Variant, xVal As Variant
    
    For Each acXrecObj In acDictObj
      acXrecObj.GetXRecordData xType, xVal
      MsgBox "Entry Name: " & acXrecObj.Name & vbLf & _
             "Value: " & CStr(xVal(0))
    Next acXrecObj
  End If
End Sub

Using the Sheet Set API will allow you to walk a sheet set (DST) file and access the references to the drawings in which the sheet set contains along with things like Publish settings, custom properties and more.  A demonstration of the Sheet Set API (with VB.NET which would be similar to VBA) can be found at the following location on the AU website: http://au.autodesk.com/au-online/classes-on-demand/class-catalog/classes/year-2015/autocad/it10489#c...



Lee Ambrosius
Senior Principal Content Experience Designer
For additional help, check out the AutoCAD Developer Documentation