"Highlight" polyline in block references

"Highlight" polyline in block references

SRSDS
Advisor Advisor
2,452 Views
13 Replies
Message 1 of 14

"Highlight" polyline in block references

SRSDS
Advisor
Advisor

I don't think this is possible but I'll ask anyway.

By "highlighting" I mean changing the width of polylines within a block.

 

At the moment I am doing this by setting the polylines lineweight set to "ByBlock" and changing the BlockReferences lineweight. This isn't ideal as I need to turn on LWDISPLAY which thinkens all lines in the drawing that have lineweights.

 

Is it possible to change the ConstantWidth property of polylines within specific BlockReferences?

I'm guessing that you can only modify the BlockTableRecord which would change the thicknesses of all BlockReferences under the BlockTableRecord.

 

 

 

0 Likes
Accepted solutions (1)
2,453 Views
13 Replies
Replies (13)
Message 2 of 14

GeeHaa
Collaborator
Collaborator

You could probably do it with a dynamic block and visibility states

0 Likes
Message 3 of 14

SRSDS
Advisor
Advisor

Thanks for the super fast reply. Great idea, if it weren't for my situation I think.

I have many very complicated blocks using many geometric and dimensional constraints. 

I'd need to duplicate all the polylines, reconstrain them, then constrain them against the existing polylines.

Which would be hard.

 

 

0 Likes
Message 4 of 14

SRSDS
Advisor
Advisor

Sorry.. Copying and pasting isn't hard and doesn't remove constraints.

I'd just need to constrain points from the old to the new. Maybe that is the answer!

0 Likes
Message 5 of 14

norman.yuan
Mentor
Mentor

Well, in most cases "highlight" is used as temporary visual hint for CAD user. So, depending on when/how long you want the entity be highlighted, you can consider to use TransientGraphics to draw the polyline with certain global width on top the polyline seen in the block reference, and remove it for unhighlight. That is:

 

1. identify the polyline in the blocktablerecord;

2. clone the identified polyline;

3. transform the cloned polyline with the blockreference's transform;

4. use the cloned polyline as drawable to draw transient graphics;

5. when its time to unhighlight, erase the transient graphics;

6. dispose the cloned polyline.

 

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 6 of 14

SRSDS
Advisor
Advisor

Hi Norman.

After years I appear to know very little.

The block has visibility states. How do I identify visible polylines.

Sadly I don’t know where to go without asking for code examples of all your steps.

0 Likes
Message 7 of 14

Alexander.Rivilis
Mentor
Mentor

@SRSDS 

Any Entity (and Polyline also) has property Visible. If Polyline in this visibility state of BlockReference is invisible - so it's property Visible is false in correspondent BlockTableRecord.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 8 of 14

Alexander.Rivilis
Mentor
Mentor

Other way is: https://adndevblog.typepad.com/autocad/2012/05/accessing-visible-entities-in-a-dynamic-block.html

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 9 of 14

norman.yuan
Mentor
Mentor

Visibility state is dynamic block's property. You said dynamic block would not be your desired solution, that is why I proposed TransientGraphics solution.

 

If Visibility State meets your need, it is just a simple task to design the block with a thicker polyline with desired highlight color being hidden in normal use; and turn the Visibility State on when highlight is needed. By code, you do not need to identify the "highlight polyline" that can be turned off/on, the code only needs to loop through all dynamic properties by property name, when found, change the property value accordingly. Of course user can also manually flip the Visibility state.

 

If you only want the highlight shown during certain process (of your code), Transient graphics might be better choice, because you do not want user accidently turn on the undesired highlight and forgot to turn it off.

 

You might want to explain why/when/how you want part of a blockrefernce be highlighted. In the meanwhile, I might see if I have time to put together some code to demonstrate TransientGraphics for highlighting partial of BlockReference

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 10 of 14

norman.yuan
Mentor
Mentor
Accepted solution

OK, I went ahead to write some code for this. As usual, for better readability/presentation, I publish it in my blog here:

 

https://drive-cad-with-code.blogspot.com/2021/03/highlight-entity-in-block.html 

 

No sure whether it is you are looking for, but at least it is an idea to your request.

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 11 of 14

SRSDS
Advisor
Advisor

Linetype and color I can handle. The line thickness is what I think stands out as a highlight.

See attached. Is this possible?

0 Likes
Message 12 of 14

SRSDS
Advisor
Advisor

Sorry.. It probably is.

Not thinking and time to go to sleep.

Thank you so much.

0 Likes
Message 13 of 14

SRSDS
Advisor
Advisor

Norman,

I really need to learn C#. Just gotten around to implementing this.

I copied the code from your blog to https://converter.telerik.com/ and it doesn't like it. 

Any chance you could help me understand what the problem might be?

 

 

0 Likes
Message 14 of 14

norman.yuan
Mentor
Mentor

@SRSDS ,

I updated my article with the same code of VB.NET version, which I also used Terelik's online converter, which could not recognize the IDisposable.Dispose() implementing: that is the only thing you need to manually fix it (you can see the code in my article).

HTH.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes