ydilday Posted December 24, 2021 Posted December 24, 2021 (defun c:layercolor1 (/ c d e n) ;; RJP » 2019-03-19 ;; Set layer color by pick (or (getenv "clc") (setenv "clc" "(62 . 1)")) (cond ((setq c (acad_truecolordlg (read (getenv "clc")))) (setenv "clc" (vl-prin1-to-string (last c))) (setq d (vla-get-activedocument (vlax-get-acad-object))) (while (setq e (car (nentsel "\nSelect entity to change layer color: "))) (entmod (append (entget (tblobjname "layer" (cdr (assoc 8 (entget e))))) c)) (vla-regen d acactiveviewport) ) ) ) (princ) ) (vl-load-com) I found this LISP routine the other day to allow object to be selected and the object's layer color to be changed. After loading it into my AutoCAD Civil3d 2019 it appeared to work fine. Once I restarted my virtual machine it no longer works and I receive the following error "Application ERROR: Bad arguments.". Unsure what is causing the issue as the LIST routine still works on AutoCAD 2019 on my machine and works on other peoples machine. Did I reset a variable that is causing the LISP to no longer work? Thanks for the help. Still learning how to develop and troubleshoot LISP routines, so any help is appreciated. Quote
Steven P Posted December 24, 2021 Posted December 24, 2021 Not sure if this helps, occassionally when I have LISPs not running unexpectedly it is all of them, so have you tried to run another LISP on the virtual machine and what happens? You could go to appload and reload the LISP you want to use and see if this helps. Not a good fix butfor the number of times ithappens to me I can live with that.I suspect it is something to do with my profile Quote
mhupp Posted December 24, 2021 Posted December 24, 2021 Being a virtual machine I'm curious how all the registry variables are acting. Might want to switch over to Ldata (saved locally in drawing) rather then in the registry. (defun c:layercolor2 (/ clc c doc e) (vl-load-com) ;; RJP » 2019-03-19 ;; Set layer color by pick (setq clc (vlax-ldata-get "obj" "color")) ;checks for ldata and sets the variable (if (= clc nil) (setq clc (cons 62 1))) (cond ((setq c (acad_truecolordlg clc)) (setq clc (last c)) (vlax-ldata-put "obj" "color" clc) ;Saves value to drawing (setq doc (vla-get-activedocument (vlax-get-acad-object))) (while (setq e (car (nentsel "\nSelect entity to change layer color: "))) (entmod (append (entget (tblobjname "layer" (cdr (assoc 8 (entget e))))) c)) (vla-regen doc acactiveviewport) ) ) ) (princ) ) Quote
ydilday Posted December 24, 2021 Author Posted December 24, 2021 18 minutes ago, mhupp said: Being a virtual machine I'm curious how all the registry variables are acting. Might want to switch over to Ldata (saved locally in drawing) rather then in the registry. (defun c:layercolor2 (/ clc c doc e) (vl-load-com) ;; RJP » 2019-03-19 ;; Set layer color by pick (setq clc (vlax-ldata-get "obj" "color")) ;checks for ldata and sets the variable (if (= clc nil) (setq clc (cons 62 1))) (cond ((setq c (acad_truecolordlg clc)) (setq clc (last c)) (vlax-ldata-put "obj" "color" clc) ;Saves value to drawing (setq doc (vla-get-activedocument (vlax-get-acad-object))) (while (setq e (car (nentsel "\nSelect entity to change layer color: "))) (entmod (append (entget (tblobjname "layer" (cdr (assoc 8 (entget e))))) c)) (vla-regen doc acactiveviewport) ) ) ) (princ) ) I believe it did not stop working until I restarted my machine. All my other LISPs have worked fine for a while now. How would one switch over to Ldata? Quote
ydilday Posted December 24, 2021 Author Posted December 24, 2021 2 hours ago, Steven P said: Not sure if this helps, occassionally when I have LISPs not running unexpectedly it is all of them, so have you tried to run another LISP on the virtual machine and what happens? You could go to appload and reload the LISP you want to use and see if this helps. Not a good fix butfor the number of times ithappens to me I can live with that.I suspect it is something to do with my profile None of my other LISP routines have had any issues for a few weeks now. I have reloaded/renamed/changed the command shortcut multiple times to no avail. Quote
mhupp Posted December 24, 2021 Posted December 24, 2021 11 minutes ago, ydilday said: How would one switch over to Ldata? The lisp I posted is converted. Quote
ydilday Posted December 24, 2021 Author Posted December 24, 2021 2 minutes ago, mhupp said: The lisp I posted is converted. Duh. Thank you, that is working now. Well try a restart and see what happens. Quote
BIGAL Posted December 24, 2021 Posted December 24, 2021 Why (setenv (62 . 1) red is color 1 (acad_truecolordlg 1) works fine so why not just save a single number. Just change the entmod to include (cons 61 color). Quote
Recommended Posts
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.