.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Setting AutoCAD Variables

8 REPLIES 8
Reply
Message 1 of 9
BrentBurgess1980
1195 Views, 8 Replies

Setting AutoCAD Variables

I have just started using the .NET API and have managed to successfully create a tool palette. What I am trying to do is select an item from a combo box in the tool palette and set a variable based on the item selected.

I have attached a copy of what I have so far, but have not been able to find anything on Setvariable. Any help is greatly appreciated.

TIA

Brent
8 REPLIES 8
Message 2 of 9
Anonymous
in reply to: BrentBurgess1980



size=2>Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable(string,
object)


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<BrentBurgess1980> сообщил/сообщила в новостях следующее:
href="news:6042296@discussion.autodesk.com">news:6042296@discussion.autodesk.com
...
I
have just started using the .NET API and have managed to successfully create a
tool palette. What I am trying to do is select an item from a combo box in the
tool palette and set a variable based on the item selected. I have attached a
copy of what I have so far, but have not been able to find anything on
Setvariable. Any help is greatly appreciated. TIA Brent
Message 3 of 9
ash.
in reply to: BrentBurgess1980

Here's a very simplified example.

  • To set a system variable:

    Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("OSMODE")

  • To get a system variable:

    Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("OSMODE", 0)
Message 4 of 9

Obviously you should note that in the previous post he crossed them up. has Set under get and vice-versa.

The Additional information not included in the other posts is that most of the variables that are saved in the drawing file are accessible by the Database object. use the object browser to see what's in there, and not, but for example "CECOLOR" for the current entity color is accessible by Database.cecolor....all of the dimensioning variables are under Database... many others too.
Dave O.                                                                  Sig-Logos32.png
Message 5 of 9

Thanks for the information. I am having trouble setting the users variables. All other ones are fine and I can set them.
This is a snippet from my code.
'------
Dim oValue As Object = LblFolder.Text
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("USERS5", oValue)
'------
I can get the "users" variables using the ....GetSystemVariable("USERS5")

Any idea that I could be doing wrong? Also where can I find more information of the Database object? I am finding the search function in the new setup hard to use.

Thanks
Brent
Message 6 of 9

I'm not completely clear what the sequence of events is, but just so you know, the USERS variables are not saved from one drawing session to the next, so if you are setting something in there, hoping to read it out later, it will only be there until the drawing is closed.

What exactly is the problem? as in, does it error, or do you just not get the expected value in USERS#?

I noticed you declared your oValue as Object, which I would think should work, but the USERS variables are String Variables, so you might try declaring it as String, or doing Cstr(oValue) when you pass it....

Any time I want to find examples to learn from, I go to Through the Interface first http://through-the-interface.t ypepad.com/

Dim AcDocs As DocumentCollection = Application.DocumentManager

Dim ActDoc As Document = AcDocs.MdiActiveDocument

Dim DB As Database = ActDoc.Database

but The USERS# variables are not accessible from there (because they are not saved in the dwg)

Dave O.                                                                  Sig-Logos32.png
Message 7 of 9
Anonymous
in reply to: BrentBurgess1980

David is mistaken.

SetSystemVariable's second argument is System.Object,
so what you are doing is perfectly correct, assuming that
the value of oValue is a string.

You say you're having trouble, but that doesn't really tell
us much. You need to be more specific as to what error
you get, and so on.

And, if you are setting this variable, AutoCAD may also
require you to lock the document, if you're doing it from
the Application context, such as from an event handler
of a control on a PaletteSet.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

wrote in message news:6044208@discussion.autodesk.com...
Thanks for the information. I am having trouble setting the users variables. All other ones are fine and I can set them. This is a snippet from my code. '------ Dim oValue As Object = LblFolder.Text Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("USERS5", oValue) '------ I can get the "users" variables using the ....GetSystemVariable("USERS5") Any idea that I could be doing wrong? Also where can I find more information of the Database object? I am finding the search function in the new setup hard to use. Thanks Brent
Message 8 of 9

Thanks for the information Tony. The information is being called from an event in a tool palette I have create. The strange this is I am not getting any error when the event is called. Lets say for argument sake that oValue = LblFolder.Text.ToString ("PEK832"). I can get oValue.ToString to appear in a mesasge box, but when it comes to set the variable, it seems as though it is not recognised. I will have a look at locking the document and see if that helps. FWIW, I am using VB express 2008, AutoCAD 2008.

I have been programming with VBA for about 3 years now, and am trying to learn .NET. Can you recommend any good resource material, or courses that would be beneficial to learning .NET?

Thanks
Brent
Message 9 of 9

Thanks Tony - I locked the document and it worked fine.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost