OMEGA-ThundeR Posted May 22, 2017 Share Posted May 22, 2017 Hi, i want to make an 'create layer' lisp so i can switch layers by command. i don't want any errors and they don't show in the very basic version. (Defun C:HulplijnA () (command "-Layer" "make" "X-XX-AL-HULPLIJN-G" "color" "yellow" "" "") (Command "-Layer" "set" "X-XX-AL-HULPLIJN-G" "") (princ) ) Since above code is wrong on a few levels , i want to create a check with an if statement. (Defun C:hulplijn () (if (tblsearch "LAYER" "X-XX-AL-HULPLIJN-G") ; Bestaat deze laag? ((Command "-Layer" "set" "X-XX-AL-HULPLIJN-G" "")(princ)) ; Zo ja dan doen we dit ((command "-Layer" "make" "X-XX-AL-HULPLIJN-G" "color" "yellow" "" "")) ; Zo nee dan doen we dit ) (princ) ) So, above code gives me a "Command: ; error: no function definition: nil" Error on both situations. What am i doing wrong to create that error? Quote Link to comment Share on other sites More sharing options...
BKT Posted May 22, 2017 Share Posted May 22, 2017 You need to eliminate the extra parentheses and the (princ): (Defun C:hulplijn () (if (tblsearch "LAYER" "X-XX-AL-HULPLIJN-G") ; Bestaat deze laag? [color=red]([/color](Command "-Layer" "set" "X-XX-AL-HULPLIJN-G" "")[color=red](princ))[/color] ; Zo ja dan doen we dit [color=red]([/color](command "-Layer" "make" "X-XX-AL-HULPLIJN-G" "color" "yellow" "" "")[color=red])[/color] ; Zo nee dan doen we dit ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Aftertouch Posted May 22, 2017 Share Posted May 22, 2017 If you just use 'make' layer, it will set it active if it already exists. An 'if' statement is overkill in this case. Quote Link to comment Share on other sites More sharing options...
OMEGA-ThundeR Posted May 23, 2017 Author Share Posted May 23, 2017 You need to eliminate the extra parentheses and the (princ): (Defun C:hulplijn () (if (tblsearch "LAYER" "X-XX-AL-HULPLIJN-G") ; Bestaat deze laag? [color=red]([/color](Command "-Layer" "set" "X-XX-AL-HULPLIJN-G" "")[color=red](princ))[/color] ; Zo ja dan doen we dit [color=red]([/color](command "-Layer" "make" "X-XX-AL-HULPLIJN-G" "color" "yellow" "" "")[color=red])[/color] ; Zo nee dan doen we dit ) (princ) ) Thanks, works like a charm now . If you just use 'make' layer, it will set it active if it already exists. An 'if' statement is overkill in this case. Perhaps, but it looked 'cleaner' to do the right action, although there is one action 'to rule them all' . But i will add an alert saying the layer doesn't exist making clear the right template isn't used (in this case one doesn't go without the other) And also if i would change any properties of the layer like the color the command (to make the layer) wil reset it to the preferences in the command. Quote Link to comment Share on other sites More sharing options...
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.