Author Topic: Lisp not working  (Read 4775 times)

0 Members and 1 Guest are viewing this topic.

Sam

  • Bull Frog
  • Posts: 201
Lisp not working
« on: March 04, 2013, 02:31:21 AM »
Dear sir,
please check this code not working properly. please improve this code.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:RM (/ roomname roomsz)
  2.   (defun roomname ()
  3.     (textpage)
  4.     (princ "\nROOMNAME OPTIONS: ")
  5.     (princ "\n\t Living   Kitchen    Bed     Toilet ")
  6.     (princ "\n\t Office   SHop       STore   STUdy  ")
  7.     (princ "\n\t Dining   Puja       BAth    W.c. = WC  ")
  8.     (princ
  9.       "\n\t LIft = LT    LObby      S.toi.  Living/dining = LD "
  10.     )
  11.     (princ "\n\nPress any key to return to your drawing ")
  12.     (grread)
  13.     (princ "\r                                          ")
  14.     (graphscr)
  15.   )                                     ;End of roomname
  16.  
  17.   (defun roomsz
  18.          (/ p1 p2 p3 p4 x x1 y y1 tx h ht1 rm op pl pm tm ft rsz pll)
  19.                                         ;;(   )
  20.     (if (null txlay)
  21.       (progn
  22.         (setq txlay "tx")
  23.         (setq txlayer (tblsearch "layer" txlay))
  24.         (if (null txlayer)
  25.           (progn
  26.             (setq txlay (getstring "\nLayer name for TEXT : "))
  27.             (setq txclr
  28.                    (getstring (strcat "\nColor for " txlay " layer: "))
  29.             )
  30.             (command "layer" "m" txlay "c" txclr "" "")
  31.           )
  32.           (prompt "\nTEXT ON TX LAYER")
  33.         )
  34.       )
  35.     )
  36.     (setvar "osmode" 32)
  37.     (menucmd "p0=filters")
  38.     (menucmd "p0=*")
  39.     (if (null ht)
  40.       (setq ht "250")
  41.     )
  42.     (setq p1 (getpoint "\nPick room corner: ")
  43.           p2 (getcorner p1 "\nPick Diagonally opposite corner: ")
  44.           p3 (list (car p2) (cadr p1))
  45.           p4 (list (car p1) (cadr p2))
  46.           a  (distance p1 p3)
  47.           b  (distance p1 p4)
  48.           x  (* 0.001 a)
  49.           y  (* 0.001 b)
  50.           x1 (rtos x 2 2)
  51.           y1 (rtos y 2 2)
  52.           mt (strcat x1 "x" y1)
  53.     )
  54.     (setq ix (cvunit x "meter" "inch")
  55.           iy (cvunit y "meter" "inch")
  56.           xf (rtos ix 4 0)
  57.           yf (rtos iy 4 0)
  58.           ft (strcat xf "x" yf)
  59.     )
  60.     (PROMPT "\nENTER FOLLOWING KEYWORD OR TY FOR TYPE")
  61.     (setq cnt T)
  62.     (while cnt
  63.       (initget 1
  64.                (strcat "Living Kitchen Bed Toilet "
  65.                        "Office SHop STore STUdy "
  66.                        "Dining Puja BAth WC TY ? "
  67.                        "LT LObby S.toi. LD "
  68.                )
  69.       )
  70.       (setq rm
  71.              (getkword
  72.                "\nROOM NAME = Liv/Bed/Kit/Toi/Off/Din/SHop/BAth/WC/STore/STUdy/S./LT/LD/LO/TYpe/?:"
  73.              )
  74.       )
  75.       (if (/= (type rm) 'LIST)
  76.         (if (= rm "?")
  77.           (progn
  78.             (roomname)
  79.             (setq cnt T)
  80.           )
  81.           (progn
  82.             (setq cnt nil)
  83.             (if (= rm "LT")
  84.               (setq rm "LIFT")
  85.             )
  86.             (if (= rm "LD")
  87.               (setq rm "living/dining")
  88.             )
  89.             (if (= rm "WC")
  90.               (setq rm "W.C.")
  91.             )
  92.             (IF (= rm "TY")
  93.               (setq rsz (strcase
  94.                           (getstring t "\nTYPE ROOM NAME: ")
  95.                         )
  96.               )
  97.               (setq rsz (strcase rm))
  98.             )
  99.           )
  100.         )
  101.         (setq cnt nil)
  102.       )
  103.     )
  104.     (setq
  105.       tm (strcase (getstring (strcat "\nENTER TEXT HEIGHT <" ht ">:"))
  106.                   t
  107.          )
  108.     )
  109.     (if (/= tm "")
  110.       (setq ht tm)
  111.     )
  112.     (setq h   (atof ht)
  113.           ht1 (* h 0.88888)
  114.           dt  (* h 1.7)
  115.     )
  116.     (setvar "osmode" 0)
  117.     (setvar "orthomode" 1)
  118.     (setq ht1 (fix ht1))
  119.     (setq pc (polar p1 (angle p1 p2) (/ (distance p1 p2) 2))
  120.           pm (polar pc (* pi 1.5) (/ h 3.55))
  121.           pt (polar pc (/ pi 2) dt)
  122.           pf (polar pc (* pi 1.5) dt)
  123.     )
  124.     (command "layer"       "t"    txlay  "on"   txlay  "s"    txlay
  125.              ""     "text" "s"    "rD"   "m"    pt     h      "0"
  126.              rsz
  127.             )
  128.     (setq pm2 (getpoint pm "\nENDPOINT OF TEXT: ")
  129.           PM1 (polar pm pi (distance pm pm2))
  130.           pf1 (polar pf pi (distance pm pm2))
  131.           pf2 (polar pf 0 (distance pm pm2))
  132.     )
  133.     (command "text" "s" "rs" "f" pm1 pm2 ht1 mt "text" "f" pf1 pf2 ht1
  134.              ft)
  135.     ;;(   )
  136.   )
  137. )
  138.  
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Lisp not working
« Reply #1 on: March 04, 2013, 03:55:49 AM »
Dear sir,
please check this code not working properly. please improve this code.


