PGia Posted yesterday at 06:51 AM Posted yesterday at 06:51 AM (edited) Hi again. There's something I can't seem to find a clear answer to. Maybe someone here can give me that answer. I'm experimenting with the use of dynamic variables, created in real-time. However, there's something that often makes me doubt whether it's advisable to use them. And that's where my question lies: If my code creates thousands of variables to avoid having to store data in a structure (lists or arrays)... when at the end of the code I cancel each of those variables with (set 'v nil), do the names of those variables really disappear from AutoCAD's symbol table, or only their content? I know about the atoms-family function and that it returns the value of a symbol if it exists. But the AI says that a negative response from atoms-family is not a guarantee that the symbol no longer exists in AutoCAD's internal symbol table. Thanks in advance. Edited yesterday at 07:13 AM by PGia Quote
Lee Mac Posted yesterday at 08:33 AM Posted yesterday at 08:33 AM (edited) A couple of points to make: The need to create thousands of variables on-the-fly typically points to poor program design; in almost every case, a list is more suitable. Setting all such variables to nil at the end of the program does clear them from the document namespace, but consider that you are essentially creating & clearing global variables that are not local to the scope of your program, and as such, the variable names could potentially clash with identically named variables in the document namespace - this is generally considered bad practice. Edited yesterday at 08:34 AM by Lee Mac 3 1 Quote
PGia Posted 10 hours ago Author Posted 10 hours ago Thanks for your answer, @Lee Mac. I've tried creating a list with the coordinates of almost 20,000 objects and managing it on the fly with assoc and subst. However, the processing speed is quite slow. For this reason, it occurred to me to try dynamic variables. You're probably right. But in your answer, you seem to concede a small possibility that using them might actually be worthwhile. What do you mean by that? Quote
Recommended Posts
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.