+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16
  1. #1
    Junior Member
    Using
    AutoCAD 2013
    Join Date
    Jan 2013
    Posts
    16

    Default Getstring & Strcat

    Registered forum members do not see this ad.

    Hi,

    I'm trying to write a lisp to help me do the elevation leader & material code easier.

    But seems like I miss understand some function.

    I want to setq the Material Code by only input 2 digit, for example, "1" + "3" should return WC03. But right now !Material return 1, !Code return 3..... and !MaterialCode return MaterialCode......


    (setq Material (getstring "\nSpecify material [1_WC/2_WD/3_ST/]: "))
    (setq Code (getstring "\nSpecify material [1_01/2_02/3_03/4_04]: "))
    (setq MaterialCode (strcat "Material" "Num"))

  2. #2
    Junior Member
    Using
    AutoCAD 2013
    Join Date
    Jan 2013
    Posts
    16

    Default

    Hey Guys,

    I just help myself out, i should use getkword and it should look like below

    (setq Mat1 (getkword "\n [BL/CP/GL/FA/FB/ML/P/PL/SP/ST/TL/WC/WD]<ML>: "))
    (initget "01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20")
    (setq Num1 (getkword "\n [01/02/03/04/05/06/07/08/09/10/11/12/13/14/15/16/17/18/19/20]: "))
    (setq Mat1Num1 (strcat Mat1 Num1))

    And then get what i want
    But to make it more friendly, how do type 1=01 without the clarify window asking which number has1 ?

  3. #3
    Super Member hanhphuc's Avatar
    Using
    AutoCAD 2007
    Join Date
    Apr 2013
    Location
    Happy Garden
    Posts
    565

    Default

    hi please use code tag

    Quote Originally Posted by leong1221 View Post
    And then get what i want
    But to make it more friendly, how do type 1=01 without the clarify window asking which number has1 ?
    This code with code tags
    Code:
    (defun matNum (/ l i s mat1 Num1)
      (setq	i 1
    	l '("BL" "CP" "GL" "FA"	"FB" "ML" "P" "PL" "SP"	"ST" "TL" "WC"
    	    "WD")
      )
      (repeat (length l)
        (setq s (cons (strcat (itoa i) "_" (nth (1- i) l) " / ") s))
        (setq i (1+ i))
      )
    
      (initget 7)
      (if
        (and
          (setq i (getint (strcat "\nIndex number ["
    			      (apply 'strcat (reverse s))
    			      "]? : "
    		      )
    	      )
          )
          (<= i (length l))
    
          (setq mat1 (nth (1- i) l))
    
    
          (progn
    	(initget 7)
    	(setq i (getint "Enter number 1~20 ? : "))
    	(setq Num1 (itoa i))
    	(<= i 20)
          )
        )
    
      (princ (strcat Mat1
    		 (if (< i 10)
    		   (strcat "0" Num1)
    		   Num1
    		 )
    	 )
      )
      (prompt "\nInvalid Input.. ")
    )
    ;(princ) ; removed
    )
    Last edited by hanhphuc; 14th Nov 2017 at 03:08 am.
    lambda not optimized.. ( apply '= "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" ) ; error: too many arguments

  4. #4
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,819

    Default

    Ths may be useful we want D01-d09 then D10+ taken from some code.

    Code:
    ; if less than 10
        (if (< (car dwgnum) 10.0) 
          (setq newstr2 (strcat dwgname "-D0"  (rtos sheetnum 2 0)))
          (setq newstr2 (strcat dwgname "-D"  (rtos sheetnum 2 0)))
        )
    A man who never made mistakes never made anything

  5. #5
    Junior Member
    Using
    AutoCAD 2013
    Join Date
    Jan 2013
    Posts
    16

    Default

    Hi hanhphuc,

    Thanks! It works perfectly!

  6. #6
    Junior Member
    Using
    AutoCAD 2013
    Join Date
    Jan 2013
    Posts
    16

    Default

    Quote Originally Posted by hanhphuc View Post
    hi please use code tag



    This code with code tags
    Code:
    (defun c:test (/ l i s mat1 Num1)
      (setq	i 1
    	l '("BL" "CP" "GL" "FA"	"FB" "ML" "P" "PL" "SP"	"ST" "TL" "WC"
    	    "WD")
      )
      (repeat (length l)
        (setq s (cons (strcat (itoa i) "_" (nth (1- i) l) " / ") s))
        (setq i (1+ i))
      )
    
      (initget 7)
      (if
        (and
          (setq i (getint (strcat "\nIndex number ["
    			      (apply 'strcat (reverse s))
    			      "]? : "
    		      )
    	      )
          )
          (<= i (length l))
    
          (setq mat1 (nth (1- i) l))
    
    
          (progn
    	(initget 7)
    	(setq i (getint "Enter number 1~20 ? : "))
    	(setq Num1 (itoa i))
    	(<= i 20)
          )
        )
    
      (princ (strcat Mat1
    		 (if (< i 10)
    		   (strcat "0" Num1)
    		   Num1
    		 )
    	 )
      )
      (princ "\nInvalid Input.. ")
    )
    
    (princ)
    
    )
    The reason I setq Mat1 and Num1 is to help -insert an attribute block in next step and to rename the block according to what just input, for example by running your lisp and input "1" "1" then i got an attribute block named BL01.

    Any hint how to do it? Many thanks

  7. #7
    Junior Member
    Using
    AutoCAD 2013
    Join Date
    Jan 2013
    Posts
    16

    Default

    Quote Originally Posted by leong1221 View Post
    The reason I setq Mat1 and Num1 is to help -insert an attribute block in next step and to rename the block according to what just input, for example by running your lisp and input "1" "1" then i got an attribute block named BL01.

    Any hint how to do it? Many thanks
    I was think the command Gatte, and then I write it to my lisp
    (command "gatte") and return GATTE Unknown command "GATTE"

  8. #8
    Senior Member
    Discipline
    Civil
    Aftertouch's Discipline Details
    Discipline
    Civil
    Details
    Engineer
    Using
    AutoCAD 2017
    Join Date
    Jul 2016
    Location
    Netherlands
    Posts
    222

    Default

    GATTE is a Global Attribute Edit function.

    If you want to rename the block, i would just 'insert' the regular block, and use a RENAME function on the ENTLAST?

  9. #9
    Junior Member
    Using
    AutoCAD 2013
    Join Date
    Jan 2013
    Posts
    16

    Default

    Quote Originally Posted by Aftertouch View Post
    GATTE is a Global Attribute Edit function.

    If you want to rename the block, i would just 'insert' the regular block, and use a RENAME function on the ENTLAST?
    Hi, i attached an image to clarify me idea



    Thanks
    Leo

  10. #10
    Junior Member
    Using
    AutoCAD 2013
    Join Date
    Jan 2013
    Posts
    16

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by leong1221 View Post
    Hi, i attached an image to clarify me idea



    Thanks
    Leo
    Step1 is done, stuck at step 2

Similar Threads

  1. Need some help with getstring
    By pmxcad in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 1st Nov 2017, 08:21 pm
  2. Getstring Question
    By harrison-matt in forum AutoLISP, Visual LISP & DCL
    Replies: 31
    Last Post: 19th Oct 2010, 10:57 pm
  3. problem with strcat
    By Sweety in forum AutoLISP, Visual LISP & DCL
    Replies: 36
    Last Post: 25th Aug 2010, 08:39 pm
  4. getstring
    By jay3791 in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 29th Sep 2009, 07:21 pm
  5. strcat help sought
    By diarmuid in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 23rd Aug 2006, 08:44 am

Bookmarks

Posting Permissions

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