No need for this

Code: [Select]
...

  (defun roomsz
(/ p1 p2 p3 p4 x x1 y y1 tx h ht1 rm op pl pm tm ft rsz pll)
;;(   )
...
  )

Sam

  • Bull Frog
  • Posts: 201
Re: Lisp not working
« Reply #2 on: March 04, 2013, 04:04:41 AM »
Dear sir,
please check this code not working properly. please improve this code.


No need for this

Code: [Select]
...

  (defun roomsz
(/ p1 p2 p3 p4 x x1 y y1 tx h ht1 rm op pl pm tm ft rsz pll)
;;(   )
...
  )

dear sir,
after removing code some error
Quote
; warning: local variable used as function: ROOMNAME
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Lisp not working
« Reply #3 on: March 04, 2013, 10:44:03 AM »
This will give you something to play with.
Look into the TEXTBOX function

Code: [Select]
(defun c:rm (/ A B BOX CNT DIS DT FT H HT HT1 IX IY MT P1 P2 P3 P4 PF PM PT
             RM RSZ TM TXCLR TXLAY TXLAYER TXT X X1 XF Y Y1 YF)
  (defun rn_help ()
    (textpage)
    (princ "\nROOMNAME OPTIONS: ")
    (princ "\n\t Living   Kitchen    Bed     Toilet ")
    (princ "\n\t Office   SHop       STore   STUdy  ")
    (princ "\n\t Dining   Puja       BAth    W.c. = WC  ")
    (princ "\n\t LIft = LT    LObby      S.toi.  Living/dining = LD ")
    (princ "\n\nPress any key to return to your drawing ")
    (grread)
    (princ "\r                                          ")
    (graphscr)
  ) ;End of rn_help
 
  ;;  layer Make or set current
  (defun LayerMake(lyrname Color ltype Other)
    (if (tblsearch "LAYER" lyrname)
      (progn
        (command "._Layer" "_Thaw" lyrname "_On" lyrname "_UnLock" lyrname "_Set" lyrname)
        (if (or (null other) (= Other "")) (command "") (command Other  lyrname ""))
      )
      (progn
        (command "._Layer" "_Make" lyrname "_Color"
               (if (or (null color)(= Color "")) "_White" Color) lyrname
               "LT" (if (or (null ltype)(= ltype "")) "Continuous" ltype) lyrname)
        (if (or (null other) (= Other "")) (command "") (command Other  lyrname ""))
      )
    )
  )
 
  (defun MakeText (pt10 pt11 lay sty ht str / dxf72)
    (if (< (distance pt10 pt11) 0.00001)
      (setq dxf72 1)
      (setq dxf72 5)
    )
    (entmakex (list (cons 0 "TEXT") ; ***
                   (cons 1 str) ; * (the string itself)
                   ;; (cons 6 "BYLAYER")  ; Linetype name
                   ;(cons 7 sty) ; * Text style name, defaults to STANDARD, not current
                   (cons 8 lay)   ; layer
                   (cons 10 pt10) ; * First alignment point (in OCS)
                   (cons 11 pt11) ; * Second alignment point (in OCS)
                   (cons 39 0.0) ; Thickness (optional; default = 0)
                   (cons 40 ht) ; * Text height
                   (cons 41 1.0) ; Relative X scale factor, Width Factor, defaults to 1.0
                   (cons 50 0.0) ; Text rotation ange
                   ;; (cons 51 0.0) ; Oblique angle
                   ;; (cons 62 256) ; color
                   ;;(cons 71 0)   ; Text generation flags
                   (cons 72 dxf72)   ; Horizontal text justification type
                   ;;(cons 73 0)   ; Vertical text justification type
                   )))
 
    (if (and (null txlay)(null (setq txlayer (tblsearch "layer" (setq txlay "tx")))))
          (progn
            (setq txlay (getstring "\nLayer name for TEXT : "))
            (setq txclr (getstring (strcat "\nColor for " txlay " layer: ")))
            (LayerMake txlay txclr nil nil)
          )
          (prompt "\nTEXT ON TX LAYER")
    )
    (setvar "osmode" 32)
    ;(menucmd "p0=filters")
    ;(menucmd "p0=*")
    (or ht (setq ht "250"))
    (setq p1 (getpoint "\nPick room corner: ")
          p2 (getcorner p1 "\nPick Diagonally opposite corner: ")
          p3 (list (car p2) (cadr p1))
          p4 (list (car p1) (cadr p2))
          a  (distance p1 p3)
          b  (distance p1 p4)
          x  (* 0.001 a)
          y  (* 0.001 b)
          x1 (rtos x 2 2)
          y1 (rtos y 2 2)
          mt (strcat x1 "x" y1)
    )
    (setq ix (cvunit x "meter" "inch")
          iy (cvunit y "meter" "inch")
          xf (rtos ix 4 0)
          yf (rtos iy 4 0)
          ft (strcat xf "x" yf)
    )
    (prompt "\nENTER FOLLOWING KEYWORD OR TY FOR TYPE")
    (setq cnt t)
    (while
     (not (progn
      (initget 1
               (strcat "Living Kitchen Bed Toilet "
                       "Office SHop STore STUdy "
                       "Dining Puja BAth WC TY ? "
                       "LT LObby S.toi. LD "
               )
      )
      (setq rm (getkword
         "\nROOM NAME = Liv/Bed/Kit/Toi/Off/Din/SHop/BAth/WC/STore/STUdy/S./LT/LD/LO/TYpe/?:"
       )
      )
      (cond
        ((= rm "?") (rn_help))
        ((= rm "LT") (setq rm "LIFT"))
        ((= rm "LD") (setq rm "living/dining"))
        ((= rm "WC") (setq rm "W.C."))
        ((= rm "TY") (setq rsz (strcase (getstring t "\nTYPE ROOM NAME: "))))
        (t (setq rsz (strcase rm)))
      )
     )) ; not progn
    ) ; while
    (setq tm (strcase (getstring (strcat "\nENTER TEXT HEIGHT <" ht ">:")) t))
    (if (/= tm "")
      (setq ht tm)
    )
    (setq h   (atof ht)
          ht1 (* h 0.9)
          dt  (* h 2.0)
    )
    (setvar "osmode" 0)
    (setvar "orthomode" 1)
    (setq ht1 (fix ht1))
    (setq pt (polar p1 (angle p1 p2) (/ (distance p1 p2) 2))
          pm (polar pt (* pi 1.5) (/ h 3.55))
          pf (polar pt (* pi 1.5) dt)
    )
    (setq txt (MakeText pt pt txlay "rD" h rsz)) ; Center Bottom
    (setq box (textbox (entget txt))
          dis (/ (caadr box) 2.))
    (MakeText (polar pm 0  dis) (polar pm pi dis) txlay "rs" ht1 mt)
    (MakeText (polar pf pi dis) (polar pf 0  dis) txlay "rs" ht1 ft)
  (princ)
)

