Author Topic: Hitching a ride during cloning  (Read 2216 times)

0 Members and 1 Guest are viewing this topic.

Jeff H

  • Needs a day job
  • Posts: 6150
Hitching a ride during cloning
« on: January 29, 2013, 01:05:15 PM »
Let's say you have your standard blocks contained in library files.
For setting up something to help with inserting them on a certain layer, you can add the layers to the library file that you want the blocks inserted on.
Then in the BlockTableRecords ExtensionDictionary add the Layers ObjectId using a HardPointer type code.

The layer gets cloned and for BlockReferences you can look in definitions ExtensionDictionary to get translated ObjectId of layer so it keeps its association.

For drawings that are meant to be inserted as blocks does anyone have an idea of a good way to map the layer during a 'Insert', assuming you add the layer or layers to drawing(and using your own logic to store ids and decide which one is appropriate for the condition). The layers get cloned for just being in the drawing, but not sure of a good way to recreate association when 'Inserted'.
During a Insertion the extensionDictionary values do not seem to get cloned with TreatElementsAsHard = true.

I tried using a ObjectOverrule and adding the layers ObjectId to the Blocks file ModelSpace's ExtentionDictionary, and the ExtensionDictionary of its DraworderTable & BlockBegins, but does not get cloned.


I did get something hackishly working with BeginDeepCloneTranslation event but doesn't feel right.

Or probably best to quit trying what I think might work and try to understand exactly what is happening, for starters during a 'Insert' does it kinda act like a deepclone where it opens the database of the drawing to be inserted and instead copying & translating the ObjectIds it just keeps the same ObjectIds and destroys the database leaving the objects in memory that are needed for the 'Insertion'?
« Last Edit: January 29, 2013, 01:09:25 PM by Jeff H »

TheMaster

  • Guest
Re: Hitching a ride during cloning
« Reply #1 on: January 31, 2013, 06:25:45 AM »
....The layer gets cloned and for BlockReferences you can look in definitions ExtensionDictionary to get translated ObjectId of layer so it keeps its association.

For drawings that are meant to be inserted as blocks does anyone have an idea of a good way to map the layer during a 'Insert', assuming you add the layer or layers to drawing(and using your own logic to store ids and decide which one is appropriate for the condition). The layers get cloned for just being in the drawing, but not sure of a good way to recreate association when 'Inserted'.
During a Insertion the extensionDictionary values do not seem to get cloned with TreatElementsAsHard = true.

I tried using a ObjectOverrule and adding the layers ObjectId to the Blocks file ModelSpace's ExtentionDictionary, and the ExtensionDictionary of its DraworderTable & BlockBegins, but does not get cloned.


I've read this twice, and I'm still not sure I understand what your question is. What do you mean by 'association'?  The way Insert() works depends on which version of the method you're using and what you pass as the value for the preserveSourceDatabase argument. If it's true, the operation is a DeepClone, so what is not going along for the ride?

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Hitching a ride during cloning
« Reply #2 on: January 31, 2013, 11:08:53 AM »
Sorry Tony,

Trying to get a entrry in a drawing's ModelSpace Extension Dictionary to copy over to the BlockTableRecord that is created when it is inserted.
So Block.dwg is inserted into Drawing.dwg, where the entry in Block.dwg ModelSpace's ExtensionDictionary will be cloned into the BlockTableRecord "Block" in Drawing.dwg.

Hopefully that makes a little more sense.

Thanks.

WILL HATCH

  • Bull Frog
  • Posts: 450
Re: Hitching a ride during cloning
« Reply #3 on: January 31, 2013, 01:16:23 PM »
Could you take a step back and clone the model space block table record which has the extension dictionary attached instead of the individual entities contained within it?

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Hitching a ride during cloning
« Reply #4 on: January 31, 2013, 01:23:41 PM »

Thanks Will,

I was hoping to have it work with AutoCADs 'INSERT' command and was testing using default insert, but might be easier to do it myself.

TheMaster

  • Guest
Re: Hitching a ride during cloning
« Reply #5 on: February 04, 2013, 08:13:33 PM »
Sorry Tony,

Trying to get a entrry in a drawing's ModelSpace Extension Dictionary to copy over to the BlockTableRecord that is created when it is inserted.
So Block.dwg is inserted into Drawing.dwg, where the entry in Block.dwg ModelSpace's ExtensionDictionary will be cloned into the BlockTableRecord "Block" in Drawing.dwg.

Hopefully that makes a little more sense.

Thanks.

I haven't tried it, so I can't say for sure what's going on, but it may be that Insert() just doesn't clone dictionary entries from the model space block to an insert-able block. There could be all kinds of stuff in the ms extension dictionary, and it probably wouldn't clone anything unless there's a hard reference to it in one of the entities in model space.

So, I think the only way to do that without code-based intervention would be to plant something in model space that would cause the dictionary to be cloned.


Jeff H

  • Needs a day job
  • Posts: 6150
Re: Hitching a ride during cloning
« Reply #6 on: February 04, 2013, 08:52:50 PM »
Thanks Tony!


And a friendly reminder
WARNING!
Do not make the mistake of adding a ObjectID of a layer in ModelSpace's ExtensionDictionary and accidently using TypeCode HardOwnerID instead of HardPointerId.


Will corrupt drawing!!!!