.NET

Reply
Distinguished Contributor
bart_van_tuyl
Posts: 164
Registered: ‎07-01-2008
Message 1 of 6 (186 Views)
Accepted Solution

vb.net set lisp variable

186 Views, 5 Replies
07-24-2014 11:22 AM
Hi,

I have a lot of questions qua vb.net and acad, but its all very new too me (an appologie if im anoying). Ive been toyong around with how to set variables and when its system variables its nice and easy. However I would like to know how I can set (or even create) a lisp variable from with in vb.net? Also yes I did consider setting the system variable USERs1 but only found out how to set the system variables for integers, wich is identified as USERi1 through to USERi5. When i tryed it out for string input (as its text i want to store in the variable, the result came up as a blank?

After running the code

 

dim myint as integer= textbox1.text
application.setsystemvariable("Useri1", myint)

 

did you go to the command line for "USERS1" right after with the same drawing? There is no reason the above code does not work.

 

You may be aware that if there are multiple drawings are open, Application.SetSystemVariable() sets system variables of current drawing (MdiActiveDocument). Also, different from other USER variables (USERRx and USERIx), USERSx do not save their value inside the drawing. That is, if the drawing is closed and opened again, the USERSx value set in previous AutoCAD session will be gone.

Distinguished Mentor
BlackBox_
Posts: 771
Registered: ‎02-25-2013
Message 2 of 6 (173 Views)

Re: vb.net set lisp variable

07-24-2014 03:22 PM in reply to: bart_van_tuyl

For .NET interacting with LISP variables, give this a read: http://www.theswamp.org/index.php?topic=35714.0

 

You might also consider the USERR* and USERS* system variables.

 

Cheers



"Potential has a shelf life." - Margaret Atwood


Autodesk Exchange Apps ~ Autoloader ~ AutoCAD Security

Distinguished Contributor
bart_van_tuyl
Posts: 164
Registered: ‎07-01-2008
Message 3 of 6 (155 Views)

Re: vb.net set lisp variable

07-25-2014 05:47 AM in reply to: bart_van_tuyl
Userr* means USER REAL, and Users* means USER STRING, since i want to pass a string value i have chosen to use USERS*. The example I found was for integers (or said USERI*). The sample code was as follows

[code]

dim myint as integer= textbox1.text
application.setsystemvariable("Useri1", myint)

[code]

respectivaly if i modify the code as follows it should work for string variables but no value is set?

[code]

dim mystr as string = textbox1.text
application.setsystemvariable("users1", mystr)

[code]

but this fails toset anything, if i call the variable up via the sutocad command prompt it says users1("") ???
*Expert Elite*
norman.yuan
Posts: 994
Registered: ‎04-27-2009
Message 4 of 6 (146 Views)

Re: vb.net set lisp variable

07-25-2014 07:04 AM in reply to: bart_van_tuyl

After running the code

 

dim myint as integer= textbox1.text
application.setsystemvariable("Useri1", myint)

 

did you go to the command line for "USERS1" right after with the same drawing? There is no reason the above code does not work.

 

You may be aware that if there are multiple drawings are open, Application.SetSystemVariable() sets system variables of current drawing (MdiActiveDocument). Also, different from other USER variables (USERRx and USERIx), USERSx do not save their value inside the drawing. That is, if the drawing is closed and opened again, the USERSx value set in previous AutoCAD session will be gone.

Distinguished Contributor
bart_van_tuyl
Posts: 164
Registered: ‎07-01-2008
Message 5 of 6 (142 Views)

Re: vb.net set lisp variable

07-25-2014 08:34 AM in reply to: bart_van_tuyl
The integers version works, the string version fails o tried to use a numeric value afterwoulds with the string version but that failed also??
*Expert Elite*
dgorsman
Posts: 5,359
Registered: ‎10-12-2006
Message 6 of 6 (106 Views)

Re: vb.net set lisp variable

07-28-2014 09:39 AM in reply to: bart_van_tuyl

Rather than trying to set a variable, create a method as a LISP function that returns a value.  That way it can be called the same way as a LISP function, even if its just (setq tval (MyNETFunction)).

 

Don't rely too much on the USER* variables - other functions may be using them and writing/rewriting values can have unexpected results.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
Adopt. Adapt. Overcome. Or be overcome.
A good question will be halfway to a good answer.


Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.