<code updated with the TextBox function>
« Last Edit: March 04, 2013, 12:13:30 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Sam

  • Bull Frog
  • Posts: 201
Re: Lisp not working
« Reply #4 on: March 04, 2013, 11:52:17 PM »
This will give you something to play with.
Look into the TEXTBOX function

Code: [Select]
(defun c:rm (/ A B BOX CNT DIS DT FT H HT HT1 IX IY MT P1 P2 P3 P4 PF PM PT
             RM RSZ TM TXCLR TXLAY TXLAYER TXT X X1 XF Y Y1 YF)
  (defun rn_help ()
    (textpage)
    (princ "\nROOMNAME OPTIONS: ")
    (princ "\n\t Living   Kitchen    Bed     Toilet ")
    (princ "\n\t Office   SHop       STore   STUdy  ")
    (princ "\n\t Dining   Puja       BAth    W.c. = WC  ")
    (princ "\n\t LIft = LT    LObby      S.toi.  Living/dining = LD ")
    (princ "\n\nPress any key to return to your drawing ")
    (grread)
    (princ "\r                                          ")
    (graphscr)
  ) ;End of rn_help
 
  ;;  layer Make or set current
  (defun LayerMake(lyrname Color ltype Other)
    (if (tblsearch "LAYER" lyrname)
      (progn
        (command "._Layer" "_Thaw" lyrname "_On" lyrname "_UnLock" lyrname "_Set" lyrname)
        (if (or (null other) (= Other "")) (command "") (command Other  lyrname ""))
      )
      (progn
        (command "._Layer" "_Make" lyrname "_Color"
               (if (or (null color)(= Color "")) "_White" Color) lyrname
               "LT" (if (or (null ltype)(= ltype "")) "Continuous" ltype) lyrname)
        (if (or (null other) (= Other "")) (command "") (command Other  lyrname ""))
      )
    )
  )
 
  (defun MakeText (pt10 pt11 lay sty ht str / dxf72)
    (if (< (distance pt10 pt11) 0.00001)
      (setq dxf72 1)
      (setq dxf72 5)
    )
    (entmakex (list (cons 0 "TEXT") ; ***
                   (cons 1 str) ; * (the string itself)
                   ;; (cons 6 "BYLAYER")  ; Linetype name
                   ;(cons 7 sty) ; * Text style name, defaults to STANDARD, not current
                   (cons 8 lay)   ; layer
                   (cons 10 pt10) ; * First alignment point (in OCS)
                   (cons 11 pt11) ; * Second alignment point (in OCS)
                   (cons 39 0.0) ; Thickness (optional; default = 0)
                   (cons 40 ht) ; * Text height
                   (cons 41 1.0) ; Relative X scale factor, Width Factor, defaults to 1.0
                   (cons 50 0.0) ; Text rotation ange
                   ;; (cons 51 0.0) ; Oblique angle
                   ;; (cons 62 256) ; color
                   ;;(cons 71 0)   ; Text generation flags
                   (cons 72 dxf72)   ; Horizontal text justification type
                   ;;(cons 73 0)   ; Vertical text justification type
                   )))
 
    (if (and (null txlay)(null (setq txlayer (tblsearch "layer" (setq txlay "tx")))))
          (progn
            (setq txlay (getstring "\nLayer name for TEXT : "))
            (setq txclr (getstring (strcat "\nColor for " txlay " layer: ")))
            (LayerMake txlay txclr nil nil)
          )
          (prompt "\nTEXT ON TX LAYER")
    )
    (setvar "osmode" 32)
    ;(menucmd "p0=filters")
    ;(menucmd "p0=*")
    (or ht (setq ht "250"))
    (setq p1 (getpoint "\nPick room corner: ")
          p2 (getcorner p1 "\nPick Diagonally opposite corner: ")
          p3 (list (car p2) (cadr p1))
          p4 (list (car p1) (cadr p2))
          a  (distance p1 p3)
          b  (distance p1 p4)
          x  (* 0.001 a)
          y  (* 0.001 b)
          x1 (rtos x 2 2)
          y1 (rtos y 2 2)
          mt (strcat x1 "x" y1)
    )
    (setq ix (cvunit x "meter" "inch")
          iy (cvunit y "meter" "inch")
          xf (rtos ix 4 0)
          yf (rtos iy 4 0)
          ft (strcat xf "x" yf)
    )
    (prompt "\nENTER FOLLOWING KEYWORD OR TY FOR TYPE")
    (setq cnt t)
    (while
     (not (progn
      (initget 1
               (strcat "Living Kitchen Bed Toilet "
                       "Office SHop STore STUdy "
                       "Dining Puja BAth WC TY ? "
                       "LT LObby S.toi. LD "
               )
      )
      (setq rm (getkword
         "\nROOM NAME = Liv/Bed/Kit/Toi/Off/Din/SHop/BAth/WC/STore/STUdy/S./LT/LD/LO/TYpe/?:"
       )
      )
      (cond
        ((= rm "?") (rn_help))
        ((= rm "LT") (setq rm "LIFT"))
        ((= rm "LD") (setq rm "living/dining"))
        ((= rm "WC") (setq rm "W.C."))
        ((= rm "TY") (setq rsz (strcase (getstring t "\nTYPE ROOM NAME: "))))
        (t (setq rsz (strcase rm)))
      )
     )) ; not progn
    ) ; while
    (setq tm (strcase (getstring (strcat "\nENTER TEXT HEIGHT <" ht ">:")) t))
    (if (/= tm "")
      (setq ht tm)
    )
    (setq h   (atof ht)
          ht1 (* h 0.9)
          dt  (* h 2.0)
    )
    (setvar "osmode" 0)
    (setvar "orthomode" 1)
    (setq ht1 (fix ht1))
    (setq pt (polar p1 (angle p1 p2) (/ (distance p1 p2) 2))
          pm (polar pt (* pi 1.5) (/ h 3.55))
          pf (polar pt (* pi 1.5) dt)
    )
    (setq txt (MakeText pt pt txlay "rD" h rsz)) ; Center Bottom
    (setq box (textbox (entget txt))
          dis (/ (caadr box) 2.))
    (MakeText (polar pm 0  dis) (polar pm pi dis) txlay "rs" ht1 mt)
    (MakeText (polar pf pi dis) (polar pf 0  dis) txlay "rs" ht1 ft)
  (princ)
)

