.NET

Reply
Active Member
RayRay_46
Posts: 7
Registered: ‎04-20-2010
Message 1 of 5 (533 Views)

.NET GetSystemVariable gets variable from wrong drawing in AutoCAD 2013

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

Hi,

 

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*
norman.yuan
Posts: 1,049
Registered: ‎04-27-2009
Message 2 of 5 (524 Views)

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*
_gile
Posts: 2,115
Registered: ‎04-29-2006
Message 3 of 5 (519 Views)

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

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

Hi,

 

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

Gilles Chanteau
Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 4 of 5 (483 Views)

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
RayRay_46
Posts: 7
Registered: ‎04-20-2010
Message 5 of 5 (426 Views)

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
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!