.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to include a block's Extension Dictionary when inserting a block reference

15 REPLIES 15
Reply
Message 1 of 16
Anonymous
1126 Views, 15 Replies

How to include a block's Extension Dictionary when inserting a block reference

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

15 REPLIES 15
Message 2 of 16
Mikko
in reply to: Anonymous

have you thought of moving the data from xrecord to xdata and attach that to block
Message 3 of 16
Anonymous
in reply to: Mikko

Yes. XData may be too small to hold our deserialised XML object.
Message 4 of 16
DiningPhilosopher
in reply to: Anonymous

Try setting the TreatElementsAsHard property on the owning DBDictionary to true

Message 5 of 16
Mikko
in reply to: Anonymous

not like the old reply's when you would rip us a new one Smiley Very Happy  miss those daze.....

Merry Christmas

Message 6 of 16
Anonymous
in reply to: Anonymous

 

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?

 

Message 7 of 16
Anonymous
in reply to: Anonymous

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.

 

 

Message 8 of 16
dgorsman
in reply to: Anonymous

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.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 9 of 16
Anonymous
in reply to: dgorsman

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.

 

 

Message 10 of 16
Anonymous
in reply to: Anonymous

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?

Message 11 of 16
dgorsman
in reply to: Anonymous

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.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 12 of 16
Anonymous
in reply to: dgorsman

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 HolidaysSmiley Happy.

Message 13 of 16
philippe.leefsma
in reply to: Anonymous

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.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 14 of 16
Anonymous
in reply to: dgorsman

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

 

Message 15 of 16
philippe.leefsma
in reply to: Anonymous

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.

 

http://through-the-interface.typepad.com/through_the_interface/2012/12/hooking-into-autocad-copy-pas...

 

Philippe.

 

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 16 of 16
Anonymous
in reply to: philippe.leefsma

Thanks Philippe, I have been looking at Kean's blogs and I have seen some articles by Balaji but no match for waht I'm trying to do. If the objects processed by the command are not available via the event handler arguments I have not choice then but to redefine these commands.
Craig

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost