Message 1 of 5
project units
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Guys Hi,
i am retrieving the Project Base Point and i would like to format it according to the current Project Units
here is my simple code:
namespace MyNameSpace
{
public class Command : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Document document = commandData.Application.ActiveUIDocument.Document;
ProjectLocation projectlocation = document.ActiveProjectLocation;
XYZ origin = new XYZ(0, 0, 0);
ProjectLocation position = projectlocation.get_ProjectPosition(origin);
double angle = position.Angle;
double eastWest = position.EastWest;
double northSouth = position.NorthSouth;
Units units = new Units(UnitSystem.Metric);
FormatValueOptions formatvalueoptions = new FormatValueOptions();
FormatOptions formatoptions = new FormatOptions();
formatoptions = units.GetFormatOptions(UnitType.UT_Length);
formatvalueoptions.SetFormatOptions(formatoptions);
string s1 = UnitFormatUtils.Format(document.GetUnits(), Autodesk.Revit.DB.UnitType.UT_Length, eastWest, false, false, formatvalueoptions);
string s2 = UnitFormatUtils.Format(document.GetUnits(), Autodesk.Revit.DB.UnitType.UT_Length, northSouth, false, false, formatvalueoptions);
return Autodesk.Revit.UI.Result.Succeeded;
}
}
}
Units units = new Units(UnitSystem.Metric);
can i get the UnitSystem from the project?
s1 + s2 are set to be "0", what am i doing wrong?
(i do not want to set each FormatOptions properties, i would like them to inherit from Units)
if there is another way to do this?
thanks in advance
Moshe