<code updated with the TextBox function>
Dear Sir,
Thx for Help

Some error are come


Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Lisp not working
« Reply #5 on: March 05, 2013, 11:22:35 AM »
Lisp revised.
Code: [Select]
(defun c:rm (/ A B BOX CNT DIS DT FT H HT HT1 IX IY MT P1 P2 P3 P4 PF PM PT
             RM RSZ TM TXCLR TXLAY TXLAYER TXT X X1 XF Y Y1 YF)
  (defun rn_help ()
    (textpage)
    (princ "\nROOMNAME OPTIONS: ")
    (princ "\n\t Living   Kitchen    Bed     Toilet ")
    (princ "\n\t Office   SHop       STore   STUdy  ")
    (princ "\n\t Dining   Puja       BAth    W.c. = WC  ")
    (princ "\n\t LIft = LT    LObby      S.toi.  Living/dining = LD ")
    (princ "\n\nPress any key to return to your drawing ")
    (grread)
    (princ "\r                                          ")
    (graphscr)
  ) ;End of rn_help
 
  ;;  layer Make or set current
  (defun LayerMake(lyrname Color ltype Other)
    (if (tblsearch "LAYER" lyrname)
      (progn
        (command "._Layer" "_Thaw" lyrname "_On" lyrname "_UnLock" lyrname "_Set" lyrname)
        (if (or (null other) (= Other "")) (command "") (command Other  lyrname ""))
      )
      (progn
        (command "._Layer" "_Make" lyrname "_Color"
               (if (or (null color)(= Color "")) "_White" Color) lyrname
               "LT" (if (or (null ltype)(= ltype "")) "Continuous" ltype) lyrname)
        (if (or (null other) (= Other "")) (command "") (command Other  lyrname ""))
      )
    )
  )
 
  (defun MakeText (pt10 pt11 lay sty ht str / dxf72)
    (if (< (distance pt10 pt11) 0.00001)
      (setq dxf72 1)
      (setq dxf72 5)
    )
    (entmakex (list (cons 0 "TEXT") ; ***
                   (cons 1 str) ; * (the string itself)
                   ;; (cons 6 "BYLAYER")  ; Linetype name
                   ;(cons 7 sty) ; * Text style name, defaults to STANDARD, not current
                   (cons 8 lay)   ; layer
                   (cons 10 pt10) ; * First alignment point (in OCS)
                   (cons 11 pt11) ; * Second alignment point (in OCS)
                   (cons 39 0.0) ; Thickness (optional; default = 0)
                   (cons 40 ht) ; * Text height
                   (cons 41 1.0) ; Relative X scale factor, Width Factor, defaults to 1.0
                   (cons 50 0.0) ; Text rotation ange
                   ;; (cons 51 0.0) ; Oblique angle
                   ;; (cons 62 256) ; color
                   (cons 71 0)   ; Text generation flags
                   (cons 72 dxf72)   ; Horizontal text justification type
                   ;;(cons 73 0)   ; Vertical text justification type
                   )))
 
    (if (and (null txlay)(null (setq txlayer (tblsearch "layer" (setq txlay "tx")))))
          (progn
            (setq txlay (getstring "\nLayer name for TEXT : "))
            (setq txclr (getstring (strcat "\nColor for " txlay " layer: ")))
            (LayerMake txlay txclr nil nil)
          )
          (prompt "\nTEXT ON TX LAYER")
    )
    (setvar "osmode" 32)
    ;(menucmd "p0=filters")
    ;(menucmd "p0=*")
    (or ht (setq ht "250"))
    (setq p1 (getpoint "\nPick room corner: ")
          p2 (getcorner p1 "\nPick Diagonally opposite corner: ")
          p3 (list (car p2) (cadr p1))
          p4 (list (car p1) (cadr p2))
          a  (distance p1 p3)
          b  (distance p1 p4)
          x  (* 0.001 a)
          y  (* 0.001 b)
          x1 (rtos x 2 2)
          y1 (rtos y 2 2)
          mt (strcat x1 "x" y1)
    )
    (setq ix (cvunit x "meter" "inch")
          iy (cvunit y "meter" "inch")
          xf (rtos ix 4 0)
          yf (rtos iy 4 0)
          ft (strcat xf "x" yf)
    )
    (prompt "\nENTER FOLLOWING KEYWORD OR TY FOR TYPE")
    (setq cnt t)
    (while
     (not (progn
      (initget 1
               (strcat "Living Kitchen Bed Toilet "
                       "Office SHop STore STUdy "
                       "Dining Puja BAth WC TY ? "
                       "LT LObby S.toi. LD "
               )
      )
      (setq rm (getkword
         "\nROOM NAME = Liv/Bed/Kit/Toi/Off/Din/SHop/BAth/WC/STore/STUdy/S./LT/LD/LO/TYpe/?:"
       )
      )
      (cond
        ((= rm "?") (rn_help))
        ((= rm "LT") (setq rsz "LIFT"))
        ((= rm "LD") (setq rsz "living/dining"))
        ((= rm "WC") (setq rsz "W.C."))
        ((= rm "TY") (setq rsz (strcase (getstring t "\nTYPE ROOM NAME: "))))
        (t (setq rsz (strcase rm)))
      )
     )) ; not progn
    ) ; while
    (setq tm (strcase (getstring (strcat "\nENTER TEXT HEIGHT <" ht ">:")) t))
    (if (/= tm "")
      (setq ht tm)
    )
    (setq h   (atof ht)
          ht1 (* h 0.9)
          dt  (* h 2.0)
    )
    (setvar "osmode" 0)
    (setvar "orthomode" 1)
    (setq ht1 (fix ht1))
    (setq pt (polar p1 (angle p1 p2) (/ (distance p1 p2) 2)) ; mid point
          pm (polar pt (* pi 1.5) (* h 1.7))
          pf (polar pm (* pi 1.5) (* h 1.7))
    )
    (setq txt (MakeText pt pt txlay "rD" h rsz)) ; Center Bottom
    (setq box (textbox (entget txt))
          dis (abs (/ (caadr box) 2.)))
    (MakeText (polar pm pi  dis) (polar pm 0 dis) txlay "rs" ht1 mt)
    (MakeText (polar pf pi dis) (polar pf 0  dis) txlay "rs" ht1 ft)
  (princ)
)
« Last Edit: March 05, 2013, 11:31:04 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Sam

  • Bull Frog
  • Posts: 201
