Hi, all:
I got a question about access AUTOCAD through COM.
Previously I have one VB6 program, which read blocks from an external dwg files and insert into AUTOCAD2010's activepage. Now I want to upgrade to VB.NET2010, but found one big problem cannot be resolved, that is, how to copy blocks from an external dwg files?
I use the command below to copy blocks from dwg file:
Call GetBlocksFromDwg("d:\abc.dwg", obj_Doc)
obj_'s definition is:
Dim obj_Doc As Autodesk.AutoCAD.Interop.AcadDocument
Previous VB6 source codes:
Private Sub GetBlocksFromDwg(DwgName As String, Target As Object)
Set DbxDoc = obj_Acad.GetInterfaceObject("ObjectDBX.AxDbDocument.18")
DbxDoc.Open DwgName
Dim Objects(0 To 0) As Object
For Each entry In DbxDoc.Blocks
Set Objects(0) = DbxDoc.Blocks(entry.Name)
DbxDoc.CopyObjects Objects, Target.Blocks
Next
End Sub
Current VB.NET 2010's source codes:
Private Sub GetBlocksFromDwg(ByRef DwgName As String, ByRef Target As Object)
Dim entry As Object
Dim DbxDoc As Object
DbxDoc = obj_Acad.GetInterfaceObject("ObjectDBX.AxDbDocument.18")
DbxDoc.Open(DwgName)
Dim Objects(0) As Object
For Each entry In DbxDoc.Blocks
Objects(0) = DbxDoc.Blocks(entry.Name)
.CopyObjects(Objects, Target.Blocks, Type.Missing)
Next entry
End Sub
The command below cannot work:
.CopyObjects(Objects, Target.Blocks, Type.Missing)
Please advise, thanks a lot.
Hi,
crosspost, please continue in the forum for >>>AutoCAD dev with .NET<<<.
- alfred -