VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to copy blocks using VB.NET through COM?

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
459 Views, 2 Replies

How to copy blocks using VB.NET through COM?

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.

 

2 REPLIES 2
Message 2 of 3
Alfred.NESWADBA
in reply to: Anonymous

Hi,

 

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

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 3
Anonymous
in reply to: Alfred.NESWADBA

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost