Jump to content

Set Text height in this lisp?


Kurpulio

Recommended Posts

Hello, 

 

I got this LISP for automatically placing texts with incremental number vaues (e.g. for room numbering) (from here https://www.youtube.com/watch?v=5q6ssb3p_tk )

It requires command 'TIT'

 

By default it places texts with '2.5' height, which is always too small compared to my drawing. 

 

It'd be awesome if this .lsp would use some fixed text height value which i can set to what i need. (like before i use the .lsp i open it in notepad and change the value)

I tried to set use command 'textsize' prior running the list, but somewhy texts placed by the lisp always remained 2.5

 

Thanks :)

 

Numbering_TIT.lsp

Link to comment
Share on other sites

entmake txt use (cons 40 txt) 

cons 40 = textsize property

variable txt = (getvar dimtxt) x (getvar dimscale)

 

so, I guess replace every (cons 40 txt) to (cons 40 (getvar "textsize"))

it can be change to textsize variable you input

Edited by exceed
Link to comment
Share on other sites

Like this?

;;; 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 (getreal "\nText Height: "))
  (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.")

 

  • Thanks 1
Link to comment
Share on other sites

8 minutes ago, Isaac26a said:

Like this?

 

Thank you !!  exactly 

this way this .lsp is much more convenient to use than Express Tools's tcount command 

Link to comment
Share on other sites

3 minutes ago, Kurpulio said:

 

Thank you !!  exactly 

this way this .lsp is much more convenient to use than Express Tools's tcount command 

You're welcome 

Link to comment
Share on other sites

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...