Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

System Variables in Fields

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
djohns2486
2313 Views, 9 Replies

System Variables in Fields

I am using a the USERI, USERR, and USERS system variables in Fields that are in Mtext throughout my drawings to be able to quickly updated text from machine to machine.

The problem I am running into is that the USERS system variables are not saved in the drawing.  

 

Is there a way to make a new system variable that could hold a string value in the drawing?  

 

I have read other posts that state that XDATA or XRECORD would be a better way to store data, but can it be called in a text field?

 

I am currently using DieselExpression in a Field to get the system variables: $(getvar, users5)

This works great for integers and reals, I just need the same functionality with a string.

 

9 REPLIES 9
Message 2 of 10
dbroad
in reply to: djohns2486

"Is there a way to make a new system variable that could hold a string value in the drawing?  "

 

No.  Users cannot create new system variables.

 

What information were you storing in user variables?  I may be able to suggest options if you give an application and context.

Architect, Registered NC, VA, SC, & GA.
Message 3 of 10
dgorsman
in reply to: dbroad

I believe that custom system variables can be created in dotNET for the past few releases.  It *might* be possible to manually create them through directly diddling with the registry.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 4 of 10
djohns2486
in reply to: dbroad

I am making electrical schematics and the device name prefix and wire number prefix change based on the equipment numbers.

I have the same schematic that is used in multiple areas/equipment and would like to make the changes once and have it update the entire drawing. 

 

Since my original post I found a work around that appears to work.

I added custom properties to the Drawing Properties and then use Fields in the wire numbers and device names throughout my drawing that reference those properties.

The only downfall is I cannot do any functions on the Custom Drawing Properties variables like I was able to do with Diesel, for example $(-,$(getvar,useri1),1).

This is my first attempt at programming anything in Acad so if there is a better way to do this I would love to hear it.

 

Thanks!

Message 5 of 10
scot-65
in reply to: djohns2486

Determine what type of data will be stored:

 

a) Is it global, meaning will be applied to all workstations?

b) Is it local, meaning applies to all drawings opened at your work station?

c) Is it drawing specific?

d) Is it session only?

 

Possible Answers:

 

a) Read from and Write to an external file located on the server.

b) Create a registry entry VL-REGISTRY-READ or explore GETCFG if registry permission issues.

c) Explore VLAX-LDATA-GET - store information as a LIST.

d) Setq USER_XXX where XXX is the program name, and do not declare in the defun section of the code (it's a gremlin). Make a LIST as needed.

 

Now, have the ability to read from these areas (except item d) and set the USERS#'s when the drawing is first opened - look into ACADDOC.lsp.

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 6 of 10
dbroad
in reply to: djohns2486

Thanks.  That is why I asked the question.  Let's assume that you have several fragments of information that you want to distribute throughout the drawing.  Hopefully you want to control not just the value but also the symbol name that holds the value.  I suggest you explore the following before getting complicated with xdata and ldata and such.  Use the dwgprops command.  On the custom tab, add your symbol/value pairs  (Module = 04300, SubModule = C).  Then when creating the fields, just reference the document branch and those symbol/value pairs will be accessible.

Architect, Registered NC, VA, SC, & GA.
Message 7 of 10
dbroad
in reply to: dgorsman

Thanks for the correction.  As far as that being a practical solution though, I am not convinced, especially for the ordinary user.

Architect, Registered NC, VA, SC, & GA.
Message 8 of 10
djohns2486
in reply to: scot-65

Thanks scot-65 for these additional options!

I will play around with them and see what works best.

Message 9 of 10
djohns2486
in reply to: dbroad

Thanks everyone for all the recommendations!

The DWGPROPS solution works well and is easy to use.

Message 10 of 10
scot-65
in reply to: djohns2486

I had forgotten about drawing props. Personally I do not like them. It's more of a publicly

accessible area that can easily be tampered with outside a program that depends on the values.

 

When you said "machine to machine", I understood that differently than what you were asking.

 

Combining methods I showed earlier is another plan of attack:

Suppose archived drawings used an old part number that has since been replaced with new ones.

Like this does happen all the time, huh?

Store the latest and greatest on the server and at the appropriate time check if values are stored

in the drawing file itself (first time run). If it is not, then load the server values, otherwise load what

was stored. I have learned that files might get reused, and the values were never updated. When

this type of situation warrants a reset, I actually store the file name (or a substring of the file name)

as part of the program. Now if the file name does not match, delete the data in file and load the

data from the server.

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost