Posted by
Rallaz on
Dec 20, 2012; 7:14pm
URL: https://forum.librecad.org/How-could-I-fetch-the-block-and-entity-information-tp5707314p5707318.html
Hi Johnson,
by parts...
Johnson wrote
I will use block name such as "159-124...." to find the block. is it reasonable ?
Is Ok, I do not see any problem.
Johnson wrote
another question is that if the colors of rect is changed , the near line color will be changed. do you know how to check whether the line touch the rect or not ?
Ckecking Xline - Xinsert < 1e5 etc. is easy. The problem is that access to the boundary of "block definition" is not implemented in plugins (you can implement it and send a patch :-) )
Johnson wrote
change the color of the blocks(actually it's just a entity container , I might change the color of the four line and a text together. do you know how to change the color of block rather than change the color of each individual )
A "block" (block definition) is the same as a document or drawing (entity container)
A "insert" is a entity, a reference to "block" (block definition)
when you add a block in the drawing you are adding an "insertion" (like a C pointer)
If you change the color of the entities which form the block, then all inserts change =>BAD
A "insert" is a entity with color, linetype etc. if you change the color of the "insert" only
this "insert" change the color => GOOD
The problem (and the solution) is
On draw a "insert" the sequence are:
red insert -> black line in "block" -> draw a black line
red insert -> bylayer line in "block" -> line in yelow layer -> draw a yelow line
red insert -> byblock line in "block" -> insert is red -> draw a red line
and...
bylayer insert -> byblock line in "block" -> insert in blue layer -> draw a blue line
That is, a powerful "block definition" have all the entities in layer 0 & color, linetype & width "byblock"
Attached a dxf to demostrate.
check "sameprop plugin" (Edit->Same properties) this plugin changes layer, color, linetype & width.
Rallaz