Author Topic: Imperial to Metric Conversion Disabled (Civil3D)  (Read 2504 times)

0 Members and 1 Guest are viewing this topic.

chriskroll

  • Guest
Imperial to Metric Conversion Disabled (Civil3D)
« 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();

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: Imperial to Metric Conversion Disabled (Civil3D)
« Reply #1 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.

chriskroll

  • Guest
Re: Imperial to Metric Conversion Disabled (Civil3D)
« Reply #2 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.

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Imperial to Metric Conversion Disabled (Civil3D)
« Reply #3 on: March 31, 2015, 11:31:19 AM »
curious; about what it is you are attempting to do, or prevent?
Be your Best


Michael Farrell
http://primeservicesglobal.com/

chriskroll

  • Guest
Re: Imperial to Metric Conversion Disabled (Civil3D)
« Reply #4 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. 

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: Imperial to Metric Conversion Disabled (Civil3D)
« Reply #5 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.

chriskroll

  • Guest
Re: Imperial to Metric Conversion Disabled (Civil3D)
« Reply #6 on: March 31, 2015, 11:56:42 AM »
Thanks Jeff! That code works beautifully.  :-D