TheSwamp

Code Red => .NET => Topic started by: chriskroll on March 31, 2015, 10:53:59 AM

Title: Imperial to Metric Conversion Disabled (Civil3D)
Post by: chriskroll on March 31, 2015, 10:53:59 AM
I need to check the setting of the "Imperial to Metric Conversion" box in the Civil 3D drawing settings dialog (See Attached Image).  For some reason this box can be enabled/disabled by choosing different coordinate systems.  Furthermore, the values I am getting in code are not accurate if the "Imperial to Metric Conversion" box is grayed out.  Does anyone know how I can determine if the coordinate system is overriding this setting through code?

Code: [Select]
CivilDocument civilDocument = CivilDocument.GetCivilDocument(dwgDB);

_AngularUnits = civilDocument.Settings.DrawingSettings.UnitZoneSettings.AngularUnits.ToString();
_DrawingUnits = civilDocument.Settings.DrawingSettings.UnitZoneSettings.DrawingUnits.ToString();
// This property will be "InternationalFoot" even if it is displayed as "US Survey Foot" in the interface.
_ImperialToMetricConversion = civilDocument.Settings.DrawingSettings.UnitZoneSettings.ImperialToMetricConversion.ToString();
Title: Re: Imperial to Metric Conversion Disabled (Civil3D)
Post by: Jeff_M on March 31, 2015, 11:06:37 AM
I believe that if the coordinate system is in feet, and the dwg units are in feet, then that is disabled. However, if the dwg units are different than the CS, then that option is enabled.
Title: Re: Imperial to Metric Conversion Disabled (Civil3D)
Post by: chriskroll on March 31, 2015, 11:16:55 AM
Thanks, good to know that Jeff.  Now I just need to know if there is a way to determine if the coordinate system is in feet.  It seems like the Civil 3D API only gives you access to the coordinate system code.
Title: Re: Imperial to Metric Conversion Disabled (Civil3D)
Post by: mjfarrell on March 31, 2015, 11:31:19 AM
curious; about what it is you are attempting to do, or prevent?
Title: Re: Imperial to Metric Conversion Disabled (Civil3D)
Post by: chriskroll on March 31, 2015, 11:34:51 AM
I am writing an auditing program.  The client has thousands of drawings that need to be checked for proper settings.  One of the settings they want checked is the "Imperial to Metric" box. 
Title: Re: Imperial to Metric Conversion Disabled (Civil3D)
Post by: Jeff_M on March 31, 2015, 11:38:29 AM
Here's a quick little example of how to get the CS's units:
Code - C#: [Select]
  1.         [CommandMethod("GetCS")]
  2.         public void getcs()
  3.         {
  4.             CivilDocument civdoc = CivilApplication.ActiveDocument;
  5.             SettingsCoordinateSystem coordsys = SettingsUnitZone.GetCoordinateSystemByCode(civdoc.Settings.DrawingSettings.UnitZoneSettings.CoordinateSystemCode);
  6.             Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\nThe current Coordinate system is: {0}, whose units are in {1}", coordsys.Description, coordsys.Unit);
  7.         }
  8.  

You will likely need to handle the case where a CS has not been set for the dwg.
Title: Re: Imperial to Metric Conversion Disabled (Civil3D)
Post by: chriskroll on March 31, 2015, 11:56:42 AM
Thanks Jeff! That code works beautifully.  :-D