using Autodesk.Civil.ApplicationServices;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
namespace Civil3D_DrawingProperties
{
public class C3D_Extensions_Terno
{
//Нод для смены системы единиц на метрическую
public static void ChangeDrawingUnitsToMeters(bool condition_meters)
{
//На вход подается условие - нужны ли метр, если false - то работает данный метод (if далее)
Document m_Doc = Application.DocumentManager.MdiActiveDocument;
Database db = m_Doc.Database;
//Они сами по себе, а строки ниже - сами по себе, это верно?!
CivilDocument c3d_doc = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument;
var Units_Window = c3d_doc.Settings.DrawingSettings;
//Инициация изменяемых переменных
var _DrawingUnits = Units_Window.UnitZoneSettings.DrawingUnits;
var _AngularUnits = Units_Window.UnitZoneSettings.AngularUnits;
var _ImperialToMetricConversion = Units_Window.UnitZoneSettings.ImperialToMetricConversion;
var _ScaleObjectsFromOtherDrawings = Units_Window.UnitZoneSettings.ScaleObjectsFromOtherDrawings;
var _MatchAutoCADVariables = Units_Window.UnitZoneSettings.MatchAutoCADVariables;
var _DrawingScale = Units_Window.UnitZoneSettings.DrawingScale;
var _DrivingDirection = Units_Window.AmbientSettings.General.DrivingDirection.Value;
var _Time = Units_Window.AmbientSettings.Time.Unit.Value;
var _Distance = Units_Window.AmbientSettings.Distance.Unit.Value;
var _Dimension = Units_Window.AmbientSettings.Dimension.Unit.Value;
var _Coordinate = Units_Window.AmbientSettings.Coordinate.Unit.Value;
var _GridCoordinate = Units_Window.AmbientSettings.GridCoordinate.Unit.Value;
var _Elevation = Units_Window.AmbientSettings.Elevation.Unit.Value;
var _Area = Units_Window.AmbientSettings.Area.Unit.Value;
var _Volume = Units_Window.AmbientSettings.Volume.Unit.Value;
var _Speed = Units_Window.AmbientSettings.Speed.Unit.Value;
var _Angle = Units_Window.AmbientSettings.Angle.Unit.Value;
var _Direction = Units_Window.AmbientSettings.Direction.Unit.Value;
var _LatLong = Units_Window.AmbientSettings.LatLong.Unit.Value;
var _Grade = Units_Window.AmbientSettings.Grade.Format.Value;
var _Slope = Units_Window.AmbientSettings.Slope.Format.Value;
var _GradeSlope = Units_Window.AmbientSettings.GradeSlope.Format.Value;
var _Station = Units_Window.AmbientSettings.Station.Unit.Value;
var _Acceleration = Units_Window.AmbientSettings.Acceleration.Unit.Value;
var _Pressure = Units_Window.AmbientSettings.Pressure.Unit.Value;
if (condition_meters == false)
{
//using (Transaction m_Tr = db.TransactionManager.StartTransaction()) //
using (Transaction tr = db.TransactionManager.StartTransaction())
{
_DrawingUnits = Autodesk.Civil.Settings.DrawingUnitType.Meters; //2
_AngularUnits = Autodesk.Civil.AngleUnitType.Degree; //179
_ImperialToMetricConversion = Autodesk.Civil.Settings.ImperialToMetricConversionType.InternationalFoot; //536870912;
_ScaleObjectsFromOtherDrawings = true;
_MatchAutoCADVariables = true;
_DrawingScale = Units_Window.UnitZoneSettings.DrawingScale = 1;// 1.0;
_DrivingDirection = Autodesk.Civil.DrivingDirectionType.RightSideOfTheRoad;// 0;
_Time = Autodesk.Civil.TimeUnitType.Minute;//301;
_Distance = Autodesk.Civil.LinearUnitType.Meter;// 2;
_Dimension = Autodesk.Civil.LinearUnitType.Meter;// 2;
_Coordinate = Autodesk.Civil.LinearUnitType.Meter;// 2;
_GridCoordinate = Autodesk.Civil.LinearUnitType.Meter; // 2;
_Elevation = Autodesk.Civil.LinearUnitType.Meter; // 2;
_Area = Autodesk.Civil.AreaUnitType.SquareMeter; //55;
_Volume = Autodesk.Civil.VolumeUnitType.CubicMeter;// 96;
_Speed = Autodesk.Civil.SpeedUnitType.KilometerPerHour;// 190;
_Angle = Autodesk.Civil.AngleUnitType.Degree;// 179;
_Direction = Autodesk.Civil.AngleUnitType.Degree;// 179;
_LatLong = Autodesk.Civil.AngleUnitType.Degree;// 179;
_Grade = Autodesk.Civil.GradeFormatType.Decimal;// 2468;
_Slope = Autodesk.Civil.SlopeFormatType.RiseRun;// 2465;
_GradeSlope = Autodesk.Civil.GradeSlopeFormatType.Decimal;// 2468;
_Station = Autodesk.Civil.LinearUnitType.Meter;// 2;
_Acceleration = Autodesk.Civil.AccelerationUnitType.MeterPerSecSquared;// 202;
_Pressure = Autodesk.Civil.PressureUnitType.Kilopascal;// 240;
tr.Commit();
}
}
else
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
_DrawingUnits = Autodesk.Civil.Settings.DrawingUnitType.Feet; //30
_AngularUnits = Autodesk.Civil.AngleUnitType.Degree; //179
_ImperialToMetricConversion = Autodesk.Civil.Settings.ImperialToMetricConversionType.InternationalFoot; //536870912;
_ScaleObjectsFromOtherDrawings = false;
_MatchAutoCADVariables = false;
_DrawingScale = Units_Window.UnitZoneSettings.DrawingScale = 1;// 1.0;
_DrivingDirection = Autodesk.Civil.DrivingDirectionType.RightSideOfTheRoad;// 0;
_Time = Autodesk.Civil.TimeUnitType.Minute;//301;
_Distance = Autodesk.Civil.LinearUnitType.Foot;// 30;
_Dimension = Autodesk.Civil.LinearUnitType.Inch;// 31;
_Coordinate = Autodesk.Civil.LinearUnitType.Foot;// 30;
_GridCoordinate = Autodesk.Civil.LinearUnitType.Foot;// 30;
_Elevation = Autodesk.Civil.LinearUnitType.Foot;// 30;
_Area = Autodesk.Civil.AreaUnitType.SquareFoot; //56;
_Volume = Autodesk.Civil.VolumeUnitType.CubicYard;// 153;
_Speed = Autodesk.Civil.SpeedUnitType.MilePerHour;// 196;
_Angle = Autodesk.Civil.AngleUnitType.Degree;// 179;
_Direction = Autodesk.Civil.AngleUnitType.Degree;// 179;
_LatLong = Autodesk.Civil.AngleUnitType.Degree;// 179;
_Grade = Autodesk.Civil.GradeFormatType.Percent;// 2467;
_Slope = Autodesk.Civil.SlopeFormatType.RunRise;// 2466;
_GradeSlope = Autodesk.Civil.GradeSlopeFormatType.Percent;// 2467;
_Station = Autodesk.Civil.LinearUnitType.Foot;// 2;
_Acceleration = Autodesk.Civil.AccelerationUnitType.FootPerSecSquared;// 203;
_Pressure = Autodesk.Civil.PressureUnitType.PoundPerSquareInch;// 242;
tr.Commit();
}
}
}
}
}