FANDOM


;|

These enhanced input functions prompt for user input
External dependencies:
WIKI-3PTTOBULGE
WIKI-SEGMENT-LENGTH

|;
(DEFUN
   WIKI-GETANGLEX (GX-STARTINGPOINT GX-PROMPT GX-DEFAULTVALUE
                   GX-INITIALVALUE / GX-INPUT
                  )
  (SETQ
    GX-DEFAULTVALUE
     (COND
       (GX-DEFAULTVALUE)
       (GX-INITIALVALUE)
       (0.0)
     )
  )
  (COND
    ((AND
       GX-STARTINGPOINT
       (SETQ
         GX-INPUT
          (GETANGLE
            GX-STARTINGPOINT
            (STRCAT
              "\n"
              GX-PROMPT
              " <"
              (ANGTOS GX-DEFAULTVALUE)
              ">: "
            )
          )
       )
     )
     GX-INPUT
    )
    ((AND
       (NOT GX-STARTINGPOINT)
       (SETQ
         GX-INPUT
          (GETANGLE
            (STRCAT
              "\n"
              GX-PROMPT
              " <"
              (ANGTOS GX-DEFAULTVALUE)
              ">: "
            )
          )
       )
     )
     GX-INPUT
    )
    (GX-DEFAULTVALUE)
  )
)

;;;WIKI-GETDISTX
;;;Returns a distance
(DEFUN WIKI-GETDISTX (GX-POINT1 GX-PROMPT GX-DEFAULTVALUE GX-INITIALVALUE)
  (CAR (WIKI-GETDISTPOINT GX-POINT1 GX-PROMPT GX-DEFAULTVALUE GX-INITIALVALUE))
)
;;;WIKI-GETDISTPOINT
;;;Returns a distance, the endpoint of the distance, and the bulge used for the distance.
;;;'(distance endpoint bulge)
(DEFUN
   WIKI-GETDISTPOINT (GX-POINT1 GX-PROMPT GX-DEFAULTVALUE
                      GX-INITIALVALUE / GX-POINT2 GX-POINT3 GX-BULGE
                      GX-DISTANCE
                     )
  (SETQ
    GX-DEFAULTVALUE
     (COND
       (GX-DEFAULTVALUE)
       (GX-INITIALVALUE)
     )
  )
  ;;If starting point wasn't provided, get it.
  (COND
    ((NOT GX-POINT1)
     (SETQ GX-POINT1 (GETPOINT "\nSpecify first point: "))
    )
  )
  ;;If there is now a starting point, get the second point or Arc keyword.
  (COND
    (GX-POINT1
     (INITGET "Arc")
     (SETQ
       GX-POINT2
        (GETPOINT
          GX-POINT1
          (STRCAT
            "\n"
            GX-PROMPT
            " [Arc]"
            (IF GX-DEFAULTVALUE
              (STRCAT " <" (RTOS GX-DEFAULTVALUE) ">")
              ""
            )
            ": "
          )
        )
     )
    )
  )
  (SETQ
    GX-DISTANCE
     (COND
       ;;If
       (  ;;point2 was not entered
          (NOT GX-POINT2)
        ;;then return the default value.
        GX-DEFAULTVALUE
       )
       ;;Else if point2 isn't "Arc"
       ((/= "Arc" GX-POINT2)
        ;;then return the distance between point1 and point2
        (DISTANCE GX-POINT1 GX-POINT2)
       )
       ;;Else enter arc mode.
       (T
        ;;Prompt for the second and third arc points
        (SETQ
          GX-POINT2
           (GETPOINT
             (STRCAT "\nSpecify point on arc: ")
           )
          GX-POINT3
           (GETPOINT
             (STRCAT "\nSpecify end point of arc: ")
           )
        )
        (COND
          ;;If the second and third arc point were provided, then
          ((AND GX-POINT2 GX-POINT3)
           ;;Return the length of the arc.
           (WIKI-SEGMENT-LENGTH
             GX-POINT1
             GX-POINT3
             (SETQ
               GX-BULGE
                (WIKI-3PTTOBULGE
                  (WIKI-FLATTEN GX-POINT1)
                  (WIKI-FLATTEN GX-POINT2)
                  (WIKI-FLATTEN GX-POINT3)
                )
             )
           )
          )
        )
       )
     )
  )
  (LIST
    GX-DISTANCE
    (COND
      (GX-POINT3)
      (GX-POINT2)
    )
    GX-BULGE
  )
)

