Jump to content

Recommended Posts

Posted

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

  • Replies 32
  • Created
  • Last Reply

Top Posters In This Topic

  • mstb

    10

  • BIGAL

    6

  • dlanorh

    6

  • Roy_043

    4

Posted

Not exact depends on font (/ (* (strlen str)  ht) 1.4) ? It varies for say IIIIIII and WWWWWWW

Posted
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

Posted (edited)

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

Posted (edited)
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
Posted
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

Posted
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

Posted
8 minutes ago, eldon said:

Perhaps this thread might provide food for thought

Thank you very much

Posted

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.

Posted
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

Posted

Where is wrong؟!!!

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

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

Posted

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

 

Posted
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)

Posted
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

Posted
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

Posted
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:

Posted

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.

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