Tuesday, January 17, 2006

Copy dimstyles between drawings using VBA

' Add reference to AutoCAD/ObjectDBX Common 16.0 Type Library (axdb16enu.dll)
' This samples copies all dimstyles from specified drawing to the current drawing
' Existing dimstyles are not affected
Public Sub ImportDimstyles()
   Dim oAxDbDoc As New AxDbDocument
   oAxDbDoc.Open "c:\DimStyles.dwg"
   Dim oObj() As Object
   Dim oDs As AcadDimStyle
   Dim i As Integer
   For i = 0 To oAxDbDoc.DimStyles.Count - 1
      ReDim Preserve oObj(i)
      Set oObj(i) = oAxDbDoc.DimStyles(i)
   Next
   oAxDbDoc.CopyObjects oObj, ThisDrawing.Database.DimStyles
End Sub

1 comment:

  1. Restored comments

    Anonymous said...

    Could not get this to work in ADT 2006.
    Some type of error in the Public Sub statement.
    May 30, 2006

    JTB World said...

    Did you add reference to AutoCAD/ObjectDBX Common 16.0 Type Library?
    May 30, 2006

    ReplyDelete

Some of the latest blog posts

Subscribe to RSS headline updates from:
Powered by FeedBurner