Jump to content

HELP: VBA code for AutoCad 2008 (copy objects from one open document to another)


mfab03

Recommended Posts

Hi, I'm fairly new at using VBA code for AutoCad 2008 and I was wondering if anyone could help me.

 

The purpose of my code is to click two objects, recognize which objects I've selected, and then go through the logic and open the correct existing document based on what two objects I've selected.

 

My problem is, when I get the second document open, I want to copy the objects in that drawing into the first drawing I had open. However, I am not able to copy the entities from one open drawing to another.

 

I've tried .copy and .copyobject, but I don't know if I'm doing it correctly. (it would probably help if I bought a book on VBA for autocad, if anyone knows where I can find a good book that advice would also be helpful!)

 

Thanks.

Link to comment
Share on other sites

I guess to make the question as simple as possible...

 

If I have two open drawings, how do I copy an object from one drawing to the other using VBA for AutoCad 2008?

 

It seems like it should be extremely simple, but I can't find anything for it.

Link to comment
Share on other sites

CopyObjects Method [ActiveX and VBA Reference: AAR]From the help file..

 

 

 

RetVal = object.CopyObjects(Objects[, Owner][, IDPairs])

Object

Database, Document

The object or objects this method applies to.

Objects

Variant (array of objects); input-only

The array of primary objects to be copied. All the objects must have the same owner, and the owner must belong to the database or document that is calling this method.

Owner

Variant (a single object); input-only; optional

The new owner for the copied objects. If no owner is specified, the objects will be created with the same owner as the objects in the Objects array.

IDPairs

Variant (array of IDPair objects); input-output; optional

Information on what happened during the copy and translation process.

Input: an empty variant.

Output: an array of IDPair objects.

RetVal

Variant (array of objects)

An array of newly created duplicate objects. Only primary objects are returned in this array. For more information on what occured during the CopyObjects operation, or a list of objects owned by primary objects that were also copied, consult the IDPairs array.

Remarks

To copy objects to another open drawing, set the Owner parameter to the other drawing's model space.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...