I tried it that way and it worked (with a button in the form), I hope for you too
Const tSourceFileName As String = "C:\TEMP\X01.DWG" Const tDestFileName As String = "C:\TEMP\X02.DWG" Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim obj_Acad As AcadApplication = CType(GetObject(, "AutoCAD.Application.18"), AcadApplication) Dim TargetDoc As AcadDocument = obj_Acad.Documents.Open(tDestFileName) Dim DbxDoc As Object = obj_Acad.GetInterfaceObject("ObjectDBX.AxDbDocumen
t.18") DbxDoc.Open(tSourceFileName) Dim Objects(0) As Common.AcadBlock For Each entry As Common.AcadBlock In CType(DbxDoc.Blocks, IEnumerable) If (Not entry.IsLayout) AndAlso (Not entry.Name.StartsWith("*")) Then Objects(0) = entry DbxDoc.CopyObjects(CObj(Objects), TargetDoc.Blocks) Debug.Print(entry.Name) End If Next entry End Sub
- alfred -
Thanks a lot, it works.
The key is:
dim entry as acadblock
dim Objects(0) as acadblock
Access a broad range of knowledge to help get the most out of your products and services.
Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.
Upgrading to a 2015 product? Make sure to check these out 1st!