i have a small lisp and i would like for it to:
(command "undefine" "plot")
(defun c:plot ()
(if (layerstate-has "Temp")
(layerstate-delete “Temp”)
)
(command "Layer" "A" "S" "Temp" "" "" "")
(command "Layer" "A" "R" "plot" "" "" "")
(command ".plot" "Yes" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "")
(command "Layer" "A" "R" "Temp" "" "" "")
(graphscr)
(princ)
)
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
sorry for the "accidental" smiley, it should be
(defun c "colon sign" plot ()
@youngPE wrote:
sorry for the "accidental" smiley, it should be
(defun c "colon sign" plot ()
If you use the Code tags you don't get the smiley's 🙂
(command "undefine" "plot") (defun c:plot () (if (layerstate-has "Temp") (layerstate-delete “Temp”) ) (command "Layer" "A" "S" "Temp" "" "" "") (command "Layer" "A" "R" "plot" "" "" "") (command ".plot" "Yes" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "") (command "Layer" "A" "R" "Temp" "" "" "") (graphscr) (princ) )
@youngPE wrote:
thanks for the tip Jeff. any suggestions on how to make the code run?
I was working on that...this will delete the TEMP Layerstate if it exists:
(vl-load-com) (setq lays (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))) (if (vla-get-hasextensiondictionary lays :vlax-true) (progn (setq exdict (vla-getextensiondictionary lays)) (setq dict (vla-item exdict "ACAD_LAYERSTATES")) (vlax-for xrec dict (if (eq (strcase (vla-get-name xrec)) "TEMP") (vla-delete xrec) ) )
youngPE,
perhaps something like
(command "undefine" "plot") (defun c:plot () (if (layerstate-has "Temp") (layerstate-delete "Temp") ) (command "-Layer" "A" "S" "Temp" "" "" "");; changed to commandline version (command "-Layer" "A" "R" "plot" "" "" "");; changed to commandline version (command "-plot" "Yes" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "");; changed to commandline version (command "-Layer" "A" "R" "Temp" "" "" "");; changed to commandline version (graphscr) (princ) )
should work well, I do not know if the number of enters in the plot command is correct or not, you have to test it.
Henrique
Jeff,
i merged what you gave with what i had (added two extra parantheses at the end of yours), loads fine, but gives me an error as:
Command: plot
; error: Too many actual parameters
i must be doing something dumb here, but cannot figure out what. do you have any ideas? merged code is below:
(command "undefine" "plot")
(defun c:plot ()
(vl-load-com)
(setq lays (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))))
(if (vla-get-hasextensiondictionary lays :vlax-true)
(progn
(setq exdict (vla-getextensiondictionary lays))
(setq dict (vla-item exdict "ACAD_LAYERSTATES"))
(vlax-for xrec dict
(if (eq (strcase (vla-get-name xrec)) "TEMP")
(vla-delete xrec)
)
)
)
)
(command "Layer" "A" "S" "Temp" "" "" "")
(command "Layer" "A" "R" "plot" "" "" "")
(command ".plot" "Yes" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "")
(command "Layer" "A" "R" "Temp" "" "" "")
(graphscr)
(princ)
)
Henrique,
yours seem to work very well! i didnt expect that going to the command line version would make the difference, thanks!
youngPE,
in my previous post, I forgot to redefine the plot command,
You should receive an error such as;
Command: PLOT Unknown command "PLOT". Press F1 for help.
(command "undefine" "plot") (defun c:plot () (if (layerstate-has "Temp") (layerstate-delete "Temp") ) (command "-Layer" "A" "S" "Temp" "" "" "");; changed to commandline version (command "-Layer" "A" "R" "plot" "" "" "");; changed to commandline version (command "_redefine" "plot");; restores the plot command (command "-plot" "Yes" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "");; changed to commandline version (command "-Layer" "A" "R" "Temp" "" "" "");; changed to commandline version (graphscr) (princ) )
Henrique
@youngPE wrote:sorry for the "accidental" smiley, it should be
(defun c "colon sign" plot ()
[Another way to avoid smileys: see the instructions at the top of this thread. But when you know you're using a colon-and-letter combination that triggers some smiley [see the list there], using a code window will prevent the smiley for others who aren't signed in, or for those who are but who don't have them turned off. (There was a time when even a code window didn't prevent it, but that's no longer a problem.)]
no worries Jeff, I have personally always learned something new from you every time you have replied to my questions. thanks again for sharing all the knowledge!