Jump to content

Evaluating an expression within a command string in a palette


Tyke

Recommended Posts

Does anyone know how to evaluate an expression in a command string for a palette.

 

I have saved a value in the system variable USERR5 and when I click on a button in a palette to insert some text I want to set the text height to the value in USERR5 multiplied by a standard value, for example 2 * 1.8.

 

I've tried wrapping the expression with brackets and quotation marks, but I still get an error message that says a numerical value is required to set the text height.

 

Somewhere I've seen how to do it but can unfortunately I can't find it anymore.

Link to comment
Share on other sites

Just a suggestion (* 2 (getvar "userr5")) change to (* 2.0 (getvar "userr5")) sometimes a 2* will return an integer answer v's 2.0 returns a real answer. Just a frustrating thing about programing in lisp.

 

May have an effect if you want 3.5 high text not 4.

Link to comment
Share on other sites

Just a suggestion (* 2 (getvar "userr5")) change to (* 2.0 (getvar "userr5")) sometimes a 2* will return an integer answer v's 2.0 returns a real answer.

 

Point taken BigAl, thanks.

 

Just to round things off:

 

I have a palette on which I have various buttons where I can select which scale to use, ie. 1:500, 1:250, 1:100 etc. The command string for such a button is:

^C^Cltscale;0,5;regen;userr5;0.5;modemacro;"Scale 1:500;

It sets the LTSCALE, writes the value 0.5 to the system variable USERR5 and displayes the scale I have selected next to the coordinate display bottom left.

 

I then have another button where I insert som text which must be a certain size and style. The command string for such a button is:

^C^Ctextsize;$M=(* 4.0 $(getvar,userr5));_dtext;_style;12_Flrstk;\;270;

This sets the text height using a standard size multiplied by the value saved in USERR5 by the scale button above, issues the DTEXT command, selects the style and in this case sets the angle of the text (if you want to set the text angle by user input replace the 270 with a \ ).

 

I'm going to insert blocks from buttons and scale them in a similar fashion.

 

An advantage with this method is that you can set the size of text and blocks differently within one drawing. Using annotation is not always wanted and we have some funny clients :wink:.

 

Comments and improvements are welcome.

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