Author Topic: What's a good way to distinguish a block reference object?  (Read 2074 times)

0 Members and 1 Guest are viewing this topic.

cannorth

  • Guest
What's a good way to distinguish a block reference object?
« on: August 13, 2013, 09:01:52 PM »
Hello,

  Aside from the Name, what are two other ways to distinguish one block from another to prevent two different blocks being selected by the code?

cannorth 

owenwengerd

  • Bull Frog
  • Posts: 451
Re: What's a good way to distinguish a block reference object?
« Reply #1 on: August 13, 2013, 10:24:39 PM »
Only block definitions have a name, but you mention "selecting" them, so it sounds like you're talking about block references. Can you clarify your question?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: What's a good way to distinguish a block reference object?
« Reply #2 on: August 13, 2013, 10:29:56 PM »
and :
Are they conventional blocks or dynamic blocks
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

cannorth

  • Guest
Re: What's a good way to distinguish a block reference object?
« Reply #3 on: August 14, 2013, 12:33:01 PM »
Dynamic blocks.  The name of the block has a name like U32, and the block name has "MODEL SPACE" with asterisks.  I like the actual block name from the file name.  How can I access this property?

Thanks,

cannorth 

mohnston

  • Bull Frog
  • Posts: 305
  • CAD Programmer
It's amazing what you can do when you don't know what you can't do.
CAD Programming Solutions

Jeff H

  • Needs a day job
  • Posts: 6150
Re: What's a good way to distinguish a block reference object?
« Reply #5 on: August 14, 2013, 02:37:41 PM »
Did Tony's explanation and example not help?
http://www.theswamp.org/index.php?topic=41720.msg468319#msg468319
 
Also I think you are looking at the  Entity.BlockName property.
That just returns an entities Owner's name.
Remember ModelSpace and Paperspace  are BlockTableRecords just like any other block but contain actual layout objects instead of being empty for blocks you create.
 
So unless you are looking at the BlockName property for entities contained inside BlockTableRecords that are created by users then the BlockName will always be Model, or a paperspace BlockTableRecord.
 
 
When looking at BlockReference its BlockName will be which BlockTableRecord it is contained in.
A BlockReference pushes different transformation matrixes into graphic pipeline that pertain to its info about position, scaling, rotation, etc...
 
So a BlockReference tells its owner(Blockname = owner name = Model or paper(unless a nested block))
to ask another BlockTableRecord to draw the entities it Owns with transformation applied to them.
 
Since it does that BlockReferences could only differ by scale factors, rotation, position, that are drawn from same BlockTableRecord.
 
So a BlockReference always tells its owner to use the BlockTableRecord  to draw it at the location of its BlockTableRecordId.
The BlockTableRecord at the location of its DynamicBlockTableRecordId are the same unless it contains parameters and actions that have been invoked to modify the BlockReference.
If so it then creates a new BlockTableRecord and modifies entities inside it to represent the changed parameters or actions invoked, which will be the BlockTableRecord at AnonymousBlockTableRecordId and its BlockTableRecordId wild be the same as anonymous one.
 
In short
-Block name will be its owner
-The BTR at DynamicBlockTableRecordId  location modifies entities inside it the AnonymousBlocktableRecord and will create it for first modify
-The BTR at AnonymousBlocktableRecord location is for a different representation of the BTR DynamicBlockTableRecordId location.
-The BTR at BlockTableRecordId will either point to the same location as Dynamic or anonymous one and the owner will draw the one it points to.
 
 
If I understand your question correctly the answer and extension method Tony provided should be your solution.
« Last Edit: August 14, 2013, 02:42:56 PM by Jeff H »

cannorth

  • Guest
Re: What's a good way to distinguish a block reference object?
« Reply #6 on: August 16, 2013, 06:18:03 PM »
For both dynamic block and regular blocks, the solution I came up with is the ObjectID's handle property of the blockreference. 

Thanks,

cannorth

fixo

  • Guest
Re: What's a good way to distinguish a block reference object?
« Reply #7 on: August 17, 2013, 08:23:26 AM »
Just for fun, insert any dynamic block,
set scale to be non-uniform (say 0.1,0.1,1.0) then try return block name,
if you'd double clicked on this block then you will be see
in the window its exact name :)
I could not resolve it with suggested methods above at all