Active Member
7 Posts
2 Kudos
Registered: ‎04-20-2010
Post 1 of 5

.NET GetSystemVariable gets variable from wrong drawing in AutoCAD 2013

566 Views, 4 Replies
12-15-2012 05:39 AM



We are in the middle of implementing AutoCAD 2013 to replace 2010 so at the moment I am converting / modifying our own code to suit the AutoCAD 2013 API.


One of our routines collects data from drawings (drawings are not fysically opened in AutoCAD) using the system variables 'LimMin' and 'LimMax' in order to collect all objects drawing within the titleblock.


Point2d min2d = (Point2d) Application.GetSystemVariable("LimMin");
Point2d max2d = (Point2d) Application.GetSystemVariable("LimMax");


Only the objects in the titleblock area need to be processed and this gives the engineers also the opportunity to add extra information outside the titleblock. We have used this method in 2007 and 2010 releases of AutoCAD succesfully.


But with AutoCAD 2013 I have run into a snag. As said does this routine not fysically open the drawing in AutoCAD it merely adresses the 'autocad database'  so to speak. It seems that 2013 selects the variables from an opened active drawing instead of the 'opened' drawing by the routine. What do I need to modify in the lines of codes stated above to get this rouine up and running?


The workaround for this moment is to skip the collection in the titleblock area al together and select all objects in the entire drawing which does not speed up things very much :smileywink: 


thanks in advance of any assistence.

*Expert Elite*
1,088 Posts
217 Kudos
Registered: ‎04-27-2009
Post 2 of 5

Re: .NET GetSystemVariable gets variable from wrong drawing in AutoCAD 2013

12-15-2012 06:49 AM in reply to: RayRay_46

Acad system variables can be at session level or drawing level. The drawing level sys variable is stored with drawing. To me it is logical enough that Application.GetSystemVariable() get this type of variables' value from active document, not from the side database you created with Database.ReadDwgFromFile(). Just think, what if you have multiple side databases, which's LimitMax/Min the GetSystemVariable() should return?


Well, you could try HostApplicationService.WorkDatabase o your side database before calling Application.GetSystemVariable() . I have not tried this, so do not know if it works. The point is, I do not bother to try it: I can call Database.Limmax/Limmin property on the side database.

*Expert Elite*
2,142 Posts
255 Kudos
Registered: ‎04-29-2006
Post 3 of 5

Re : .NET GetSystemVariable gets variable from wrong drawing in AutoCAD 2013

12-15-2012 07:37 AM in reply to: RayRay_46



Did you try the Database.Limmin and Database.Limmax properties with your side database instance ?

Gilles Chanteau
Valued Mentor
370 Posts
175 Kudos
Registered: ‎05-06-2012
Post 4 of 5

Re: .NET GetSystemVariable gets variable from wrong drawing in AutoCAD 2013

12-18-2012 04:13 AM in reply to: RayRay_46

Where did you get the idea that GetSystemVariable() operates on anything but the active document's database to begin with?  If you just give it a little thought, the API doesn't ask for a database, so if there are more than one possible databases, which of them are you assuming it will return the value for?


GetSystemVariable() operates on the database of the active document that's open in the editor, not on any other database.  You can use the properties of the same name on the Database you're working with, but you should also know that the limits of a drawing that's not open in the editor may not be valid.

Active Member
7 Posts
2 Kudos
Registered: ‎04-20-2010
Post 5 of 5

Re: .NET GetSystemVariable gets variable from wrong drawing in AutoCAD 2013

01-18-2013 01:59 AM in reply to: RayRay_46

First of all .. my apologies for the late response. Somehow your reactions got delivered in my spambox.


Unfortunately I have not designed the mentioned code and the person responsible for this is not working with our company anymore. I have no idea why he used / developed the current code but is was working in AutoCAD 2010.


In the upcoming weeks I will try your suggestions. Much thanks!


Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!