Author Topic: Copying objects to new db  (Read 7867 times)

0 Members and 1 Guest are viewing this topic.

Glenn R

  • Guest
Re: Copying objects to new db
« Reply #15 on: June 26, 2006, 09:49:13 PM »
Sorry Mick, I must have misread your post.

I was going to post up something about the idPair but you figured it out with my nudging ;)

Good one.

Cheers,
Me.

sinc

  • Guest
Re: Copying objects to new db
« Reply #16 on: January 01, 2009, 12:26:03 PM »
I'm trying to do something similar to this, but I'm trying to let the user pick an entity in an XREF, and clone the entity in the current drawing.  How do I go about that?

In the code below, "obj" is the object selected by the user, and returned by SelectNestedEntity.  It is therefore an entity that exists in the XREF, but it was retrieved using the current drawing's database, and is "from external reference".

Code: [Select]
BlockTableRecord currentSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
IdMapping mapping = new IdMapping();
DBObject clone = obj.WblockClone(currentSpace, mapping, false);

The above code is contained inside the standard Transaction, and I am committing the transaction at the end.  The code creates an object that gets assigned to 'clone', and I can see it in the debugger, and the code runs with no errors, but the cloned entity does not show up in the current drawing.

Am I going about this wrong?  Do I need to explicitly open the XREF database using ReadDWGFile, and then use WBlockCloneObjects() to clone entities between databases?  Or is there some way to use WBlockClone to copy a selected item from a loaded XREF into the current drawing?