TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: velasquez on August 12, 2014, 05:40:54 PM

Title: Length of a string
Post by: velasquez on August 12, 2014, 05:40:54 PM
I need to convert the length of a string (strlen "nononododod") for drawing units.
I know that the source will always .shx
I also know the height of the font.

The best way would be to compare a pattern?
Does anyone know a faster way?

Thanks
Title: Re: Length of a string
Post by: Keith™ on August 12, 2014, 06:11:36 PM
Try something like this:

Code: [Select]
(car (cadr (textbox (entget (car (entsel))))))
Title: Re: Length of a string
Post by: Lee Mac on August 12, 2014, 06:22:11 PM
Or something along the lines of:

Code - Auto/Visual Lisp: [Select]
  1. (   (lambda ( box ) (- (caadr box) (caar box)))
  2.     (textbox
  3.         (list
  4.             (cons 01 str)
  5.             (cons 40 hgt)
  6.             (cons 07 sty)
  7.         )
  8.     )
  9. )
Title: Re: Length of a string
Post by: velasquez on August 12, 2014, 06:33:05 PM
Excuse the language confuses me.
I still have the text in the drawing.
Title: Re: Length of a string
Post by: danallen on August 12, 2014, 06:49:36 PM
do you mean height instead of length? please show a picture
Title: Re: Length of a string
Post by: velasquez on August 12, 2014, 07:12:11 PM
I have a list of strings.
I need to draw a box to write strings inside.
Code: [Select]
(("Válvula de gaveta c/ flanges e cunha de borracha corpo longo c/ volante Euro 21") ("Válvula de gaveta c/ flanges Euro 21"))

I know the height of the font and the type -> can be "romans.shx" or "simplex.shx" or any other font .shx
Title: Re: Length of a string
Post by: dgorsman on August 13, 2014, 11:38:48 AM
Since there isn't a logical difference between adding text into a box that has been calculated to fit the text, and drawing the calculated box around the text, I'd suggest the latter.

If the box is somehow fixed in size, then you've got different problem.
Title: Re: Length of a string
Post by: ronjonp on August 13, 2014, 11:51:28 AM
Why not just use a table?
Title: Re: Length of a string
Post by: velasquez on August 13, 2014, 02:58:29 PM
Why not just use a table?

Hi ronjonp
Your idea is very good but I have no experience drawing tables.
I have the standard design for the table.
The user chose the font height and font .shx
Example -> font height = 5
                   font type    = romans.shx

My idea was to design a table using any other command with the information I have.

I appreciate any help.
Title: Re: Length of a string
Post by: ronjonp on August 13, 2014, 03:20:15 PM
Look into the TABLESTYLE command. Alternatively if you're going to draw the table use the code Lee supplied to get the width of the string.
Title: Re: Length of a string
Post by: velasquez on August 13, 2014, 03:33:26 PM
Look into the TABLESTYLE command. Alternatively if you're going to draw the table use the code Lee supplied to get the width of the string.
Thank you ron.
Title: Re: Length of a string
Post by: velasquez on August 13, 2014, 04:26:37 PM
Or something along the lines of:

Code - Auto/Visual Lisp: [Select]
  1. (   (lambda ( box ) (- (caadr box) (caar box)))
  2.     (textbox
  3.         (list
  4.             (cons 01 str)
  5.             (cons 40 hgt)
  6.             (cons 07 sty)
  7.         )
  8.     )
  9. )

Hi Lee,
Your tip helped me a lot again,.
thanks.


Title: Re: Length of a string
Post by: Lee Mac on August 14, 2014, 01:53:35 PM
Or something along the lines of:

Code - Auto/Visual Lisp: [Select]
  1. (   (lambda ( box ) (- (caadr box) (caar box)))
  2.     (textbox
  3.         (list
  4.             (cons 01 str)
  5.             (cons 40 hgt)
  6.             (cons 07 sty)
  7.         )
  8.     )
  9. )

Hi Lee,
Your tip helped me a lot again,.
thanks.

You're welcome  :-)

