Jump to content

Text Calculator-LeeMac text size


wilda

Recommended Posts

Hello everyone 

The TextCalcV1-0.lsp program inserts the calculation result in the drawing in the form of the MText object with the current font size (variables-textsize) and style ((variables-textstyle). This causes the inserted Mtext often to be significantly different font size of the objects selected for the calculation and is either much too large or too small.
Can someone change something in the program so that the result is inserted with a font size taken from the object
indicated for calculations?
The calculation objects can be Single-line Text, Multi-line Text, and Dimension, Multileader or Attribute.
http://www.lee-mac.com/textcalculator.html

Link to comment
Share on other sites

It is common to set your variables for text size, dimension style, etc before adding notes to your drawing. Why not do that before running Lee's program?

 

It looks like this lisp sets current variables based on selection. There are probably other options.

https://www.theswamp.org/index.php?topic=3633.msg47074#msg47074

 

Edited by dan20047
Link to comment
Share on other sites

An example is attached.
I usually use two drawing settings in one file. Site plan 1 autocad unit = 1 meter and sections 1 unit = 1 cm. In addition, I often make drawings 1j = 0.5 cm, I also get drawings from other people where the settings are still different.
The point is not to change the font size manually depending on the selected objects for calculations, but the program itself changed the font size by taking its size from the selected object for calculations.

TextCalc.gif

Link to comment
Share on other sites

Like a lot of his programming it is all integrated with different sub functions, extracting what you need and reworking the code would need a fair bit of effort I think, 

Link to comment
Share on other sites

Yup, in the example it looks like he adds mtext result using vla-addmtext which I don't think can have a height variable added - uses whatever system variables are set - set text size before you run the command

Link to comment
Share on other sites

It's not about manually setting something before or after the command is executed. I thought that maybe there is a possibility that after indicating the first text object, the program could read the font size from its properties and change the textsize variable to this size before inserting the result. Then the inserted text of the result would be the same size as the selected object for calculations.

Link to comment
Share on other sites

it is possible to do that with the code and a lot of changes, 

 

How much of this are you willing to do for yourself if you are guided along the way? (busy this week)

 

 

First step I'd do is to find a create text LISP using entmake or entmakex and replace the vla-addmtext portion with that, entmake gives you easier control over the text parameters such as font size, layers and so on - post what you find

Link to comment
Share on other sites

I'll be looking for a Lisp to create text;
I will see this lisp by CAB;
It's probably too late to learn programming, and besides, not everyone is capable of learning that;

Link to comment
Share on other sites

6 minutes ago, wilda said:

It's probably too late to learn programming, and besides, not everyone is capable of learning that;

 

I might argue about that, might not be a natural thing but I reckon most people can get by

Link to comment
Share on other sites

I looked at the SetCurrent.lsp and, by analogy, added two lines of code after (setq entity...) to textcalculator.lsp. Thanks to this, the program sets the current font size to the same as the font size of the selected object.

  (defun _Select ( msg / entity num dtext mtext )
    (while
      (progn (setvar 'ERRNO 0) 
			(setq entity (car (nentsel msg)))
			
			(setq entbl (entget entity))
			(setvar "TextSize" (cdr (assoc 40 entbl)))

I hope LeeMac will forgive me.

TextCalc2.gif

  • Like 2
Link to comment
Share on other sites

Congratulations, both on getting your solution but (I think) catching the programmer bug! I assume Lee would feel the same, as long as you maintain credit to him in the modified lisp. (And I would document your changes with comments for future reference.) I'm an oldish dog who remembers when Lee first started posting questions on theswamp.org and then became, IMHO, a lisp superstar.

Link to comment
Share on other sites

As solutions  I have add a value to multiple text, get difference of 2 text and put result in a 3rd text, similar for block attributes take att1*att2 put area in Att3. I am sure I have a few more. Stuff like pick 2 pts and take into account a scale factor on distance returned. Think long and cross sections.

 

A start

(setq ent (entsel "\nPick 1st text ")) ; pick a text no error check if wrong object picked
(setq txt (cdr (assoc 1 (entget (car ent))))) ; using dxf code get text
(setq txtnum1 (atof txt)) ; convert the string into a real

(setq txtnew (rtos  (- txtnum1 txtnum2) 2 3)) ; difference between the texts

(command "Text" your turn now

 

 

Edited by BIGAL
Link to comment
Share on other sites

Thanks BIGAL, but it's a long way from writing a simple example to programming, life is not enough for me to learn. Not everyone has such talent for programming as LeeMac or BIGAL or StevenP and several others. Besides, as such a basic concept I have it. Only thanks to this it was possible to use the lisp indicated by dan20047 (many thanks) to modify textcalculator.lsp.
Dan20047 - my clumsy attempt to modify this is not for wide publication. It's just for my needs.

LeeMac, if he thinks it's right, will correct it himself, and certainly much better.

Edited by wilda
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...