Author Topic: Change color of circles based on Visibility  (Read 1251 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
Change color of circles based on Visibility
« on: October 26, 2020, 07:32:15 AM »
Hello guys.

I have a dynamic block with visibility state that it has 20 states ("10x20" "10x30" "20x20" ... etc ) so I want to change the color of Polylines that reside into certain visibility states and not ALL and for example  these only. ( "10x30" "20x20" )

How can I do that ?

I tried with vlax-for and

Code: [Select]

      (command "-bedit" bn)

      (if (setq ss (ssget "_X" '((0 . "LWPOLYLINE"))))
        (repeat (setq sslen (sslength ss))
          (setq obj (ssname ss (setq sslen (1- sslen))))
          (vla-put-color (vlax-ename->vla-object obj) 3)
        )
      )

      (command "_bclose" "")
 

Both change all polylines and not polylines in specific visibility state.

Any idea ?

Thanks in advance.

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: Change color of circles based on Visibility
« Reply #1 on: October 26, 2020, 12:58:39 PM »
I think I misunderstood the request the first time, so I removed my answer.

I hope it's better now

Code - Auto/Visual Lisp: [Select]
  1. ;(<visibility_name> . <color>)
  2. (setq lst '(("10x20" . 1) ("10x30" . 2) ("20x20" . 3)))
  3.  
  4. (command "_bedit" bn)
  5. (if (setq ss (ssget "_X" '((0 . "LWPOLYLINE"))))
  6.   (progn
  7.     (setvar 'bvmode 0)
  8.     (foreach state lst
  9.       (command "_-bvstate" "_s" (car state))
  10.       (repeat (setq sslen (sslength ss))
  11.         (setq obj (vlax-ename->vla-object (ssname ss (setq sslen (1- sslen)))))
  12.         (if
  13.           (eq (vla-get-visible obj) :vlax-true)
  14.           (vla-put-color  obj (cdr state))
  15.         )
  16.       )
  17.     )
  18.   )
  19. )
  20. (command "_bsave" "_bclose")

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Change color of circles based on Visibility
« Reply #2 on: October 26, 2020, 01:12:26 PM »
Your thread title has change color of circles but your question is for polylines? :?

@Stefan .. that's pretty slick  8-)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Coder

  • Swamp Rat
  • Posts: 827
Re: Change color of circles based on Visibility
« Reply #3 on: October 26, 2020, 01:14:43 PM »
Wow its great.  :smitten:

Thank you so much.

Coder

  • Swamp Rat
  • Posts: 827
Re: Change color of circles based on Visibility
« Reply #4 on: October 26, 2020, 01:17:40 PM »
Your thread title has change color of circles but your question is for polylines? :?
Sorry for this confusion, had a very busy day.

@Stefan .. that's pretty slick  8-)

Definitely.