Associating (almost adding) an entity to a block

Associating (almost adding) an entity to a block

dennis
Advisor Advisor
669 Views
6 Replies
Message 1 of 7

Associating (almost adding) an entity to a block

dennis
Advisor
Advisor

Here is the scenario:  I want to associate a text character to an instance of a block.  I don't want to just add it to the block, because then it would be added to other instances of the block.  It can't be a dynamic definition for the same reason as just adding, nor can it be an attribute mainly because the sync would be then spread to all block instances.  It is very much a unique block-by-block association and not all blocks (of the same name) would receive this association.

I went down the C# road of adding it as an Xrecord / Property, which does work, but the catch...i need it on a layer.  I tried as well adding an event to the layer freeze/thaw to toggle the character on and off, but the impact on speed was significantly detrimental.

I would like to just place the character, and "tie it" to the block so it moves with it, and the block "knows" it is there.

 

Looking for suggestions and ideas as to "how to do this".  I have been thinking "constraints" but wanted to see if there a "better way".

 

0 Likes
Accepted solutions (1)
670 Views
6 Replies
Replies (6)
Message 2 of 7

dgorsman
Consultant
Consultant

Put the block reference and the text entity in a group.  They can be selected together or separately, depending on the group selection system variable setting.  Groups can be named or anonymous; named groups are easier for the user to specify.  You can use extension dictionary/Xrecord to point back to the group and use the group contents to find the other member entities.

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


0 Likes
Message 3 of 7

dennis
Advisor
Advisor

That is a thought using groups.  I would see the need to still capture the event "MOVE" for example, so that when the user wants to move the block, then the "group" would need to be turned on.  Past experience has me reluctant to use events like this due to the impact on performance...and the "unseen consequences" that can arise downstream.

But that is an idea i will look into to see if it would work for this application.

0 Likes
Message 4 of 7

norman.yuan
Mentor
Mentor

I am not sure I understand the description of your issue in hand, especially what "associating" means exactly. But it sounds like "constraints" might provide something. Have you fully explored it? The good thing is, if it helps, that there is no extra code loading/executing required; just set up constraints in the drawing (there is also API to do that, of course. But I saw there is very little interests on that ground so far).

 

The other approach you could try, if loading/executing extra code as programmatic solution does not bothers you, would be Overrule. Again, not knowing the exactly meaning of "associating", the solution can be single custom Overrule, or a combination of Overrules. For example, you can use TransformOverrule to solve the moving issue, and use VisibilityOverrule to turn the text off/on, using ObjectOverrule to prevent the text to be erase (i.e. making it can only be erased with the associated block reference)...and so on.

 

Just be aware, the same as heavily using dynamic blocks, heavily using overrules would usually slow down AutoCAD performance.

 

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 5 of 7

dgorsman
Consultant
Consultant
Accepted solution

@dennis wrote:

That is a thought using groups.  I would see the need to still capture the event "MOVE" for example, so that when the user wants to move the block, then the "group" would need to be turned on.  Past experience has me reluctant to use events like this due to the impact on performance...and the "unseen consequences" that can arise downstream.

But that is an idea i will look into to see if it would work for this application.


I would suggest skipping auto-updating the system variable setting for now.  Trying to enforce it will make things a little more difficult later e.g. trying to tweak the text position independently of the block.  We use groups for similar tasks, and once users are informed about what's happening, they leave it turned on.  And being able to turn it off for the few times it's useful is also good.

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


0 Likes
Message 6 of 7

ActivistInvestor
Mentor
Mentor

Your problem description doesn't state what should happen when a user copies a block reference with your 'associated' text, or erases the block reference. In those cases, what should happen?

 


@denniswrote:

Here is the scenario:  I want to associate a text character to an instance of a block.  I don't want to just add it to the block, because then it would be added to other instances of the block.  It can't be a dynamic definition for the same reason as just adding, nor can it be an attribute mainly because the sync would be then spread to all block instances.  It is very much a unique block-by-block association and not all blocks (of the same name) would receive this association.

I went down the C# road of adding it as an Xrecord / Property, which does work, but the catch...i need it on a layer.  I tried as well adding an event to the layer freeze/thaw to toggle the character on and off, but the impact on speed was significantly detrimental.

I would like to just place the character, and "tie it" to the block so it moves with it, and the block "knows" it is there.

 

Looking for suggestions and ideas as to "how to do this".  I have been thinking "constraints" but wanted to see if there a "better way".

 


 

0 Likes
Message 7 of 7

dennis
Advisor
Advisor

The users were all agreeable to the group idea

0 Likes