Re: Lisp not working
« Reply #6 on: March 05, 2013, 11:37:20 PM »
Lisp revised.
Code: [Select]
(defun c:rm (/ A B BOX CNT DIS DT FT H HT HT1 IX IY MT P1 P2 P3 P4 PF PM PT
             RM RSZ TM TXCLR TXLAY TXLAYER TXT X X1 XF Y Y1 YF)
  (defun rn_help ()
    (textpage)
    (princ "\nROOMNAME OPTIONS: ")
    (princ "\n\t Living   Kitchen    Bed     Toilet ")
    (princ "\n\t Office   SHop       STore   STUdy  ")
    (princ "\n\t Dining   Puja       BAth    W.c. = WC  ")
    (princ "\n\t LIft = LT    LObby      S.toi.  Living/dining = LD ")
    (princ "\n\nPress any key to return to your drawing ")
    (grread)
    (princ "\r                                          ")
    (graphscr)
  ) ;End of rn_help
 
  ;;  layer Make or set current
  (defun LayerMake(lyrname Color ltype Other)
    (if (tblsearch "LAYER" lyrname)
      (progn
        (command "._Layer" "_Thaw" lyrname "_On" lyrname "_UnLock" lyrname "_Set" lyrname)
        (if (or (null other) (= Other "")) (command "") (command Other  lyrname ""))
      )
      (progn
        (command "._Layer" "_Make" lyrname "_Color"
               (if (or (null color)(= Color "")) "_White" Color) lyrname
               "LT" (if (or (null ltype)(= ltype "")) "Continuous" ltype) lyrname)
        (if (or (null other) (= Other "")) (command "") (command Other  lyrname ""))
      )
    )
  )
 
  (defun MakeText (pt10 pt11 lay sty ht str / dxf72)
    (if (< (distance pt10 pt11) 0.00001)
      (setq dxf72 1)
      (setq dxf72 5)
    )
    (entmakex (list (cons 0 "TEXT") ; ***
                   (cons 1 str) ; * (the string itself)
                   ;; (cons 6 "BYLAYER")  ; Linetype name
                   ;(cons 7 sty) ; * Text style name, defaults to STANDARD, not current
                   (cons 8 lay)   ; layer
                   (cons 10 pt10) ; * First alignment point (in OCS)
                   (cons 11 pt11) ; * Second alignment point (in OCS)
                   (cons 39 0.0) ; Thickness (optional; default = 0)
                   (cons 40 ht) ; * Text height
                   (cons 41 1.0) ; Relative X scale factor, Width Factor, defaults to 1.0
                   (cons 50 0.0) ; Text rotation ange
                   ;; (cons 51 0.0) ; Oblique angle
                   ;; (cons 62 256) ; color
                   (cons 71 0)   ; Text generation flags
                   (cons 72 dxf72)   ; Horizontal text justification type
                   ;;(cons 73 0)   ; Vertical text justification type
                   )))
 
    (if (and (null txlay)(null (setq txlayer (tblsearch "layer" (setq txlay "tx")))))
          (progn
            (setq txlay (getstring "\nLayer name for TEXT : "))
            (setq txclr (getstring (strcat "\nColor for " txlay " layer: ")))
            (LayerMake txlay txclr nil nil)
          )
          (prompt "\nTEXT ON TX LAYER")
    )
    (setvar "osmode" 32)
    ;(menucmd "p0=filters")
    ;(menucmd "p0=*")
    (or ht (setq ht "250"))
    (setq p1 (getpoint "\nPick room corner: ")
          p2 (getcorner p1 "\nPick Diagonally opposite corner: ")
          p3 (list (car p2) (cadr p1))
          p4 (list (car p1) (cadr p2))
          a  (distance p1 p3)
          b  (distance p1 p4)
          x  (* 0.001 a)
          y  (* 0.001 b)
          x1 (rtos x 2 2)
          y1 (rtos y 2 2)
          mt (strcat x1 "x" y1)
    )
    (setq ix (cvunit x "meter" "inch")
          iy (cvunit y "meter" "inch")
          xf (rtos ix 4 0)
          yf (rtos iy 4 0)
          ft (strcat xf "x" yf)
    )
    (prompt "\nENTER FOLLOWING KEYWORD OR TY FOR TYPE")
    (setq cnt t)
    (while
     (not (progn
      (initget 1
               (strcat "Living Kitchen Bed Toilet "
                       "Office SHop STore STUdy "
                       "Dining Puja BAth WC TY ? "
                       "LT LObby S.toi. LD "
               )
      )
      (setq rm (getkword
         "\nROOM NAME = Liv/Bed/Kit/Toi/Off/Din/SHop/BAth/WC/STore/STUdy/S./LT/LD/LO/TYpe/?:"
       )
      )
      (cond
        ((= rm "?") (rn_help))
        ((= rm "LT") (setq rsz "LIFT"))
        ((= rm "LD") (setq rsz "living/dining"))
        ((= rm "WC") (setq rsz "W.C."))
        ((= rm "TY") (setq rsz (strcase (getstring t "\nTYPE ROOM NAME: "))))
        (t (setq rsz (strcase rm)))
      )
     )) ; not progn
    ) ; while
    (setq tm (strcase (getstring (strcat "\nENTER TEXT HEIGHT <" ht ">:")) t))
    (if (/= tm "")
      (setq ht tm)
    )
    (setq h   (atof ht)
          ht1 (* h 0.9)
          dt  (* h 2.0)
    )
    (setvar "osmode" 0)
    (setvar "orthomode" 1)
    (setq ht1 (fix ht1))
    (setq pt (polar p1 (angle p1 p2) (/ (distance p1 p2) 2)) ; mid point
          pm (polar pt (* pi 1.5) (* h 1.7))
          pf (polar pm (* pi 1.5) (* h 1.7))
    )
    (setq txt (MakeText pt pt txlay "rD" h rsz)) ; Center Bottom
    (setq box (textbox (entget txt))
          dis (abs (/ (caadr box) 2.)))
    (MakeText (polar pm pi  dis) (polar pm 0 dis) txlay "rs" ht1 mt)
    (MakeText (polar pf pi dis) (polar pf 0  dis) txlay "rs" ht1 ft)
  (princ)
)

