Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Little help with LISP PLS

  1. #1
    Member
    Join Date
    2013-09
    Posts
    20
    Login to Give a bone
    0

    Default Little help with LISP PLS

    Hello! I have dealt several times with Lisp, and today I had to write a little code. The essence of the code is to put labels and two plines of a cross section. Problem appears with labeling the drawing. I attach the file with a drawing because I can not explain very well: P Here is my version of the code sequence.
    Code:
    (defun C:write    (/ elevation relevation level axis ptn  ptlevel len  a b c d) 
     (setvar "cmdecho" 0)
     (setvar "osmode" 513)
     (command  "STYLE" "Standart" "Arial" 0.2 0.7 0 "N" "N" )
     (command "LAYER" "M" "LABELS" "C" "red" "0" "LW" 0.15 "0" "")
    
      (setq elevation (getpoint "\nEnter the base elevation of section: "))
      (setq level (getpoint "\nChose level of base elevation: "))
      (setq axis (getpoint "\nChose axis of section: "))
      (setq ptn (getpoint "\nChose point for labeling: "))
      (setq   a 0.7
                b 1.5
                c 1
                d 0.75
      )
     (setq ptlevel (list (car ptn) (cadr level)))
      (setq len (- (car ptn) (cadr level)))
      (command "_.pline" "_non" ptn "_non" ptlevel "c")
      (setq relevation (+ elevation len))
      (command "TEXT" "J" "ML"  (list (- ptlevel b c d) (cadr ptlevel)) 90 relevation)
    )
    I'm still trying to write the elevation bellow the needed point 1. (setq relevation (+ elevation len)) <- it is something wrong with that because AutoCAD returns to me -> ; error: bad argument type: numberp: "here is the elevation value i have typed above - 106 in this case".
    I would be thankful for any guidelines and sorry for my English.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by d_2de416038; 2013-09-05 at 06:24 AM.

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,684
    Login to Give a bone
    0

    Default Re: Little help with LISP PLS

    Code:
       (setq len (- (car ptn) (cadr nivo)))
      (command "_.pline" "_non" ptn "_non" ptlevel "c")
      (setq relevation (+ elevation len))
    What's the value of nivo?

  3. #3
    Member
    Join Date
    2013-09
    Posts
    20
    Login to Give a bone
    0

    Default Re: Little help with LISP PLS

    I'm sorry for that. It had to be level.

  4. #4
    Member
    Join Date
    2013-09
    Posts
    20
    Login to Give a bone
    0

    Default Re: Little help with LISP PLS

    I'v made some changes in code but still no result with sum of base elevation and length of ordinate
    Code:
    (defun C:write    (/ elevation relevation level axis ptn  ptlevel rlen endord len  a b c d) 
     (setvar "cmdecho" 0)
     (setvar "osmode" 513)
     (command  "STYLE" "Standart" "Arial" 0.2 0.7 0 "N" "N" )
     (command "LAYER" "M" "LABELS" "C" "red" "0" "LW" 0.15 "0" "")
    
      (setq elevation (getpoint "\nEnter the base elevation of section: "))
      (setq level (getpoint "\nChose level of base elevation: "))
      (setq axis (getpoint "\nChose axis of section: "))
      (setq ptn (getpoint "\nChose point for labeling: "))
      (setq   a 0.7
                b 1.5
                c 1
                d 0.75
      )
     (setq ptlevel (list (car ptn) (cadr level))) ; Here calculate bottom point of ordinate
      (command "_.pline" "_non" ptn "_non" ptlevel "c") ;Draw ordinate
     (setq endord (getpoint "\nChose bottom point of ordinate: ")) ;Take point for calculate length of ordinate
     (setq len (distance ptn endord))
     (setq rlen (rtos len 2 2))
     (setq relevation (+ elevation rlen)  ;At this line show message: error: bad argument type: numberp:
      (command "TEXT" "J" "ML"  (list (- ptlevel b c d) (cadr ptlevel)) 90 relevation)
    )

  5. #5
    I could stop if I wanted to
    Join Date
    2009-03
    Location
    London, England
    Posts
    304
    Login to Give a bone
    0

    Default Re: Little help with LISP PLS

    Quote Originally Posted by d_2de416038 View Post
    Code:
    (setq rlen (rtos len 2 2))
    (setq relevation (+ elevation rlen)  ;At this line show message: error: bad argument type: numberp:
    The variable rlen is assigned the result of converting the value held by variable len to a string; the variable elevation is either a 3D point (i.e. a list of three numerical values) or nil, as returned by the getpoint function. You are receiving an error because you are attempting to add a list to a string.

  6. #6
    Member
    Join Date
    2013-09
    Posts
    20
    Login to Give a bone
    0

    Default Re: Little help with LISP PLS

    This was changed earlier to getstring and manually entering the base elevation witch is integer but still not work.

  7. #7
    I could stop if I wanted to
    Join Date
    2009-03
    Location
    London, England
    Posts
    304
    Login to Give a bone
    0

    Default Re: Little help with LISP PLS

    Quote Originally Posted by d_2de416038 View Post
    This was changed earlier to getstring and manually entering the base elevation witch is integer but still not work.
    Hint: getstring returns a string; since you require a numerical value, consider either getint or getreal

  8. #8
    Member
    Join Date
    2013-09
    Posts
    20
    Login to Give a bone
    0

    Default Re: Little help with LISP PLS

    Thanks Lee! I'v never used that functions before. Continue with code

  9. #9
    Member
    Join Date
    2013-09
    Posts
    20
    Login to Give a bone
    0

    Default Re: Little help with LISP PLS

    I finally succeeded with the program! My big mistake was with the types of data that I wanted to enter and calculate. But thanks to Lee I correct that.And there's a worked (for me) code
    And again sorry for my English
    Code:
    (defun C:nadpis	(/ kota nivo os ptn a b c d ptnivo endord len kotatochka kotastring nomertochka otstoqnie ostring)
     (setvar "cmdecho" 0)
     (setvar "osmode" 513)
      (command  "STYLE" "Standart" "Arial" 0.25 0.8 0 "N" "N" )
      (command "LAYER" "M" "NADPIS" "C" "red" "0" "LW" 0.15 "0" "")
      (setq kota (getreal "\nEnter base elevation: "))
      (setq nivo (getpoint "\nChose level of base elevation: "))
      (setq os (getpoint "\nChose bottom point at axis of cross section: "))
      
      (setq	a 0.7
    	b 3.25
    	c 7
    	d 0.4
    	)
      (while
      (setq ptn (getpoint "\nChose point: ")) ; Chose point for labeling
      (setq ptnivo (list (car ptn) (cadr nivo)))
      (command "_.pline" "_non" ptn "_non" ptnivo "c")
      (setq endord (getpoint "\nChose bottom point of ordinate: "))
      (setq len (distance ptn endord)) ;Calculate length of ordinate
      (setq kotatochka (+ len kota)) ;Calculate elevation of wanted point
      (setq kotastring (rtos kotatochka 2 2))
      (setq otstoqnie (distance endord os))
      (setq ostring (rtos otstoqnie 2 2))
       (setq nomertochka (getstring "\nEnter point number: "))
      (if (< (car ptn) (car os))
      (command
    		"TEXT" "J" "BL" (list (car ptn) (+ (cadr ptn) d)) 0 nomertochka
    	 )
        (command
    		"TEXT" "J" "BR" (list (car ptn) (+ (cadr ptn) d)) 0 nomertochka
    	 )
        )
      (command
    		"TEXT" "J" "MC" (list (car ptn) (- (cadr ptnivo) b)) 90 kotastring
    	 )
     
      (if (< (car ptn) (car os))
      (command
    		"TEXT" "J" "MC" (list (+ (car ptn) (/ otstoqnie 2)) (- (cadr os) c)) 0 ostring
    	 )
      (command
    		"TEXT" "J" "MC" (list (- (car ptn) (/ otstoqnie 2)) (- (cadr os) c)) 0 ostring
    	 )
      )
      )
    )
    
    (princ  "  \n Author: Deyan Dechev 2013.")
    (princ "   _________________________________________________________\n")
    (princ "      Starting with   nadpis    \n")
    (princ "  \n")
    Sorry thet varibles are not on english but I have some issues when loaded code .
    I'v attached pdf with result from program
    Thanks to everybody!
    Attached Files Attached Files

  10. #10
    Member
    Join Date
    2013-09
    Posts
    20
    Login to Give a bone
    0

    Unhappy Re: Little help with LISP PLS

    Hello again LISP minds
    With the aim to reduce the actions required by the user decided to modify the program for labeling of cross sections, but one problem appears to me that I can not handle. Can't get distance between two points. The user have to take two points with getpoint and the third is combination between the other two.
    Also the program draws a line that strange how is with a doubled length!
    The code i something like that:
    Code:
    (setq pt1(getpoint "\nChose first point: "))
    (setq pt2(getpoint "\nChose second point: "))
    (setq pt3 (list (car pt1) (cadr pt2)))
    (command "_.pline" "_non" pt1 "_non" pt3 "c")
    (initget 64) ;;<--Maybe this is optional in this case, but I do not think it's wrong
    (setq dist (getdist pt1 pt3))
    As result, i get this: error: bad argument type: stringp: "Here is the coordinates of pt3"
    I think the problem is again with the type of user input, but I can not guess the right combination
    I welcome any help.
    Best regards!
    Deyan Dechev

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 13
    Last Post: 2014-01-20, 06:14 PM
  2. NEED HELP WITH LISP ROUTINE - PURGE linetype lisp
    By ECASAOL350033 in forum AutoLISP
    Replies: 6
    Last Post: 2013-06-21, 01:13 AM
  3. Replies: 3
    Last Post: 2012-05-07, 08:16 PM
  4. Replies: 9
    Last Post: 2012-01-21, 07:58 AM

Posting Permissions

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