Jump to content

String with Getenv


mwade93

Recommended Posts

I have been playing around with these variables, I have not been able to figure out a way to make a string with getenv embedded in the string. For example Rev(X)-Date. Is there a way to prompt the user for just the number (X) with setenv/getenv?

Link to comment
Share on other sites

  • Replies 27
  • Created
  • Last Reply

Top Posters In This Topic

  • mwade93

    9

  • Tuns

    8

  • steven-g

    6

  • Tyke

    5

Top Posters In This Topic

I actually answered my own question.

 

It just looks like this:

^C^C^C-la;t;rev$M=$(getenv,users1);;

 

I just have to set users1 before I issue this button.

Link to comment
Share on other sites

I used setenv then entered users1 and prompted the user for the answer:

 

^C^C^Csetenv;users1;\

 

I know there is a users2 variable but I can't seem to get it to work.

Link to comment
Share on other sites

I always use 3 just to make sure. That is a habit I picked up from my instructor I had in the customizing class.

 

How do you normally do your diesel macros then if you don't store anything?

Link to comment
Share on other sites

I always use 3 just to make sure. That is a habit I picked up from my instructor I had in the customizing class.

 

How do you normally do your diesel macros then if you don't store anything?

I use the magic of variables already present in the drawing. For the most part I don't really need to store variables for my job.

Link to comment
Share on other sites

Does this work for you, all in one,

 
^C^C^Csetenv;users1;\-la;t;rev$M=$(getenv,users1);;

 

That would work except I have 3 other items related to the desired level so I don't want to prompt each and every time. I prompt once then the other buttons do not prompt.

 

I use the magic of variables already present in the drawing. For the most part I don't really need to store variables for my job.

 

The variables never work when I try to use the default system ones.

Link to comment
Share on other sites

That would work except I have 3 other items related to the desired level so I don't want to prompt each and every time. I prompt once then the other buttons do not prompt.

 

 

 

The variables never work when I try to use the default system ones.

Could you explain a bit more, it sounds interesting.
Link to comment
Share on other sites

Tuns

Here is the toolbar. The first button sets the level by prompting the user. Next draws a rev cloud on the revX layer. Next one inserts delta with correct number. Last one changes the date on the title block.

 

[ATTACH=CONFIG]43852[/ATTACH]

 

Steven-g

Well, for example, if I try to insert the variable dimscale into a macro, it always gives me 1. Basically, it always give me the default system variable as if the value for each variable has never been changed.

Link to comment
Share on other sites

I know there is a users2 variable but I can't seem to get it to work.

 

The reason you are having trouble with the USERS2 variable is because there are no USERSn variables in LT, just in full AutoCAD. The S stands for a string value. There are USERRn where the R stands for a real value and USERIn where the I stands for an integer value.

 

Here is an extract from the LT User Guide > Command Reference > System Variables:

 

 

  • UOSNAP
    Determines whether object snapping is active for geometry in DWF, DWFx, PDF, and DGN underlays that are attached to the drawing.
     
  • UPDATETHUMBNAIL
    Controls updating of the thumbnail previews for views and layouts.
     
  • USERI1-5
    Provides storage and retrieval of integer values.
     
  • USERNAME
    Specifies the user name.
     
  • USERR1-5
    Provides storage and retrieval of real numbers.

And the link to the page: http://exchange.autodesk.com/autocadlt/enu/online-help/browse#WS73099cc142f48755-1c09418211f25b18dc4-4daa.htm

 

 

I have read that you can use the variable "strPrefix", but I have no other knowledge on that and I can find no reference to it in the documentation.

Link to comment
Share on other sites

Hey don't get me wrong you can use them, but it's 'getvar' and 'setvar' that you want. And not 'getenv' and 'setenv' which is a different animal, that's why setenv users1 worked, basically the differenece is that getenv reads variables stored in the windows registery and can have just about any name you choose, and it is available to every drawing, anytime you want until you change that value with setenv, whereas getvar is what you use, to find the variables within the current drawing, and those values are reset for a new drawing to the default values.

PS it is the use of getenv/setenv that lets you use strings in variables in LT, but a word of caution setenv will create variables in the registry and they stay there for ever so try and use them sparingly or use the same name each time unless it is something that has a special purpose.

Link to comment
Share on other sites

It's not so much a question of mistakes, just something to be aware of, a lot of people don't consider that setenv creates something permanent, so if you are happily using setenv in a macro and the name uses todays date you could end up very quickly with hundreds if not thousands of system variables wasting resources, If the intention is to count how many drawings you have created in a project then fine, but if it's just for a temporary store then get into the habit of using something like temp1, temp2 and stick to that.

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