How Identifying User-Set Measurement Units in AutoCAD Architecture for Drawing, Area, Volume, and Angle?

How Identifying User-Set Measurement Units in AutoCAD Architecture for Drawing, Area, Volume, and Angle?

ramesh_choudhari
Enthusiast Enthusiast
366 Views
1 Reply
Message 1 of 2

How Identifying User-Set Measurement Units in AutoCAD Architecture for Drawing, Area, Volume, and Angle?

ramesh_choudhari
Enthusiast
Enthusiast

In AutoCAD Architecture application, users have the flexibility to choose different units for area and volume measurements, such as square feet or cubic meters, independent of the drawing's original units. Now, I need to determine the units set by the user for the drawing, area, volume, and angle measurements programmatically.

ramesh_choudhari_0-1715849290522.png

 

Could someone provide guidance or code snippets on how I can achieve this using the .NET API? Any help would be greatly appreciated!

0 Likes
367 Views
1 Reply
Reply (1)
Message 2 of 2

Gepaha
Collaborator
Collaborator

Search for "DrawingSetupVariables".
Add a reference to AecBaseMgd.dll.
Autodesk.Aec.ApplicationServices.DrawingSetupVariables: settings saved in the drawing database.
Autodesk.Aec.Arch.ApplicationServices.ArchDBVariables: architectural object settings.
https://www.autodesk.com/autodesk-university/class/What-AutoCADR-ACAMEP-AutoLISPR-Guy-Supposed-Do-20... 

 

 

 

Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = HostApplicationServices.WorkingDatabase;
Transaction tr = db.TransactionManager.StartTransaction();

using (tr)
{
    ObjectId objID = AecApp.DrawingSetupVariables.GetInstance(db,false);
    AecApp.DrawingSetupVariables dsv = (AecApp.DrawingSetupVariables)tr.GetObject(objID, OpenMode.ForWrite);
    // drawing units
    String from = dsv.LinearUnit.ToString();
    String to = Autodesk.Aec.BuiltInUnit.Meter.ToString();
    ed.WriteMessage("{0} to {1}.",from, to);
    dsv.LinearUnit = Autodesk.Aec.BuiltInUnit.Meter;
    // drawing scale
    double dblScale = dwgVars.DwgScale;
    // annotation plot size
    double dblPlotSize = dsv.TextHeight;

    tr.Commit();
}
ObjectId idDwgVars = DrawingSetupVariables.GetInstance(database, false);            
DrawingSetupVariables dwgVars = trans.GetObject(idDwgVars, OpenMode.ForRead) as DrawingSetupVariables;
switch (dwgVars.LinearUnit)
{
  case Autodesk.Aec.BuiltInUnit.Inch:
     // .....         
  case Autodesk.Aec.BuiltInUnit.Foot:
     // ...
  case Autodesk.Aec.BuiltInUnit.Millimeter:
     // ...
  case Autodesk.Aec.BuiltInUnit.Centimeter:
     // ...
  case Autodesk.Aec.BuiltInUnit.Decimeter:
    // ...
  case Autodesk.Aec.BuiltInUnit.Meter:
    // ...
  default:
    // ...
}            

 

 

 

0 Likes