mfab03 Posted April 23, 2009 Share Posted April 23, 2009 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. Quote Link to comment Share on other sites More sharing options...
mfab03 Posted April 23, 2009 Author Share Posted April 23, 2009 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. Quote Link to comment Share on other sites More sharing options...
borgunit Posted April 23, 2009 Share Posted April 23, 2009 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.