;;WIKI-GETINTX
;;Provided for legacy compatability and user experience.
(DEFUN
   WIKI-GETINTX (GX-PROMPT GX-DEFAULTVALUE GX-INITIALVALUE)
  (WIKI-GETINTXX GX-PROMPT GX-DEFAULTVALUE GX-INITIALVALUE 0)
)
;;;WIKI-GETINTXX
;;;Extended (getint) with default value and drawing text selection
;;;Three modes:
;;;1. If a default or initial value is supplied, GETINTX prompts with it and allows user to enter Select from drawing text mode.
;;;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 an INT or nil if nothing provided.
(DEFUN
   WIKI-GETINTXX (GX-PROMPT GX-DEFAULTVALUE GX-INITIALVALUE
                  GX-PROMPTMODE / GX-RESPONSE
                 )
  ;;Log all calls to this function.
  (WIKI-LOG
    (STRCAT
      "WIKI-GETINTX GX-PROMPT="
      GX-PROMPT
      " GX-DEFAULT="
      (IF GX-DEFAULTVALUE
        (ITOA GX-DEFAULTVALUE)
        "nil"
      )
      " GX-INITIALVALUE="
      (IF GX-INITIALVALUE
        (ITOA GX-INITIALVALUE)
        "nil"
      )
    )
  )
  (SETQ
    GX-DEFAULTVALUE
     (COND
       (GX-DEFAULTVALUE)
       (GX-INITIALVALUE)
     )
  )
  ;;First prompt
  (COND
    ;;If a default value was supplied, prompt with it and allow user to enter Select from drawing text mode.
    (GX-DEFAULTVALUE
     (INITGET "Select")
     (SETQ
       GX-RESPONSE
        (GETINT
          (STRCAT
            "\n"
            GX-PROMPT
            " or [Select from drawing] <"
            (ITOA GX-DEFAULTVALUE)
            ">: "
          )
        )
     )
    )
    ;;Else if mode is 0, prompt for standard input
    ((= GX-PROMPTMODE 0)
     (SETQ
       GX-RESPONSE
        (GETINT
          (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
       (NOT GX-RESPONSE)
       ;;and there's a default value,
       GX-DEFAULTVALUE
     )
     ;;No second prompt
     NIL
    )
    ;;Else if
    ((OR (AND
           ;;no response
           (NOT GX-RESPONSE)
           ;;and mode is 0,
           (= GX-PROMPTMODE 0)
         )
         ;;or response was Select
         (= GX-RESPONSE "Select")
     )
     ;;Prompt for object select
     (SETQ
       GX-RESPONSE
        (NENTSEL
          (STRCAT "\nSelect object with " GX-PROMPT ": ")
        )
     )
    )
    ;;Else if
    ((AND
       ;; no response
       (NOT GX-RESPONSE)
       ;;and mode is 1,
       (= GX-PROMPTMODE 1)
     )
     ;;Prompt for standard input
     (SETQ GX-RESPONSE (GETINT (STRCAT "\n" GX-PROMPT ": ")))
    )
  )
  ;;Return the integer if provided
  (COND
    ;;If
    ((AND
       ;;there's a response
       GX-RESPONSE
       ;;and it's an integer,
       (= (TYPE GX-RESPONSE) 'INT)
     )
     ;;Then return it
     GX-RESPONSE
    )
    ;;Else if
    ((AND
       ;;there's a response
       GX-RESPONSE
       ;;and it's an entsel,
       (= (TYPE GX-RESPONSE) 'LIST)
     )
     ;;Then return it
     ;;Then convert it to an integer
     (ATOI
       (CADR
         (WIKI-EXTRACT (CDR (ASSOC 1 (ENTGET (CAR GX-RESPONSE)))))
       )
     )
    )
    ;;Else
    (T
     ;;Return the default
     GX-DEFAULTVALUE
    )
  )
)

;;WIKI-GETREALX
;;Provided for legacy compatability and user experience.
(DEFUN
   WIKI-GETREALX (GX-PROMPT GX-DEFAULTVALUE GX-INITIALVALUE)
  (WIKI-GETREALXX GX-PROMPT GX-DEFAULTVALUE GX-INITIALVALUE 0)
)
;;;WIKI-GETREALXX
;;;Extended (getreal) with default value and drawing text selection
;;;Three modes:
;;;1. If a default or initial value is supplied, GETREALX prompts with it and allows user to enter Select from drawing text mode.
;;;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 an REAL or nil if nothing provided.
(DEFUN
   WIKI-GETREALXX (GX-PROMPT GX-DEFAULTVALUE GX-INITIALVALUE
                   GX-PROMPTMODE / GX-RESPONSE
                  )
  ;;Log all calls to this function.
  (WIKI-LOG
    (STRCAT
      "WIKI-GETREALX GX-PROMPT="
      GX-PROMPT
      " GX-DEFAULT="
      (IF GX-DEFAULTVALUE
        (RTOS GX-DEFAULTVALUE 2)
        "nil"
      )
      " GX-INITIALVALUE="
      (IF GX-INITIALVALUE
        (RTOS GX-INITIALVALUE 2)
        "nil"
      )
    )
  )
  (SETQ
    GX-DEFAULTVALUE
     (COND
       (GX-DEFAULTVALUE)
       (GX-INITIALVALUE)
     )
  )
  ;;First prompt
  (COND
    ;;If a default value was supplied, prompt with it and allow user to enter Select from drawing text mode.
    (GX-DEFAULTVALUE
     (INITGET "Select")
     (SETQ
       GX-RESPONSE
        (GETREAL
          (STRCAT
            "\n"
            GX-PROMPT
            " or [Select from drawing] <"
            (RTOS GX-DEFAULTVALUE 2)
            ">: "
          )
        )
     )
    )
    ;;Else if mode is 0, prompt for standard input
    ((= GX-PROMPTMODE 0)
     (SETQ
       GX-RESPONSE
        (GETREAL
          (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
       (NOT GX-RESPONSE)
       ;;and there's a default value,
       GX-DEFAULTVALUE
     )
     ;;No second prompt
     NIL
    )
    ;;Else if
    ((OR (AND
           ;;no response
           (NOT GX-RESPONSE)
           ;;and mode is 0,
           (= GX-PROMPTMODE 0)
         )
         ;;or response was Select
         (= GX-RESPONSE "Select")
     )
     ;;Prompt for object select
     (SETQ
       GX-RESPONSE
        (NENTSEL
          (STRCAT "\nSelect object with " GX-PROMPT ": ")
        )
     )
    )
    ;;Else if
    ((AND
       ;; no response
       (NOT GX-RESPONSE)
       ;;and mode is 1,
       (= GX-PROMPTMODE 1)
     )
     ;;Prompt for standard input
     (SETQ GX-RESPONSE (GETREAL (STRCAT "\n" GX-PROMPT ": ")))
    )
  )
  ;;Return the real number if provided
  (COND
    ;;If
    ((AND
       ;;there's a response
       GX-RESPONSE
       ;;and it's an integer,
       (= (TYPE GX-RESPONSE) 'REAL)
     )
     ;;Then return it
     GX-RESPONSE
    )
    ;;Else if
    ((AND
       ;;there's a response
       GX-RESPONSE
       ;;and it's an entsel,
       (= (TYPE GX-RESPONSE) 'LIST)
     )
     ;;Then return it
     ;;Then convert it to an real
     (ATOF
       (CADR
         (WIKI-EXTRACT (CDR (ASSOC 1 (ENTGET (CAR GX-RESPONSE)))))
       )
     )
    )
    ;;Else
    (T
     ;;Return the default
     GX-DEFAULTVALUE
    )
  )
)

;;;WIKI-GETPOINTX
(DEFUN
   WIKI-GETPOINTX (GX-STARTINGPOINT GX-PROMPT GX-DEFAULTVALUE
                   GX-INITIALVALUE / GX-INPUT
                  )
  (SETQ
    GX-DEFAULTVALUE
     (COND
       (GX-DEFAULTVALUE)
       (GX-INITIALVALUE)
       ('(0.0 0.0 0.0))
     )
  )
  (SETQ
    GX-PROMPT
     (STRCAT
       GX-PROMPT
       " <"
       (RTOS (CAR GX-DEFAULTVALUE))
       ","
       (RTOS (CADR GX-DEFAULTVALUE))
       ","
       (RTOS (CADDR GX-DEFAULTVALUE))
       ">: "
     )
  )
  (SETQ
    GX-INPUT
     (IF GX-STARTINGPOINT
       (GETPOINT GX-STARTINGPOINT GX-PROMPT)
       (GETPOINT GX-PROMPT)
     )
  )
  (IF (NOT GX-INPUT)
    GX-DEFAULTVALUE
    GX-INPUT
  )
)

(DEFUN
   WIKI-GETSTRINGX
   (GX-PROMPT GX-DEFAULTVALUE GX-INITIALVALUE / GX-INPUT)
  (SETQ
    GX-DEFAULTVALUE
     (COND
       (GX-DEFAULTVALUE)
       (GX-INITIALVALUE)
       ("")
     )
  )
  (COND
    ((/= ""
         (SETQ
           GX-INPUT
            (GETSTRING
              (STRCAT "\n" GX-PROMPT " <" GX-DEFAULTVALUE ">: ")
            )
         )
     )
     GX-INPUT
    )
    (GX-DEFAULTVALUE)
  )
)
;;;  WIKI-SEGMENT-LENGTH
(DEFUN
   WIKI-SEGMENT-LENGTH
;;;  Returns curve or straight length of a segment.
                       (2DPNT1 2DPNT2 BULGE / D DELTA DOVER2 L R)
  (SETQ
    ;;Make sure points are truly 2d
    2DPNT1
     (WIKI-FLATTEN 2DPNT1)
    2DPNT2
     (WIKI-FLATTEN 2DPNT2)
    D (/ (DISTANCE 2DPNT1 2DPNT2) 2)
  ) ;_ end of setq
  (COND
    ((/= 0 BULGE)
     (SETQ
       DOVER2
        (ABS (* 2 (ATAN BULGE)))
       DELTA
        (* 2 DOVER2)
       R (/ D (SIN DOVER2))
     ) ;_ end of setq
     (* DELTA R)
    )
    (T (* D 2))
  ) ;_ end of cond
)

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.