Jump to content

lisp to set color to bylayer and...


jim78b

Recommended Posts

i want a lisp to set property color to bylayer through command line example digit :bl (bylayer)and bk (byblock)

and for linetype i want digit for bylayer lb and for byblock lk is possible? thanks

Link to comment
Share on other sites

Your request is kind of vague, but give this quickie a try. Does not do nested items.

(defun _foo (c / s)
  (if (setq s (ssget ":L"))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (entmod (append (entget e) (list (cons 62 c))))
    )
  )
  (princ)
)
(defun c:bl nil (_foo 256))
(defun c:bk nil (_foo 0))
(setq a 0)
;; Create c:b1 thru c:b255 for $h!+s :)
(repeat 255 (eval (read (strcat "(defun c:b" (itoa (setq a (1+ a))) " nil (_foo " (itoa a) "))"))))

 

Edited by ronjonp
Link to comment
Share on other sites

(defun C:CBL () (COMMAND "CHANGE" PAUSE "" "P" "C" "BYLAYER" "")
(PROMPT "nCOLOR CHANGED TO BYLAYER."))
 

(defun C:LTBL () (COMMAND "CHANGE" PAUSE "" "P" "LT" "BYLAYER" "")
(PROMPT "nLINETYPE CHANGED TO BYLAYER."))
 

(defun C:PS ()       ;Pick entity to set layer
    (setvar "CMDECHO" 0)

    (setq EN (car (entsel "\nPick any entity to set the layer..: ")))
    (setq ED (entget EN))
    (setq LN (cdr (assoc 8 ED )))
    (command "LAYER" "S" LN "")
    (princ)
    )

 

Edited by Jman
Link to comment
Share on other sites

10 hours ago, ronjonp said:

Your request is kind of vague, but give this quickie a try. Does not do nested items.


(defun _foo (c / s)
  (if (setq s (ssget ":L"))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (entmod (append (entget e) (list (cons 62 c))))
    )
  )
  (princ)
)
(defun c:bl nil (_foo 256))
(defun c:bk nil (_foo 0))
(setq a 0)
;; Create c:b1 thru c:b255 for $h!+s :)
(repeat 255 (eval (read (strcat "(defun c:b" (itoa (setq a (1+ a))) " nil (_foo " (itoa a) "))"))))

 

i want only  when i write bk or bl the state of color or layer change in byblock or bylayer and not select an object ...

Link to comment
Share on other sites

What I use:

(defun c:bys nil
  (mapcar 'setvar '(CECOLOR CELTYPE CELWEIGHT) '("BYLAYER" "BYLAYER" -1))
  (vl-cmdf "_.regen")
  (princ)
  ) (vl-load-com)

 

  • Like 1
Link to comment
Share on other sites

7 hours ago, jim78b said:

i want only  when i write bk or bl the state of color or layer change in byblock or bylayer and not select an object ...

As Tharwat eluded to:

(defun c:bl nil (setvar 'cecolor "ByLayer"))
(defun c:bk nil (setvar 'cecolor "ByBlock"))

 

  • Like 1
Link to comment
Share on other sites

2 hours ago, ronjonp said:

As Tharwat eluded to:


(defun c:bl nil (setvar 'cecolor "ByLayer"))
(defun c:bk nil (setvar 'cecolor "ByBlock"))

 

you are the best very thanks!! i make another lisp for linetype:

(defun c:ll nil (setvar 'celtype "ByLayer"))
(defun c:lk nil (setvar 'celtype "ByBlock"))

thanks! to everyone

Link to comment
Share on other sites

HELLO your code is ok but i need a modify please, when i select multiple object that are set on bylayer and type the command example bk the object not change to byblock...

Link to comment
Share on other sites

On 5/19/2019 at 2:29 AM, jim78b said:

HELLO your code is ok but i need a modify please, when i select multiple object that are set on bylayer and type the command example bk the object not change to byblock...

I'm confused. 🤔 

The code above does not do anything to existing objects. It changes the 'cecolor' variable so that new items added to the drawing will take on either bylayer or byblock properties depending on which you run.

Link to comment
Share on other sites

32 minutes ago, jim78b said:

SORRY can you even  make that do that?!

Already wrote that HERE. As stated before does not do nested items.

Link to comment
Share on other sites

Quote

 

sorry but I want that when I have an element selected from the keyboard I type for example bk or bl and the type of color or line changes

Link to comment
Share on other sites

6 minutes ago, jim78b said:

sorry but I want that when I have an element selected from the keyboard I type for example bk or bl and the type of color or line changes

Sorry, I cannot help you.

Link to comment
Share on other sites

jim78b

   i wrote my 2 lisp routines to change existing lines that people changed the color or line type but not the layer . it put them on the correct color or line type for the

  layer you want to use.

  I threw in pick set just for fun.  I use those lisp routines daily. It doesn't change everything globally

Link to comment
Share on other sites

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