Jump to content

Need help with user prompt lisp


MikeP

Recommended Posts

I cannot get this portion of the code to work. it does not even pop up with an error, it acts like it ignores it, and yes i do have my variables listed

 

 

(cond
   ((setq hide (getkword "\nHide Box? [Y/N] ? <Y>"))
)
  (if hide
   (command "-layer" "s" "Dim" "off" "Dim" "")
   ("")
  )
 

Link to comment
Share on other sites

Try changing this:

(command "-layer" "s" "Dim" "off" "Dim" "")

 

To this:

(command "_.layer" "s" "Dim" "off" "Dim" "Y")

 

If that don't work, I would recommend submitting the reset of your lisp.

Link to comment
Share on other sites

Just tweaking the code slighlty

 

Add Initget when using getkword to establish keywords for use by the next user-input function call

 

    (initget "Y N") ;Set the key words
   
   (setq hide (getkword "\nHide Box? [Y/N] ? <Y>")) 	;Get the input

   (if
    (= hide "Y") ;If the user has entered the required key "Y"
    (command "_.layer" "s" "Dim" "off" "Dim" "Y" "") ;Turn off the layer
    )
    

 

Regards,

Jammie

Link to comment
Share on other sites

Not sure if this applies, but when using the initget function, I usually specify a bit reference after the initget function syntax. I havnt got much experience using the initget function, so please correct me if I am wrong.

 

i.e.

 

(initget 1 "Y N") ; 1 = no null input
   
   (setq hide (getkword "\nHide Box? [Y/N] ? <Y>")) 	;Get the input

   (if
    (= hide "Y") ;If the user has entered the required key "Y"
    (command "_.layer" "s" "Dim" "off" "Dim" "Y" "") ;Turn off the layer
    )

Hope this helps :)

Link to comment
Share on other sites

  (initget "Yes No") 
  (if (/= "No" (getkword "\nHide Box? [Yes/No] ? <Y>:   "))
      (command "_.LAYER" "s" "Dim" "_Off" "Dim" "_Y" "")) 

 

By forcing the input with the (initget) bit flag, you negate the default "Y". So a nil response does not equal "No", so the test is T and the _.LAYER call will process.

 

I prefer the full word in an initget call. Even using the full Yes No, the nmenonics Y and N still work.

 

A couple of gottchas here.

- What if the layer DIM does not exist?

- What if the layer DIM is Frozen?

- If the sysvar EXPERT is set to 5, the prompt for turning off the current layer is bypassed.

 

A robust LAYER command can be a fairly lenghty call. My $0.02 -David

Link to comment
Share on other sites

I get "invalid user keyword"

 

 

 

 

 

Just tweaking the code slighlty

 

Add Initget when using getkword to establish keywords for use by the next user-input function call

 

    (initget "Y N") ;Set the key words
   
   (setq hide (getkword "\nHide Box? [Y/N] ? <Y>"))     ;Get the input

   (if
    (= hide "Y") ;If the user has entered the required key "Y"
    (command "_.layer" "s" "Dim" "off" "Dim" "Y" "") ;Turn off the layer
    )
    

Regards,

Jammie

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