Jump to content

Find the length of a text


mstb

Recommended Posts

hello every one

I want to find the length of a text I don't mean the number of characters, for example every text has a height and length I want that length

Thanks all

Link to comment
Share on other sites

  • Replies 32
  • Created
  • Last Reply

Top Posters In This Topic

  • mstb

    10

  • BIGAL

    6

  • dlanorh

    6

  • Roy_043

    4

1 hour ago, mstb said:

hello every one

I want to find the length of a text I don't mean the number of characters, for example every text has a height and length I want that length

Thanks all

 

Is the text already in the drawing or in a lisp

Link to comment
Share on other sites

yes It is in the drawing

I actually want to transfer the elevation codes that are in the drawing  so that the insertion point falls on the dot point

Of course, this way I have to use the right font, which is a problem (I mean, the font that gives a space to all the characters)

excuse me for may bad english

Edited by mstb
Link to comment
Share on other sites

22 minutes ago, mstb said:

........so that the insertion point falls on the dot point

 

It would be very handy if AutoCAD provided a dot justification. But the length of the text is not all that helpful, as elevation texts can have varying number of digits before the decimal point.

Link to comment
Share on other sites

31 minutes ago, eldon said:

 

It would be very handy if AutoCAD provided a dot justification. But the length of the text is not all that helpful, as elevation texts can have varying number of digits before the decimal point.

Exactly . First, I wanted to break the elevation code into three parts, one before and one last, almost self-contained and in the right position, but now I had three texts that I wanted to put together as if I were back in the first place.

(defun c:s ()
  (setq ss (ssget '((0 . "TEXT"))))
  (setq n (sslength ss))
  (setq li nil)
  (setq k -1)
  (repeat n
    (setq k (1+ k))
    (setq s (ssname ss k))
    (setq en (entget s))
    (setq ang (cdr (assoc 50 en)))
    (setq hi (cdr (assoc 40 en)))
    (setq la (cdr (assoc 8 en)))
    (setq po (cdr (assoc 11 en)))
    (setq txt (cdr (assoc 1 en)))
    (setq m (strlen txt))
    (setq d1 "")
    (setq d2 "")
    (setq i 0)
    (setq j 1)
    (repeat m
      (setq i (1+ i))
      (setq let (substr txt i 1))
      (if (/= let ".")
	(cond
	  ((= j 1) (setq d1 (strcat d1 let)))
	  ((= j 2) (setq d2 (strcat d2 let)))
	)
	(setq j (1+ j))
      )
      )
      (setq li (append li (list (list d1 d2))))
      )


    (entmake (list
	       (cons 0 "TEXT")
	       (cons 8 "la")
	       (cons 72 2)
	       (cons 73 0)
	       (cons 1 d1)
	       (cons 10 po)
	       (cons 11 po)
	       (cons 40 hi)
	       (cons 50 ang)
	     )
    )
      (entmake (list
	       (cons 0 "TEXT")
	       (cons 8 "la")
	       (cons 72 1)
	       (cons 73 0)
	       (cons 1 ".")
	       (cons 10 po)
	       (cons 11 po)
	       (cons 40 hi)
	       (cons 50 ang)
	     )
    )
    (entmake (list
	       (cons 0 "TEXT")
	       (cons 8 "la")
	       (cons 72 0)
	       (cons 73 0)
	       (cons 1 d2)
	       (cons 10 po)
	       (cons 11 po)
	       (cons 40 hi)
	       (cons 50 ang)
	     )
    )

  (princ)
)

It 's ok . But now I have three texts!

Edited by mstb
Link to comment
Share on other sites

43 minutes ago, mstb said:

yes It is in the drawing

I actually want to transfer the elevation codes that are in the drawing  so that the insertion point falls on the dot point

Of course, this way I have to use the right font, which is a problem (I mean, the font that gives a space to all the characters)

excuse me for may bad english

 

Look at Courier New or Monospac821BT

Link to comment
Share on other sites

4 minutes ago, dlanorh said:

 

Look at Courier New or Monospac821BT

yes. Thanks.But it would have been much better if I hadn't changed the font

Link to comment
Share on other sites

30 year old civil design software did this not Autocad it had an option the decimal point was on the point. If the insertion point is one of the 9 points available pretty easy to move text. Maybe C-C if you want the decimal point then yes a problem. Like Dlanorh look at a monospaced font. 

 

Post an image of what you want.

Link to comment
Share on other sites

2 hours ago, BIGAL said:

30 year old civil design software did this not Autocad it had an option the decimal point was on the point. If the insertion point is one of the 9 points available pretty easy to move text. Maybe C-C if you want the decimal point then yes a problem. Like Dlanorh look at a monospaced font. 

 

Post an image of what you want.

Thank you very much

Link to comment
Share on other sites

Where is wrong؟!!!

(command "STYLE" "new" "italic" "" "" "" "" "" "")  It's ok

(command "STYLE" "new" "Monospac821 BT" "" "" "" "" "" "") But This one ?!!!!

Link to comment
Share on other sites

Try this

 

(entmake
'( (0 . "STYLE")
(100 . "AcDbSymbolTableRecord")
(100 . "AcDbTextStyleTableRecord")
(2 . "Mono")
(70 . 0)
(40 . 0.0)
(41 . 1.0)
(50 . 0.0)
(71 . 0)
(3 . "Monospac821 BT.TTF")
(4 . "")
)
)

 

Link to comment
Share on other sites

3 hours ago, mstb said:

Where is wrong؟!!!

(command "STYLE" "new" "italic" "" "" "" "" "" "")  It's ok

(command "STYLE" "new" "Monospac821 BT" "" "" "" "" "" "") But This one ?!!!!

 

If you are going to use MonoSpac821 BT, I already have a lisp that returns the approximate middle of the dot (decimal point). It's scales OK, but was primally written to work with drawings in metres (text sizes less than 1.0)

Link to comment
Share on other sites

1 hour ago, BIGAL said:

Try this

 


(entmake
'( (0 . "STYLE")
(100 . "AcDbSymbolTableRecord")
(100 . "AcDbTextStyleTableRecord")
(2 . "Mono")
(70 . 0)
(40 . 0.0)
(41 . 1.0)
(50 . 0.0)
(71 . 0)
(3 . "Monospac821 BT.TTF")
(4 . "")
)
)

 

Thank you very much

Link to comment
Share on other sites

2 minutes ago, dlanorh said:

 

If you are going to use MonoSpac821 BT, I already have a lisp that returns the approximate middle of the dot (decimal point). It's scales OK, but was primally written to work with drawings in metres (text sizes less than 1.0)

Thank you very much

Link to comment
Share on other sites

1 hour ago, BIGAL said:

Try this

 


(entmake
'( (0 . "STYLE")
(100 . "AcDbSymbolTableRecord")
(100 . "AcDbTextStyleTableRecord")
(2 . "Mono")
(70 . 0)
(40 . 0.0)
(41 . 1.0)
(50 . 0.0)
(71 . 0)
(3 . "Monospac821 BT.TTF")
(4 . "")
)
)

 

 

Stop stealing my Mono textstyle. :danger::lol:

Link to comment
Share on other sites

There is no need to create temporary text objects, nor guess the width using the number of characters and a factor, just use the textbox AutoLISP function.

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