Jump to content

Is it possible to combine these 2 lisp's


Recommended Posts

Posted

Would it be difficult to combine these 2 numbering lisp routines? I would like one that draws a polygon around the Numbers & TXT. I've been able to figure out how to edit these a little but no luck and combining the features.

 

 

; inserts increasing numbers inside polygon
(defun c:iwn (/ p n ni ts oecho ds th txt na)


 (if (= 0 (getvar "dimscale"))(setq ds 1.0)(setq ds (getvar "dimscale")))
 (setq th (getvar "dimtxt"))
 (setq txt (* th ds))
 (setq ts txt)
 (if nn (setq nn (fix nn))(setq nn 1))
 (if (= nn 0)(setq nn 1))
 (princ "\n Increment by < ")
 (princ nn)
 (princ " >? : ")
 (setq ni (getint))
 (if (= ni nil)(setq ni nn)(setq nn ni))

 (if np
   ()
   (setq np 1)
 )
 (princ "\n Start or continue with number < ")
 (princ np)
 (princ " >? : ")
 (setq n (getint))
 (if (= n nil)
   (setq n np)
   (setq np n)
 )
 (setq p (getpoint "\n Number location: "))
 (setq oecho (getvar "cmdecho"))
 (setvar "cmdecho" 0)

 (while p
   (setq na (itoa n))
   (entmake (list (cons 0 "TEXT") 
     (cons 10 p) 
     (cons 11 p) 
     (cons 1 na); actual text
     (cons 7 (getvar "TEXTSTYLE"))
     (cons 40 txt)
     (cons 72 4)
      )
    )
   (if (> n 99)
     (command "polygon" "5" p "c" (* ts 1.4))     ; edit for number of polygon sides
     (command "polygon" "5" p "c" (* ts 1.4)))    ; edit for number of polygon sides
   (setq p (getpoint "\n Next number location: ")
  n (+ ni n)
  np n
   )
 )

 (setvar "cmdecho" oecho)
 (princ)
)
(princ "\n Type > iwn <  to insert numbers inside hexagon")

 

The second one allows Prefix and suffix TXT.

 

 

;;; TX+INTEGERS+TX
(defun c:tit (/ p n ni pref suff nns ntx ntxx oecho osn ds th txt)
 (setq oecho (getvar "cmdecho")
osn   (getvar "osmode")
 )
 (if (= 0 (getvar "dimscale"))(setq ds 1.0)(setq ds (getvar "dimscale")))
 (setq th (getvar "dimtxt"))
 (setq txt (* th ds))
 (setvar "cmdecho" 0)
 (setvar "osmode" 0)
 (if nn
   (setq nn (fix nn))
   (setq nn 1)
 )
 (if (= nn 0)(setq nn 1))
 (princ "\n Increment numbers by < ")
 (princ nn)
 (princ " >? : ")
 (setq ni (getint))
 (if (= ni nil)
   (setq ni nn)
   (setq nn ni)
 )
 (if np
   (setq np (fix np))
   (setq np nn)
 )
 (princ "\n Start or continue with number < ")
 (princ np)
 (princ " >? : ")
 (setq n (getint))
 (if (= n nil)
   (setq n np)
   (setq np n)
 )
 (setq nns (itoa n))
 (princ "\n Prefix text < ")
 (princ pre)
 (princ " >? or <.> for none: ")
 (setq pref (getstring t))
 (if (= pref ".")
   (progn
     (setq pre nil)
     (setq pref nil)
   )
   (progn
     (if (= pref "")
(setq pref pre)
(setq pre pref)
     )
     (if pref
  (setq ntx (strcat pref nns))
     )
   )
 )
 (princ "\n Suffix text < ")
 (princ suf)
 (princ " >? or <.> for none: ")
 (setq suff (getstring t))
 (if (= suff ".")
   (progn
     (setq suf nil)
     (setq suff nil)
   )
   (progn
     (if (= suff "")
(setq suff suf)
(setq suf suff)
     )
     (if suff
(if pref
  (setq ntxx (strcat pref nns suff))
  (setq ntxx (strcat nns suff))
)
     )
   )
 )
 (setq p (getpoint "\n Insert: "))
 (setq oecho (getvar "cmdecho"))
 (while p
   (if suff
     ;(command "text" "j" "mc" p "" "" ntxx)
     (entmake (list (cons 0 "TEXT")
      (cons 10 p)
      (cons 11 p)
      (cons 1 ntxx) ; actual text
      (cons 7 (getvar "TEXTSTYLE"))
      (cons 40 txt)
      (cons 72 4)
       )
     )
     (if pref
;(command "text" "j" "mc" p "" "" ntx)
(entmake (list (cons 0 "TEXT") 
     (cons 10 p) 
     (cons 11 p) 
     (cons 1 ntx); actual text
     (cons 7 (getvar "TEXTSTYLE"))
     (cons 40 txt)
     (cons 72 4)
      )
    )
;(command "text" "j" "mc" p "" "" n)
(entmake (list (cons 0 "TEXT") 
     (cons 10 p) 
     (cons 11 p) 
     (cons 1 n); actual text
     (cons 7 (getvar "TEXTSTYLE"))
     (cons 40 txt)
     (cons 72 4)
      )
    )
     )
   )
   (setq p   (getpoint "\n Next number location: ")
  n   (+ ni n)
  nns (itoa n)
  np n
   )

   (if suff
     (if pref
(setq ntxx (strcat pref nns suff))
(setq ntxx (strcat nns suff))
     )
   )
   (if pref
     (if suff
(setq ntxx (strcat pref nns suff))
(setq ntx (strcat pref nns))
     )
   )
 )
 (setvar "cmdecho" oecho)
 (setvar "osmode" osn)
 (princ)
)
(princ "\n Type > TIT <  to insert text with ascending integers.")

