Change back color ar lineweight to "by layer"

Change back color ar lineweight to "by layer"

Angelswing91
Contributor Contributor
901 Views
4 Replies
Message 1 of 5

Change back color ar lineweight to "by layer"

Angelswing91
Contributor
Contributor

Hi all, 

i tried to modificate this code by adding color and lineweight

 

(vl-load-com)
(defun C:CPV (/ ss i pl n); = Circles at Polyline Vertices
(if (setq ss (ssget '((0 . "LWPOLYLINE"))))
(repeat (setq i (sslength ss)); then
(setq pl (ssname ss (setq i (1- i))))
(repeat (setq n (cdr (assoc 90 (entget pl))))
(command "color" 3 "lweight" 0.3 "_.circle" (vlax-curve-getPointAtParam pl (setq n (1- n))) 0.8)
); repeat [vertices]
); repeat [Polylines]

); if
); defun

But after this command, on current layer it leaves selected color and lineweight, it is possible make it set back to by layer after this lisp?

0 Likes
Accepted solutions (1)
902 Views
4 Replies
Replies (4)
Message 2 of 5

CodeDing
Advisor
Advisor
Accepted solution

@Angelswing91 ,

 

I made some edits, but this way is faster when used and will not fill up your command history with a bunch of nonsense that we don;t need the user to see.

(defun c:CPV ( / ss osm pl i j)
;helper function
  (defun CPV_Circle (cen rad clr lwt)
    (entmakex (list '(0 . "CIRCLE") (cons 10 cen) (cons 40 rad)
		    (cons 62 clr) (cons 370 (fix (* 100 lwt)))))
  );defun
(if (setq ss (ssget '((0 . "LWPOLYLINE"))))
  (progn
    (setq osm (getvar 'OSMODE)) (setvar 'OSMODE (logior 16384 osm))
    (repeat (setq i (sslength ss))
      (setq pl (ssname ss (setq i (1- i))))
      (repeat (setq j (cdr (assoc 90 (entget pl))))
	(CPV_Circle (vlax-curve-getPointAtParam pl (setq j (1- j))) 0.8 3 0.3)
      );repeat
    );repeat
    (setvar 'OSMODE osm)
  );progn
);if
(prompt "CPV Complete.")
(princ)
);defun

If you want to stick with your method, you should change it to something like this. You were close but we needed to create the circle first:

(repeat (setq n (cdr (assoc 90 (entget pl))))
  (command  "_.circle" (vlax-curve-getPointAtParam pl (setq n (1- n))) 0.8)
  (command "_.CHPROP" (entlast) "" "color" 3 "lweight" 0.3 "")
); repeat [vertices]

Best,

~DD

0 Likes
Message 3 of 5

Sea-Haven
Mentor
Mentor

What about using (setvar 'cecolor 3) and line width rather than hard coding in your cpv and at end (setvar 'cecolor 256)

Message 4 of 5

ВeekeeCZ
Consultant
Consultant

Perhaps just like this would be enough.

 

(defun c:CPV ( / s i p)
  (if (setq s (ssget '((0 . "LWPOLYLINE"))))
    (repeat (setq i (sslength s))
      (foreach p (entget (ssname s (setq i (1- i))))
	(if (= (car p) 10)
	  (entmake (list '(0 . "CIRCLE") p '(40 . 0.8)))))))
  (princ)
 )

 

 
0 Likes
Message 5 of 5

Kent1Cooper
Consultant
Consultant

@Angelswing91 wrote:

.... color and lineweight, it is possible make it set back to by layer after this lisp?


Directly as A minimal adjustment to yours, if you like, just do exactly that after drawing the Circle, in the same way that you changed them:

....

  (repeat (setq n (cdr (assoc 90 (entget pl))))
  (command

    "color" 3 "lweight" 0.3

    "_.circle" (vlax-curve-getPointAtParam pl (setq n (1- n))) 0.8

    "color" "BYLAYER" "lweight" "BYLAYER"

  ); command
  ); repeat [vertices]

....

Kent Cooper, AIA
0 Likes