Regarding the table - my LM:addtable function from my Polyline Information (http://bit.ly/1gsEKKL) program may help you.

Lee
Title: Re: Length of a string
Post by: velasquez on August 14, 2014, 05:25:58 PM
Or something along the lines of:

Code - Auto/Visual Lisp: [Select]
  1. (   (lambda ( box ) (- (caadr box) (caar box)))
  2.     (textbox
  3.         (list
  4.             (cons 01 str)
  5.             (cons 40 hgt)
  6.             (cons 07 sty)
  7.         )
  8.     )
  9. )

Hi Lee,
Your tip helped me a lot again,.
thanks.

You're welcome  :-)

Regarding the table - my LM:addtable function from my Polyline Information (http://bit.ly/1gsEKKL) program may help you.

Lee

Its function will help me a lot
Against the table you can create an image attached equal to, or similar?
Title: Re: Length of a string
Post by: dgorsman on August 14, 2014, 05:44:30 PM
If those "fixed size" and "variable size" refer to column width, you have a logical problem: the header over the last "variable" column is indicated as "fixed", so with all the other child columns also "fixed" the last column cannot be variable.
Title: Re: Length of a string
Post by: velasquez on August 14, 2014, 06:36:13 PM
If those "fixed size" and "variable size" refer to column width, you have a logical problem: the header over the last "variable" column is indicated as "fixed", so with all the other child columns also "fixed" the last column cannot be variable.

Hi I understood what you said.
Please you have a basic example of a table that looks like this to show me?
Thanks
Title: Re: Length of a string
Post by: velasquez on August 16, 2014, 04:10:58 PM
Or something along the lines of:

Code - Auto/Visual Lisp: [Select]
  1. (   (lambda ( box ) (- (caadr box) (caar box)))
  2.     (textbox
  3.         (list
  4.             (cons 01 str)
  5.             (cons 40 hgt)
  6.             (cons 07 sty)
  7.         )
  8.     )
  9. )

Hi Lee,
Your tip helped me a lot again,.
thanks.

You're welcome  :-)

Regarding the table - my LM:addtable function from my Polyline Information (http://bit.ly/1gsEKKL) program may help you.

Lee

Hi Lee

Your Information Polyline function does a great job.
I'm trying to include a second title line.
Equal to "ttl - [str] [Optional] Table title"
But I can not make it work.
Can you help me with this also.
Title: Re: Length of a string
Post by: velasquez on August 16, 2014, 07:19:42 PM
Hi Lee
I'm working with a function LM: AddTable:
I could create a second line of title then worked around.
After (vla-AddTable ...
I know the code below to put all the columns of the second lnha on a single line.
This path is correct?

Code: [Select]
  (vla-setsubselection obj 1 0 1 7)
  (vla-getsubselection obj '1 '0 '1 '7)
  (vla-mergecells obj 1 1 0 7)
  (vla-clearsubselection obj)

;;;ESCREVE O SUBTITULO
  (vla-settext obj 1 0 "SECOND TITLE")

Thanks
Title: Re: Length of a string
Post by: Lee Mac on August 17, 2014, 07:37:43 AM
There is no need for the get/set/clearsubselection methods - only the mergecells method is required.
Title: Re: Length of a string
Post by: velasquez on August 18, 2014, 06:32:31 AM
There is no need for the get/set/clearsubselection methods - only the mergecells method is required.

Thank you Lee
It worked.

Not something like Row Style exist?
Title: Re: Length of a string
Post by: Lee Mac on August 18, 2014, 06:49:24 PM
There is no need for the get/set/clearsubselection methods - only the mergecells method is required.

Thank you Lee
It worked.

Not something like Row Style exist?

I don't think so, no  :-(
Title: Re: Length of a string
Post by: velasquez on August 18, 2014, 09:12:00 PM
There is no need for the get/set/clearsubselection methods - only the mergecells method is required.

Thank you Lee
It worked.

Not something like Row Style exist?

I don't think so, no  :-(

OK Lee,
Thanks