Results 1 to 9 of 9

Thread: Select a point vs. String input

  1. #1
    Member
    Join Date
    2006-10
    Posts
    6
    Login to Give a bone
    0

    Default Select a point vs. String input

    Is there a way to have the user either select a point or input a keyword during a lisp routine?... i.e. the pline command... once started you can continue selecting points or you can type "arc" or such and then continue selecting points. Thanks.

  2. #2
    I could stop if I wanted to
    Join Date
    2003-11
    Posts
    277
    Login to Give a bone
    0

    Default Re: Select a point vs. String input

    Higarberadam,
    for this question
    "Is there a way to have the user either select a point or input a keyword during a lisp routine?... "
    you can use
    1). (setq ss (car (entsel "\nSelect a object")))
    2). (setq ss (ssget "x" '((0 . "LINE,PLINE",ARC....etc"))))

    for others question,I'm cannot answerd,because rather confuse (maybe I stupid).

    Quote Originally Posted by garberadam
    Is there a way to have the user either select a point or input a keyword during a lisp routine?... i.e. the pline command... once started you can continue selecting points or you can type "arc" or such and then continue selecting points. Thanks.

  3. #3
    Member
    Join Date
    2006-10
    Posts
    6
    Login to Give a bone
    0

    Default Re: Select a point vs. String input

    I'm sorry i guess i was confusing earlier.... what i want is for the user to be able to pick points to draw a line.... then type a string.... then go back to picking points.....
    If i use the getpoint command i can't input a string... if i use the getstring i can't pick a point with the cursor.. how do i enable both at the same time?... sorry for the confusion.. i don't know if my explanation helps... i guess i just want to redo the polyline command.. with my own options...... i don't know how else to explain it though....

  4. #4
    I could stop if I wanted to
    Join Date
    2003-11
    Posts
    277
    Login to Give a bone
    0

    Default Re: Select a point vs. String input

    Hi garberadam,
    do you mean like this
    Code:
    (defun c:test (/ cth p1 p2 p3 str cth th)
      (while
        (setq p1 (getpoint "\nClick any location<0,0,0>: "))
        (if (= p1 "")(setq p1 '(0 0 0)))
        (setq p2 (getpoint p1"\nClick any location<0,0,0>: "))
        (if (= p2 "")(setq p2 '(10 0 0)))
        (command "_line" p1 p2 "")
        (setq str (getstring "\nEnter new string: "))
        (setq p3 (getpoint "\nClick where to put string: "))
        (setq cth (getvar "textsize"))
        (setq th (getdist (strcat "\nEnter text height< " (rtos cth) " >: ")))
        (if (= th nil)(setq th cth))
        (command "_text" p3 th "" str 0)
        )
      (princ)
      )

    Quote Originally Posted by garberadam
    I'm sorry i guess i was confusing earlier.... what i want is for the user to be able to pick points to draw a line.... then type a string.... then go back to picking points.....
    If i use the getpoint command i can't input a string... if i use the getstring i can't pick a point with the cursor.. how do i enable both at the same time?... sorry for the confusion.. i don't know if my explanation helps... i guess i just want to redo the polyline command.. with my own options...... i don't know how else to explain it though....

  5. #5
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Select a point vs. String input

    This is the solution
    Code:
    (command "._pline" ) (while (= 1 (logand (getvar "CMDACTIVE") 1 )) (command PAUSE ) )
    : ) Happy Computing !

    kennet

  6. #6
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    8,449
    Login to Give a bone
    0

    Default Re: Select a point vs. String input

    Quote Originally Posted by garberadam
    I'm sorry i guess i was confusing earlier.... what i want is for the user to be able to pick points to draw a line.... then type a string.... then go back to picking points.....
    If i use the getpoint command i can't input a string... if i use the getstring i can't pick a point with the cursor.. how do i enable both at the same time?... sorry for the confusion.. i don't know if my explanation helps... i guess i just want to redo the polyline command.. with my own options...... i don't know how else to explain it though....
    From AutoCAD Developer's Help, look at the arbitrary keyboard input.

    Quote Originally Posted by AutoCAD Developer's Help
    Code:
    (defun C:ARBENTRY ( / pt1) 
      (initget 128)                     ; Sets arbitrary entry bit 
      (setq pt1 (getpoint "\nPoint: ")) ; Gets value from user. 
      (if (= 'STR (type pt1))           ; If it's a string, convert it
        (setq pt1 (eval (read pt1)))    ; to a symbol, try evaluating
                                        ; it as a function; otherwise,
        pt1                             ; just return the value. 
      )
    )
    (defun REF ( )
      (setvar "LASTPOINT" (getpoint "\nReference point: "))
      (getpoint "\nNext point: " (getvar "LASTPOINT"))
    )
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  7. #7
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Select a point vs. String input

    This is an option, although it will not allow the space character. Single words only.
    If you need spaces in the text you will have to use grread.
    Code:
    (defun c:getline (/ pt1 strlst pstart)
      (while
        (cond
          ((progn
             (initget 128)
             (null
               (if pstart
                 (setq pt1 (getpoint pstart "\nSelect Next Point or enter Text: "))
                 (setq pt1 (getpoint "\nSelect 1st Point or enter Text: "))
               )
             )
           )
           nil     ; exit loop
          )
          ((= 'STR (type pt1)) ; collect user input
           (setq strlst (cons  pt1 strlst))
          )
          ((= 'LIST (type pt1))
           (if pstart
             (command "_.line" pstart pt1 "")
           )
           (setq pstart pt1)
          )
        )
      )
      strlst ; return a list of the keyword strings entered by the user
    )

  8. #8
    I could stop if I wanted to pnorman's Avatar
    Join Date
    2005-02
    Location
    Calgary
    Posts
    203
    Login to Give a bone
    0

    Default Re: Select a point vs. String input

    I think the answer to your question is the "initget" function?! It is specifically designed to do exactly what you want. What you do with the user input is up to you. You have to write the necessary code using while, if and/or cond etc to handle the user input.

    Here is an example:

    Code:
      (while (/= (type INSPT) 'LIST)
    	(initget "T M B O")
    	(setq INSPT (getpoint PT1 "\nInsert point or [Top/Middle/Bottom](Options...): "))
    	(cond
    	  ((= INSPT "T")
    	   (setq PT1 SP)
    	  )
    	  ((= INSPT "M")
    	   (setq PT1 (list (car SP) (- (cadr SP) (/ D 2.00)) (caddr SP)))
    	  )
    	  ((= INSPT "B")
    	   (setq PT1 (list (car SP) (- (cadr SP) D) (caddr SP)))
    	  )
    	  ((= INSPT "O")
    	   (setq WHAT_NEXT 2 INSPT '(0 0))
    	   (ppn:vla-delete-ss SS1)
    	  )
    	  ((= INSPT nil)
    	   (setq WHAT_NEXT 0 INSPT '(0 0))
    	   (ppn:vla-delete-ss SS1)
    	  )
    	)
      )

  9. #9
    Member
    Join Date
    2006-10
    Posts
    6
    Login to Give a bone
    0

    Default Re: Select a point vs. String input

    THANK YOU THANK YOU THANK YOU..... you guys are great!!!!!!!!!!!

Similar Threads

  1. 2013: Point Filters & Absolute Coordinates with Dynamic Input ON
    By blothian933499 in forum AutoCAD General
    Replies: 1
    Last Post: 2013-12-04, 07:00 PM
  2. error: malformed string on input
    By Bear31831 in forum AutoCAD General
    Replies: 13
    Last Post: 2013-08-27, 06:50 PM
  3. 2013: 3D Cartesian Coordinate System: Batch input with Work Point Labels
    By rusa67 in forum Inventor - General
    Replies: 0
    Last Post: 2013-02-04, 04:44 PM
  4. Select Block with Name Matching a String
    By harilalmn in forum AutoLISP
    Replies: 6
    Last Post: 2010-09-22, 11:50 AM
  5. I need help finding the string to access c3d point data for a lisp routin
    By jmeyer.186809 in forum AutoCAD Civil 3D - General
    Replies: 7
    Last Post: 2010-05-25, 08:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •