FANDOM


;| WIKI-GETSTRINGX
   Extended (getstring) with default value and drawing text selection
   Three modes:
   1. If a default or initial value is supplied, GETSTRINGX prompts with it
   2. If no default is supplied and MODE is 0, the first prompt is for standard input, with fallback to selecting value from drawing text.
   3. If no default is supplied and MODE is 1, the first prompt is for drawing text selection, with fallback to standard input.
   Returns a STR, empty if drawing text selection fails.
   Returns the arc sine of a number
   Edit the source code for this function at 
  Getstringx (AutoLISP function)
|;

(DEFUN
   WIKI-GETSTRINGX (GX-CR GX-PROMPT GX-DEFAULTVALUE GX-INITIALVALUE
                    GX-PROMPTMODE / GX-RESPONSE
                   )
  (SETQ
    GX-DEFAULTVALUE
     (COND
       (GX-DEFAULTVALUE)
       (GX-INITIALVALUE)
     )
  )
  ;;First prompt
  (COND
    ;;If a non-empty default value was supplied, prompt with it.
    ((/= GX-DEFAULTVALUE "")
     (SETQ
       GX-RESPONSE
        (GETSTRING
          GX-CR 
          (STRCAT "\n" GX-PROMPT " <" GX-DEFAULTVALUE ">: ")
        )
     )
    )
    ;;Else if mode is 0, prompt for standard input
    ((= GX-PROMPTMODE 0)
     (SETQ
       GX-RESPONSE
        (GETSTRING
          GX-CR 
          (STRCAT
            "\n"
            GX-PROMPT
            " or <Select from drawing>: "
          )
        )
     )
    )
    ;;Else if mode is 1, prompt for object select
    ((= GX-PROMPTMODE 1)
     (SETQ
       GX-RESPONSE
        (NENTSEL
          (STRCAT
            "\nSelect object with "
            GX-PROMPT
            " or <enter manually>: "
          )
        )
     )
    )
  )
  ;;Second prompt if necessary
  (COND
    ;;If
    ((AND
       ;;no response
       (= GX-RESPONSE "")
       ;;and there's a default value,
       GX-DEFAULTVALUE
     )
     ;;No second prompt
     NIL
    )
    ;;Else if
    ((AND
       ;;no response
       (= GX-RESPONSE "")
       ;;and mode is 0,
       (= GX-PROMPTMODE 0)
     )
     ;;Prompt for object select
     (SETQ
       GX-RESPONSE
        (NENTSEL
          (STRCAT "\nSelect object with " GX-PROMPT ": ")
        )
     )
    )
    ;;Else if
    ((AND
       ;; no response
       (= GX-RESPONSE "")
       ;;and mode is 1,
       (= GX-PROMPTMODE 1)
     )
     ;;Prompt for standard input
     (SETQ GX-RESPONSE (GETSTRING GX-CR (STRCAT "\n" GX-PROMPT ": ")))
    )
  )
  ;;Return the string if provided
  (COND
    ;;If there was a (nentsel) prompt that failed (probably because user picked empty space)
    ((NOT GX-RESPONSE)
     ;;Print a warning and exit/abort
     (princ "\nError: No text object was selected.  Can't continue.")
     (exit)
    )
    ;;Else if the user hit return,
    ((= GX-RESPONSE "")
     ;;then return the default
     GX-DEFAULTVALUE
    )
    ;;Else if response isn't empty (the user didnt hit return)
    ((/= GX-RESPONSE "")
     ;;Then return the response
     GX-RESPONSE
    )
    ;;Else if there is a response, it is an (nentsel).  Convert to string
    (GX-RESPONSE (CDR (ASSOC 1 (ENTGET (CAR GX-RESPONSE)))))
  )
)

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.