Posted

Hi GhostRider,

Test this code maybe you want like this

(defun c:test (/ ds n ni nn nns np ntx ntxx oecho osn p pre pref suf suff th ts txt)
  (setq oecho (getvar "cmdecho"))
  (if
     (/= oecho 0)
     (setvar "cmdecho" 0)
     ) ; if
  (setq osn (getvar "osmode"))
  (if
     (= 0 (getvar "dimscale"))
     (setq ds 1.0)
     (setq ds (getvar "dimscale"))
     ) ; if
  (setq th (getvar "dimtxt"))
  (setq txt (* th ds))   
  (setq ts txt)   
  (setvar "cmdecho" 0)
  (setvar "osmode" 0)
  (if
     nn
     (setq nn (fix nn))
     (setq nn 1)
     ) ; if
  (if (= nn 0)(setq nn 1))
  (setq ni (getint (strcat "\n Increment numbers by < " (itoa nn) " >? : ")))
  (if
     (= ni nil)
     (setq ni nn)
     (setq nn ni)
     ) ; if
  (if
     np
     (setq np (fix np))
     (setq np nn)
     ) ; if
  (setq n (getint (strcat "\n Start or continue with number < " (itoa np) " >? : ")))
  (if
     (= n nil)
     (setq n np)
     (setq np n)
     ) ; if
  (setq nns (itoa n))
  (setq pre "A")
  (setq pref (getstring t (strcat "\n Prefix text < " pre " >? or <.> for none: "))) ; ??!!
  (if
     (= pref ".")
     (progn
        (setq pre nil)
        (setq pref nil)
        ) ; progn
     (progn
        (if (= pref "")
           (setq pref pre)
           (setq pre pref)
           ) ; if
        (if pref
           (setq ntx (strcat pref nns))
           ) ; if
        )    ; progn
     )       ; if
  (setq suf "Z")
  (setq suff (getstring t (strcat "\n Suffix text < " suf " >? or <.> for none: ")))
  (if
     (= suff ".")
     (progn
        (setq suf nil)
        (setq suff nil)
        ) ; progn
     (progn
        (if (= suff "")
           (setq suff suf)
           (setq suf suff)
           ) ; if
        (if suff
           (if pref
              (setq ntxx (strcat pref nns suff))
              (setq ntxx (strcat nns suff))
              ) ; if
           )    ; if
        )       ; progn
     )          ; if
  (setq p (getpoint "\n Insert: "))
  (while
     p
     (if
        suff
        (entmake (list (cons 0 "TEXT")
                       (cons 10 p)
                       (cons 11 p)
                       (cons 1 ntxx) ; actual text
                       (cons 7 (getvar "TEXTSTYLE"))
                       (cons 40 txt)
                       (cons 72 4)))
        (if
           pref
           (entmake (list (cons 0 "TEXT")
                          (cons 10 p)
                          (cons 11 p)
                          (cons 1 ntx); actual text
                          (cons 7 (getvar "TEXTSTYLE"))
                          (cons 40 txt)
                          (cons 72 4)))
           (entmake (list (cons 0 "TEXT")
                          (cons 10 p)
                          (cons 11 p)
                          (cons 1 n); actual text
                          (cons 7 (getvar "TEXTSTYLE"))
                          (cons 40 txt)
                          (cons 72 4)))
           ) ; if
        )    ; if
     (command "polygon" "5" p "c" (* ts 1.5))
     (setq p (getpoint "\n Next number location: "))
     (setq n (+ ni n))
     (setq nns (itoa n))
     (if
        suff
        (if
           pref
           (setq ntxx (strcat pref nns suff))
           (setq ntxx (strcat nns suff))
           ) ; if
        )    ; if
     (if
        pref
        (if
           suff
           (setq ntxx (strcat pref nns suff))
           (setq ntx (strcat pref nns))
           ) ; if
        )    ; if
     )       ; while
  (setvar "cmdecho" oecho)
  (setvar "osmode" osn)
  (princ)
  )

Posted

Adesu, Thank you very much for taking the time to do that for me. I use this often. I thought I could figure it out but it is a little more advanced than I understand .

It works great...

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...