Troispistols 发表于 2022-7-6 05:25:00

Selected Objects to color# LIS

Hi guys i'm trying to figure out how to make this lisp and I'm just not able to get it done
 
I would like a lisp to do this by launching "CHC"
 
- Select objects (or objects could be already selected when launching the CHC lisp)
 
- Question asked: "Which color ?" (answering a color number)
 
- If number is 256 or more (its wrong) and the question has to be reasked to get a number between 1 and 255.
 
-Change selection set to the color# answered
 
I've try this but it doesnt work :
 

(defun c:chc ( / obj col#)(setq cmdecho 0)(setq obj (ssget))(setq col# (getint "\nQuelle couleur ? : "))(if (< col# 255) (setq col# (getint "\nQuelle couleur ? : " (command "change" obj "" "properties" "color" col# ""))))(princ))
 
Thanks!

ReMark 发表于 2022-7-6 05:33:11

How many people know what color is associated with what color number?
 
Lee Mac came up with this lisp routine for another thread where a similar question was asked.
 
http://www.cadtutor.net/forum/showthread.php?43839-Lisp-to-change-all-objects-with-a-certain-color-to-another-color

Tharwat 发表于 2022-7-6 05:37:48

Try it this way instead .
 

(defun c:chc (/ c s i e) (if (and (setq c (acad_colordlg 256))          (progn (princ "\n Select object to change thei colors ")               (setq s (ssget "_:L"))          )   )   (repeat (setq i (sslength s))   (setq e (entget (ssname s (setq i (1- i)))))   (entmod (append e (list (cons 62 c))))   ) ) (princ))

Troispistols 发表于 2022-7-6 05:39:19

 
I does, our plot setup use color for lineweight. Often I force color on objects.
 
Thanks I'll check it out

ReMark 发表于 2022-7-6 05:42:32

OK...so maybe you do.Do your colleagues know all the color numbers?
 
Does it make sense to override layer colors?

Troispistols 发表于 2022-7-6 05:49:40

 
Great, can you make that I can type number instead and add the option for the pop up by typing "C" for if I don't remeber my color number?
If not, I'll take it like this.
Great work
Thanks a lot for the fast answers!

David Bethel 发表于 2022-7-6 05:53:51

I'd look into (acad_colordlg )
 
-David

Troispistols 发表于 2022-7-6 05:58:58

 
They do. We have a chart and for a specific lineweight, we have ±2 color number. Steps of ±0.1.
 
It makes sense for us to override layer colors for hidden parts that we have to see thinner. Not everything is forced in the drawing!

ReMark 发表于 2022-7-6 06:02:44

Wouldn't it make more sense to have a layer called Hidden with an assigned color like grey for example?

Tharwat 发表于 2022-7-6 06:05:16

This... ?
 

(defun c:chc (/ s i e) (if (not c)   (setq c 1) ) (while   (not (< 0         (setq             c            (cond                ((getint (strcat "\n Specify color between ( "                                 (itoa c)                                 " ) : "                         )               )                )                (t c)            )         )         255      )   )    (princ "\n Number of color must be between ") ) (if   (and   c   (progn (princ "\n Select object to change thei colors ")            (setq s (ssget "_:L"))   )   )    (repeat (setq i (sslength s))      (setq e (entget (ssname s (setq i (1- i)))))      (entmod (append e (list (cons 62 c))))    ) ) (princ))
页: [1] 2
查看完整版本: Selected Objects to color# LIS