Hello. I'm using this function to copy blocks from one drawing to another. It works in AutoCAD 2004, 2006 but I need to know whether will it work in AutoCAD 2010. This is the code that I use and my question is if I add these lines to check version is the method will work or not.
If Left(Application.Version, 2) = "18" Then
Set oDbx = GetInterfaceObject("ObjectDBX.AxDbDocument.18")
End If
Here is the full program:
Private Sub CopyBlock(BlockName As String)
Dim oDbx As Object
' 2007 - 2009 ver.
If Left(Application.Version, 2) = "17" Then
Set oDbx = GetInterfaceObject("ObjectDBX.AxDbDocument.17")
End If
' 2004 - 2006 ver.
If Left(Application.Version, 2) = "16" Then
Set oDbx = GetInterfaceObject("ObjectDBX.AxDbDocument.16")
End If
Dim fname As String
fname = "C:\BojkoCAD\blocks.dwg"
oDbx.Open fname
Dim oBlocks As AcadBlocks
Dim oBlock As AcadBlock
Dim copyVar(0) As AcadBlock
Set oBlocks = oDbx.Blocks
Set oBlock = oBlocks.Item(BlockName)
Set copyVar(0) = oBlock
On Error GoTo problem
Dim idPairs As Variant
Dim copyBLK As Variant
copyBLK = oDbx.CopyObjects(copyVar, ThisDrawing.Blocks, idPairs)
Set oDbx = Nothing
problem:
If Err.Number <> 0 Then
MsgBox "ObjectDBX CopyObjects method objects failed." & vbCr & Err.Number & " " & Err.Description, vbCritical, "BojkoCAD"
End If
End Sub
Solved! Go to Solution.
Solved by Hallex. Go to Solution.
Just an idea not tested
Set oDbx = GetInterfaceObject("ObjectDBX.AxDbDocument.18.2")