How to copy blocks using VB.NET through COM?

How to copy blocks using VB.NET through COM?

Anonymous
Not applicable
692 Views
2 Replies
Message 1 of 3

How to copy blocks using VB.NET through COM?

Anonymous
Not applicable

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.

 

0 Likes
693 Views
2 Replies
Replies (2)
Message 2 of 3

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

crosspost, please continue in the forum for >>>AutoCAD dev with .NET<<<.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 3

Anonymous
Not applicable

Sorry, I just want to know the answer ASAP.Smiley Frustrated

0 Likes