I am getting Invalid Object array error on following line:
Code is given below
Here is a sample code that worked ok.
If oAcadApp IsNot Nothing Then Dim oActiveDoc As AcadDocument oActiveDoc = oAcadApp.ActiveDocument Dim oSourceDoc As AcadDocument oSourceDoc = Nothing For Each oDoc As AcadDocument In oAcadApp.Documents If ("C:\Temp\Test.dwg").ToUpper() = oDoc.FullName.ToUpper() Then oSourceDoc = oDoc Exit For End If Next If oSourceDoc IsNot Nothing Then ' Get the block to copy Dim myBlock As AcadBlock myBlock = oSourceDoc.Blocks.Item("Test") ' Gather the entities in the block to copy Dim objects(0 To myBlock.Count - 1) As AcadEntity Dim i As Integer i = 0 For Each obj In myBlock objects(i) = obj i = i + 1 Next obj ' Copy the block from the source to the active drawing ' Add a new block Dim newBlock As AcadBlock newBlock = oActiveDoc.Blocks.Add(myBlock.Origin, myBlock.Name) ' Copy the objects to the new block oSourceDoc.CopyObjects(objects, newBlock) End If End If
Please note that the collection of objects to the "CopyObjects" method is a collection of AcadEntity.
Dim myBlock As AcadBlock
You already binding it early. This is nto what I am looking for. The objective was to use both parameters of CopyObject as Late Binding.
And all this is required to detect INstalled AutoCad copy on Machine because I don't want to compile code for different versions of AutoCAD.
How can I make a single piece of code working for all versions of AutoCAD?
Sorry, I do not find any way to do that.
The "CopyObjects" method does not work with an Object array.
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.