nj1105nj Posted February 8, 2020 Posted February 8, 2020 Hello all. Here is my current lisp, which seems to be not working. I'm not very experienced in Autolisp, so I'm not sure what's causing it to not work. Any help would be appreciated! Thank you all. The lisp is supposed to insert a block, change the layer, and then set the xyz to the shown values, and then roation to zero. I'm not sure what's wrong with it, but I copied some old examples to get here and I had it working up until I added everything with the layers. (defun C:pp (/ lyr lyr1) (setq lyr (getvar "clayer")) (setq lyr1 (tblsearch "layer" "e-pole")) (if (= lyr1 nil) "")) (command "-layer" "set" "e-pole" "") (command "insert" "-ex pole" pause "xyz" 1. 1. 1. "0") (setvar "clayer" lyr) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun C:gw (/ lyr lyr1) (setq lyr (getvar "clayer")) (setq lyr1 (tblsearch "layer" "e-guywire")) (if (= lyr1 nil) "")) (command "-layer" "set" "e-guywire" "") (command "insert" "A$Cdf075535" pause "xyz" 1. 1. 1. "0")) (setvar "clayer" lyr) ) (princ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun C:fh (/ lyr lyr1) (setq lyr (getvar "clayer")) (setq lyr1 (tblsearch "layer" "0")) (if (= lyr1 nil) "")) (command "-layer" "set" "0" "") (command "insert" "A$Ca0c81eb2" pause "xyz" 1. 1. 1. "0") (setvar "clayer" lyr) ) (princ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun C:tree (/ lyr lyr1) (setq lyr (getvar "clayer")) (setq lyr1 (tblsearch "layer" "e-tree")) (if (= lyr1 nil) "")) (command "-layer" "set" "e-tree" "") (command "insert" "TREE-Standard" pause "xyz" 72. 72. 72. "0")) (setvar "clayer" lyr) ) (princ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun C:cb (/ lyr lyr1) (setq lyr (getvar "clayer")) (setq lyr1 (tblsearch "layer" "e-storm-sewer")) (if (= lyr1 nil) "")) (command "-layer" "set" "e-storm-sewer" "") (command "insert" "STM-CB-Square" pause "xyz" 4. 4. 4. "0")) (setvar "clayer" lyr) ) (princ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun C:mh (/ lyr lyr1) (setq lyr (getvar "clayer")) (setq lyr1 (tblsearch "layer" "e-storm-sewer")) (if (= lyr1 nil) "")) (command "-layer" "set" "e-storm-sewer" "") (command "insert" "STM-Manhole-Center" pause "xyz" 10. 10. 10. "0")) (setvar "clayer" lyr) ) (princ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun C:cg (/ lyr lyr1) (setq lyr (getvar "clayer")) (setq lyr1 (tblsearch "layer" "e-storm-sewer")) (if (= lyr1 nil) "")) (command "-layer" "set" "e-storm-sewer" "") (command "insert" "A$Cba839f42" pause "xyz" 4. 4. 4. "0")) (setvar "clayer" lyr) ) (princ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun C:li (/ lyr lyr1) (setq lyr (getvar "clayer")) (setq lyr1 (tblsearch "layer" "e-yard light")) (if (= lyr1 nil) "")) (command "-layer" "set" "e-yard light" "") (command "insert" "Flood Light" pause "xyz" 15. 15. 15. "0")) (setvar "clayer" lyr) ) (princ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun C:fg (/ lyr lyr1) (setq lyr (getvar "clayer")) (setq lyr1 (tblsearch "layer" "e-flag pole")) (if (= lyr1 nil) "")) (command "-layer" "set" "e-flag pole" "") (command "insert" "fpole" pause "xyz" 1. 1. 1. "0")) (setvar "clayer" lyr) ) (princ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun C:lp (/ lyr lyr1) (setq lyr (getvar "clayer")) (setq lyr1 (tblsearch "layer" "e-light pole")) (if (= lyr1 nil) "")) (command "-layer" "set" "e-light pole" "") (command "insert" "VZB_STREETLIGHT" pause "xyz" 20. 20. 20. "0")) (setvar "clayer" lyr) ) (princ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun C:sn (/ lyr lyr1) (setq lyr (getvar "clayer")) (setq lyr1 (tblsearch "layer" "e-sign")) (if (= lyr1 nil) "")) (command "-layer" "set" "e-sign" "") (command "insert" "A$Cd28f5eca" pause "xyz" 1. 1. 1. "0")) (setvar "clayer" lyr) ) (princ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun C:gv (/ lyr lyr1) (setq lyr (getvar "clayer")) (setq lyr1 (tblsearch "layer" "e-gas")) (if (= lyr1 nil) "")) (command "-layer" "set" "e-gas" "") (command "insert" "UTIL-Valve" pause "xyz" 8. 8. 8. "0")) (setvar "clayer" lyr) ) (princ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun C:wv (/ lyr lyr1) (setq lyr (getvar "clayer")) (setq lyr1 (tblsearch "layer" "e-water")) (if (= lyr1 nil) "")) (command "-layer" "set" "e-water" "") (command "insert" "UTIL-Meter" pause "xyz" 8. 8. 8. "0")) (setvar "clayer" lyr) ) (princ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun C:etc (/ lyr lyr1) (setq lyr (getvar "clayer")) (setq lyr1 (tblsearch "layer" "e-electric")) (if (= lyr1 nil) "")) (command "-layer" "set" "e-electric" "") (command "insert" "Charter-PED" pause "xyz" 2. 2. 2. "0")) (setvar "clayer" lyr) ) (princ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Quote
rlx Posted February 8, 2020 Posted February 8, 2020 you could try by starting to replace all (command "insert" with (command "-insert" . Quote
nj1105nj Posted February 8, 2020 Author Posted February 8, 2020 Oops, I've fixed that now. Although it still seems to be not working. Any other ideas? Quote
rlx Posted February 8, 2020 Posted February 8, 2020 I'm looking at your code right now and your problem is this : (setq lyr1 (tblsearch "layer" "e-gas")) (if (= lyr1 nil) "")) (command "-layer" "set" "e-gas" "") not sure what you want to do but this won't work : (if (= lyr1 nil) "")) You want to check if a layer is present. But what do you want to do if it does and what do you want to do if the layer doesn't exist? Quote
nj1105nj Posted February 8, 2020 Author Posted February 8, 2020 I would like for the block to be set to the layer in the code (in this case, e-gas). The layer should always be present, so if it isn't just to say "layer not found" or something along those lines Quote
dlanorh Posted February 8, 2020 Posted February 8, 2020 (edited) Maybe this (command "insert" "Charter-PED" pause "xyz" 2. 2. 2. "0")) should be (command "-insert" "Charter-PED" pause 2. 2. 2. "0")) Edited February 8, 2020 by dlanorh Quote
rlx Posted February 8, 2020 Posted February 8, 2020 (edited) (defun C:pp (/ lyr lyr1) (setq lyr (getvar "clayer")) (if (not (tblsearch "layer" "e-pole")) (princ "\nlayer e-pole not present") (progn (setvar "clayer" "e-pole") (command "-insert" "-ex pole" pause "xyz" 1. 1. 1. "0") (setvar "clayer" lyr) ) ) (princ) ) just tried the "xyz" option but it works ok Edited February 8, 2020 by rlx 1 Quote
nj1105nj Posted February 8, 2020 Author Posted February 8, 2020 1 hour ago, rlx said: (defun C:pp (/ lyr lyr1) (setq lyr (getvar "clayer")) (if (not (tblsearch "layer" "e-pole")) (princ "\nlayer e-pole not present") (progn (setvar "clayer" "e-pole") (command "-insert" "-ex pole" pause "xyz" 1. 1. 1. "0") (setvar "clayer" lyr) ) ) (princ) ) just tried the "xyz" option but it works ok That works great! thank you so much for your help 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.