OK, your code is simple enough: just set it and get it immediately.
I modified the code I posted previously, as following:
Imports Autodesk.AutoCAD.Runtime
Imports ADApp = Autodesk.AutoCAD.ApplicationServices.Application
Public Class WDSGClass
_
Public Sub Asdkcmd1()
' Set USERS1
ADApp.SetSystemVariable("USERS1", "A1234567890A")
' Get USER1
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage
_
("Here is USERS1: " & ADApp.GetSystemVariable("USERS1"))
End Sub
End Class
It worked, of course, on both of my Acad2006 and Acad2007, to be precise,
Acad2006/7 MAP 3D.
So, I really do not know what problem is with your Acad. Does your other
code run OK? You may have bad luck of gettiing a "weird copy" of Acad, that
is all I can say, if nothing can solve it.
wrote in message news:5626215@discussion.autodesk.com...
Thanks for the suggestions guys. Yes Tony, I know that the USERS/R/I
variables are document session specific and that they are not saved with the
drawing. The problem is in the same session (in fact while debugging).
I am using AutoCAD Mechanical 2007 SP1 and have created a form with a
button, two text boxes and a cancel button.
Code follows:
Imports Autodesk.AutoCAD.Runtime
Imports ADApp = Autodesk.AutoCAD.ApplicationServices.Application
Public Class frmMain
Private Sub btnUsers1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUsers1.Click
Dim txtU1 As String = txtUsers1.Text
ADApp.SetSystemVariable("USERS1", txtU1)
Dim txtU1a As String = ADApp.GetSystemVariable("USERS1")
txtGetUsers1.Text = txtU1a
End Sub
End Class
I used the txtU1 and txtU1as variables to simply see what was happening
during debug. I still get nothing returned in the USERS1 variable.