Dear Sir,

Thx Lisp working
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Lisp not working
« Reply #7 on: March 06, 2013, 08:45:01 AM »
You are welcome Sam.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Sam

  • Bull Frog
  • Posts: 201
Re: Lisp not working
« Reply #8 on: March 11, 2013, 01:00:12 AM »
Dear Sir,

How to reduce gap between 2 text
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Lisp not working
« Reply #9 on: March 11, 2013, 03:42:17 AM »
Dear Sir,

How to reduce gap between 2 text

Play with number 1.7 in this
Code: [Select]
(setq pt (polar p1 (angle p1 p2) (/ (distance p1 p2) 2)) ; mid point
          pm (polar pt (* pi 1.5) (* h 1.7))
          pf (polar pm (* pi 1.5) (* h 1.7))
    )

Sam

  • Bull Frog
  • Posts: 201
Re: Lisp not working
« Reply #10 on: March 11, 2013, 05:31:58 AM »
Dear Sir,

How to reduce gap between 2 text

Play with number 1.7 in this


Dear Sir,
Thx ...
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Lisp not working
« Reply #11 on: March 11, 2013, 10:38:15 AM »
Dear Sir,
Thx ...
You are most welcome

REGHUYES

  • Newt
  • Posts: 21
Re: Lisp not working
« Reply #12 on: March 15, 2013, 10:30:34 PM »
how to modify the second line of text as per attached image

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Lisp not working
« Reply #13 on: March 16, 2013, 08:15:26 AM »
Change
    (setq box (textbox (entget txt))
          dis (abs (/ (caadr box) 2.)))
    (MakeText (polar pm pi  dis) (polar pm 0 dis) txlay "rs" ht1 mt)
    (MakeText (polar pf pi dis) (polar pf 0  dis) txlay "rs" ht1 ft)

to
    (MakeText pm pm txlay "rs" ht1 mt)
    (MakeText pf pf txlay "rs" ht1 ft)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

REGHUYES

  • Newt
  • Posts: 21
Re: Lisp not working
« Reply #14 on: March 18, 2013, 05:29:36 AM »
Thank u very much CAB.u r really helping others.thanks

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Lisp not working
« Reply #15 on: March 18, 2013, 09:42:35 AM »
Glad to help.
Hope you are learning more about the power of LISP.  8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Sam

  • Bull Frog
  • Posts: 201
Re: Lisp not working
« Reply #16 on: April 15, 2013, 02:17:56 AM »
Dear sir,

i am add dcl but not working properly??? , 

please help me complete my task..

 
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html