numbering lisp (need text height modifier)

numbering lisp (need text height modifier)

armansesar
Enthusiast Enthusiast
3,135 Views
10 Replies
Message 1 of 11

numbering lisp (need text height modifier)

armansesar
Enthusiast
Enthusiast

I found this useful numbering list that generates numbers as single line text in sequence, however, i have not been able to find a useful modification to this to allow for text height adjustment and my personal attempts have failed. I also noticed there is no text height size in the lisp, so most likely defaults to whatever was last on your autocad.

 

please let me know if you can add to this  (file attached).

0 Likes
Accepted solutions (2)
3,136 Views
10 Replies
Replies (10)
Message 2 of 11

CodeDing
Advisor
Advisor

This variable 'txt' determines your text height:

  (if (= 0 (getvar "dimscale"))(setq ds 1.0)(setq ds (getvar "dimscale")))
  (setq th (getvar "dimtxt"))
  (setq txt (* th ds))

 

Best,

~DD

Message 3 of 11

Kent1Cooper
Consultant
Consultant

The code lines that @CodeDing quoted set the text height based on the setting for that in Dimensions.  It is used in the

(cons 40 txt)

lines in the Text-making parts.

You can build in a fixed number for 'txt' instead of that calculation, or even skip the variable altogether and just have the Text-making spell it out directly:

(cons 40 YourDesiredHeight)

 

or you can have the routine ask you for a height [is that what you mean by "to allow for text height adjustment"?], or you could base it on other possibilities.

 

[By the way, it's preferable to attach a file rather than put nearly 800 (!) lines of code into the Message body that people need to scroll through for so long.]

Kent Cooper, AIA
Message 4 of 11

armansesar
Enthusiast
Enthusiast

thanks, will do that next time. I am trying to undetstand what line needs to change. I have changed my default Textsize by running the textsize command and its still defaulting to a random size, so yes, ideally i would like it to prompt for the text size, or actually refer to the textsize command for the included text size.

 

thank you.

0 Likes
Message 5 of 11

Kent1Cooper
Consultant
Consultant
Accepted solution

It's not random, but based on the Dimension text size setting.  For what you describe, I would try replacing those three lines in Message 2 with just this:

(setq txt (getdist "\nText height: "))

BUT you need to do that in all the multiple locations in the posted code where that same situation occurs.

 

It could be made fancier, such as to remember your choice and offer it as a default on subsequent use, or to let you get it from a selected existing Text object, but first see whether that simple change works.

Kent Cooper, AIA
Message 6 of 11

armansesar
Enthusiast
Enthusiast
Accepted solution

I really appreciate it, this worked great, I saw a few more intricate lisp routines but this simple Lsp works great for me.

 

Thanks again.

 

I am attaching the final LSP for anyone that might be interested.

 

 

 

0 Likes
Message 7 of 11

armansesar
Enthusiast
Enthusiast

just out of curiosity, is there a quick addition to make it remember your size input? 

0 Likes
Message 8 of 11

Kent1Cooper
Consultant
Consultant

@armansesar wrote:

just out of curiosity, is there a quick addition to make it remember your size input? 


Not all that quick, but not difficult.  It would involve removing 'txt' from the localized variables list in all those commands, and using a global variable, preferably with a little more command-specific name than just 'txt' so that it will not be overwritten by the same variable name from something else.  First question:  Would you use the same Text height in all the commands that needed that adjustment?  If so, an umbrella function could be written, that could be called from within each of them, rather than spelling it all out that many times.

Kent Cooper, AIA
Message 9 of 11

armansesar
Enthusiast
Enthusiast

Thanks, seems a bit complicated, Im actually learning C++ and hoping that will help with my understanding of the LISP slightly better, but I'm simply using this to number parcels on a plot. I'm not sure what you mean by "same height in all commands". Where are the global variables defined? do you mean adding a dwg property variable? that way you can have the Lisp reference what is in the DWG props? I guess what I want is to set for example a 1" height, place a sequence of numbers, then when I reapply the numbering command, have the command prompt for text height, but remember the 1" input as default, then If for example upon being asked for the text height you input 2", then from that point, the command remembers that as the new set default (still prompting for text height every time). If however its easier to do a global variable somewhere, it would have to be unique and applied to this command only. Eg. not changing the street names, or any other text on the drawing.

 

Thank you.

0 Likes
Message 10 of 11

Sea-Haven
Mentor
Mentor

"remember the 1" input as default" easy use Ldata. It lives in a dwg and you can get, put or redefine.

 

 

(vlax-ldata-put "AlanH" "Lastnumber" 23)

(vlax-ldata-get "AlanH" "Lastnumber")

 

 

As you add numbers keep doing the put so number is updated, can have multiple keys in one ldata.

(vlax-ldata-get "AlanH" "scale")

(vlax-ldata-get "AlanH" "Layoutname")
0 Likes
Message 11 of 11

bibitzky
Community Visitor
Community Visitor

THIS WORK WELL  EXCEPT WHEN I COMMAND THE AAZZ,,IT SAYS ERROE AFTER INPUTING THE TEXT HIEGHT,,PLEASE HELP

0 Likes