Jump to content
jim78b

lisp to set color to bylayer and...

Recommended Posts

jim78b

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

Share this post


Link to post
Share on other sites
ronjonp
Posted (edited)

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

Share this post


Link to post
Share on other sites
Jman
Posted (edited)

(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

Share this post


Link to post
Share on other sites
BIGAL

Explain more guesses are being made. Have not transferred the crystal ball to my new laptop yet.

Share this post


Link to post
Share on other sites
jim78b
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 ...

Share this post


Link to post
Share on other sites
Tharwat

What I use:

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

 

  • Like 1

Share this post


Link to post
Share on other sites
ronjonp
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

Share this post


Link to post
Share on other sites
Jman
Posted (edited)

That works

Edited by Jman

Share this post


Link to post
Share on other sites
jim78b
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

Share this post


Link to post
Share on other sites
jim78b

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

Share this post


Link to post
Share on other sites
ronjonp
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.

Share this post


Link to post
Share on other sites
jim78b

SORRY can you even  make that do that?!

Share this post


Link to post
Share on other sites
ronjonp
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.

Share this post


Link to post
Share on other sites
jim78b
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

Share this post


Link to post
Share on other sites
ronjonp
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.

Share this post


Link to post
Share on other sites
jim78b

Thanks 

Share this post


Link to post
Share on other sites
Jman

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

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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