Jump to content

Lisp to create layer gives error


OMEGA-ThundeR

Recommended Posts

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 :P, 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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

If you just use 'make' layer, it will set it active if it already exists. An 'if' statement is overkill in this case.

Link to comment
Share on other sites

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.

Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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