Hi
I've attached an Extension Dictionary that contains an Xrecord, to a BlockTableRecord, which is a block.
As a 'template' for a block reference when the block is added to a drawing (I've used drag and drop from Design Center) I thought the Extension Dictionary and its Xrecord would also be included but that is not the case by default.
What can you suggest I do to have the Extension Dictionary and its Xrecord included in the BlockReference when it is created?
Craig
Try setting the TreatElementsAsHard property on the owning DBDictionary to true
public bool TreatElementsAsHard;
Accesses whether elements are treated hard or not.
I don't really understand its purpose but I went with it.
I tried attaching the extension dictionary to the BlockTableRecord with it set to true but I noticed the associated BlockReference in the symbol library does not get this extension dictionary. So I attached the extension dictionary to the BlockReference in the symbol library with it set to true and tried inserting it into a new drawing but the extension dictionary does not get created.
I probably don't have enough of an understanding of the role of the block's BlockTableRecord and what is cloned as far as the block Reference is concerned. Any good reading on the subject somewhere?
The extension dictionary should be cloned as mentioned with TreatElementsAsHard set to true. It will be inside the BlockTableRecord's extension dictionary and I have not had success for it cloning when a blockreference is created for it.
I know Xdata wil be cloned from attribute definitions to attribute references, but not sure if it will clone from a BlockTableRecord to a BlockReference.
Stupid question time: is creating a new BlockReference object (insert) actually considered cloning a BlockTableRecord (block definition)? If not, It might very well be necessary to extend the default operation with something to add the required extension information - event handler, specialized insert tool, whatever.
I would have to go back and look through docs but from what I remeber a block reference really is nothing but some entities properties(Layer, color) and transformations applied to draw method of a blocktablerecord.
So a block reference just pushes its color overrides, position, scale, rotation, etc.... transformation's into graphics pipeline then tells the blocktablerecord to draw its self then pops the transformation back off. The only entities actually attached are attributes I believe.
Thanks for all your input everyone. Thanks to Jeff H's post and responses on TheSwamp http://www.theswamp.org/index.php?topic=38440.0 (I guess this is your post Jeff) I've been able to add my extension dictionary to the block reference in the ObjectAppended event handler when my block is inserted, basing it on the extension dictionary in the block definition saved earlier (with the TreatElementsAsHard property set to true).
Taking this a little further, I'd like to display a form at the end of the event handler to capture some information that will be used to add some instance specific data to the extension dictionary. Having read the event guidelines in the developers guide I'm not sure it's safe. What do you think?
Under those circumstances, I typically build a specific tool and command to do the work rather than relying on a piggyback to the built in commands. More control, fewer work-arounds.
I think I will have to write a specific tool as you suggest. I've yet to extend it further to determine where it has been placed to allow or disallow the insert according to what is under the pointer.
I was hoping for a more integrated solution but it seems too risky.
Merry Christmas and Happy Holidays.
Hi cnicholas,
The best way to make sure about your event handler and your form would be to give a try... but indeed I don't think it is a recommended pratice. A better suggestion would be to use the event handler to keep track of the created objectId's and display your form once the insertion is finished, typically your could use CommandEnded event to display the form, gather data and modify the necessary xdata/record.
On the other side, dgorsman is correct: you'd better provide your own command that will handle all the required inputs before actually taking any actions, but that would depend upon your requirements and how you want to provide the feature to your users. You also have the possibility to overwrite the native commands if you think that's the best way to go
I hope it helps,
Philippe.
Hello again,
Sorry for my late reply.
I'm interested in trying the CommandEnded approach.
Depending on the command I want to handle, for example PASTECLIP after Ctrl-V, how do I access what was pasted? Will it be available via the arguments passed to the event handler i.e. sender (which I presume is the Document) and the CommandEventArgs?
Similarly, I want to intercept the command with CommandWillStart and cancel the command depending on values within the object. In this case too I need to know how to get access the object.
I've looked in the developer's guide, samples and managed class reference but I couldn't find what I need. Perhaps I wasn't looking in the right place.
Craig
We have basically 2 blogs dedicated to AutoCAD customization, it's not too much pain to take a quick look there before asking questions:
http://through-the-interface.typepad.com/through_the_interface/
http://adndevblog.typepad.com/autocad/
One of the first hit you can find when performing a search on those blogs with PASTECLIP keyword is the following post. The pasteclip arguments won't be returned by the event handler unfortunately. Did you at least test it or checked the helpfiles? The only property of CommandEventArgs is GlobalCommandName, a string.
Philippe.