Jump to content

Recommended Posts

Posted

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!

Posted

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)
)

Posted
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

 

I does, our plot setup use color for lineweight. Often I force color on objects.

 

Thanks I'll check it out

Posted

OK...so maybe you do. Do your colleagues know all the color numbers?

 

Does it make sense to override layer colors?

Posted
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)
)

 

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! :D

Posted

I'd look into (acad_colordlg )

 

-David

Posted
OK...so maybe you do. Do your colleagues know all the color numbers?

 

Does it make sense to override layer colors?

 

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!

Posted

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

Posted
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! :D

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 [1-255] ( "
                                 (itoa c)
                                 " ) : "
                         )
                 )
                )
                (t c)
              )
           )
           255
        )
   )
    (princ "\n Number of color must be between [1-255] ")
 )
 (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)
)

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

 

And double or triple how many layers ?

 

Not.

Posted
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 [1-255] ( "
                                 (itoa c)
                                 " ) : "
                         )
                 )
                )
                (t c)
              )
           )
           255
        )
   )
    (princ "\n Number of color must be between [1-255] ")
 )
 (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)
)

 

Yes! Can I do something to open the pop up color menu if don't remember the color#?

 

Could be :

 

Specify color between [1-255] or Select Color :

 

Thanks

Posted

All my "hidden" lines go on one layer called, strangely enough, Hidden. If you were do the drawing on a drafting board would you use different colors for all the hidden lines? Would a hidden line depicting a wall that was obscured be shown any different than a hidden line depicting another object? Sometimes we go out of our way to make things difficult. Do you plot in color as well?

Posted
Yes! Can I do something to open the pop up color menu if don't remember the color#?

 

Could be :

 

Specify color between [1-255] or Select Color :

 

Thanks

Yes, it should be possible to do this. A simple approach would be to change the current color via COLOR, then CHANGE the Property Color to the current value (CECOLOR).

Posted

For anyone who wanders in, this was the basic idea I was talking about. It allows just the standard colors 1 through 255 (no ByBlock or ByLayer). Note that the system variable CECOLOR is a string.

 

(defun C:CHC (/ ColorObjects CurrColorOrg NewColor CmdEchoOrg)
 (prompt "\nSelect objects to color...")
 (cond
   ( (setq ColorObjects (ssget))
     (setq CurrColorOrg (getvar 'CECOLOR)
           CmdEchoOrg   (getvar 'CMDECHO)
     )
     (setvar 'CMDECHO 0)    
     (while
       (not (cond
       ( (initget 6) )   
           ( (setq NewColor (getint
               "\nEnter object color (1-255) <dialog>: "
             )              )
             (if (< NewColor 256) (setvar 'CECOLOR (itoa NewColor)))
           )
           (T(initdia)
             (command "_.COLOR")
             (numberp (read (getvar 'CECOLOR)))
           )                                  
       )    )
       (prompt "\nCannot set color to that value.\n*Invalid.*")  
     )  
     (command "_.CHANGE" ColorObjects "" "_P" "_C" (getvar 'CECOLOR) "") 
 ) )
 (setvar 'CECOLOR CurrColorOrg)
 (setvar 'CMDECHO CmdEchoOrg)      
 (princ)
)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...