Get Variables set by Units command

Get Variables set by Units command

Anonymous
Not applicable
1,978 Views
7 Replies
Message 1 of 8

Get Variables set by Units command

Anonymous
Not applicable

Hi, how can I get system variables ,in c#,set by Units command , how to know what variable is set ?

 

Bsr

0 Likes
1,979 Views
7 Replies
Replies (7)
Message 2 of 8

_Tharwat
Advisor
Advisor

Hi,

 

This is an example of how to get the System Variable OSMODE.

 

 Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("OSMODE");
0 Likes
Message 3 of 8

phliberato
Advocate
Advocate

You can get this values using the DataBase object.

 

For example, if you want to use the precision lenght:

 

 

Database db = HostApplicationServices.WorkingDatabase;
int precision = db.Luprec;
Message 4 of 8

tamara
Advocate
Advocate

Hello,

do you know how to set the rest of the UNITS variables. Direction of base angle to be NORTH, and angle to be calculated CLOCKWISE, to be specific. Thank you.

 

Best regards,

Tamara Popovic

0 Likes
Message 5 of 8

_gile
Consultant
Consultant

Hi

 

ANGBASE & ANGDIR



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 6 of 8

tamara
Advocate
Advocate

Thank you, but this is what I get when I set ANGBASE to 90, and ANGDIR to 1.

Image 12.png

 

This "Rotacija" property is my custom atribute that just reads rotation property from Block Reference entity and displays it in decimal value. It still shows value respect to AutoCAD's original angle direktion which is East. Seems like under the hood nothing changed.

0 Likes
Message 7 of 8

_gile
Consultant
Consultant

The BlockReference.Rotation property is always measured in radians counterclockwise from the X axis of the block reference OCS (while the block reference normel is equal to Z Axis, the OCS is the same as WCS).

You can convert the BlockReference.Rotation value to a clockwise positve decimal degrees value starting from north doing:

 

double degrees = (450.0 - blockReference.Rotation * 180.0 / System.Math.PI) % 360.0;

Another way, if the ANGBASE and ANGDIR sysvars are correctly set, is to use the Converter.AngleToString() method.

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 8 of 8

tamara
Advocate
Advocate

Thank you very much. I was looking at the problem the wrong way trying to get the CAD behave like I want. Instead I have to adapt to it's behaviour.

 

Best regards,

Tamara Popovic

 

 

 

0 Likes