project units

project units

Moshe-A
Mentor Mentor
1,240 Views
4 Replies
Message 1 of 5

project units

Moshe-A
Mentor
Mentor

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



 

 

0 Likes
1,241 Views
4 Replies
Replies (4)
Message 2 of 5

Moshe-A
Mentor
Mentor

Good Morning,

 

forgot to mention...i did moved the Project Base Point from Survey Point/Startup Point

 

 

 

 

0 Likes
Message 3 of 5

Moshe-A
Mentor
Mentor

here is an update

 

i think i figure it out  (working on Revit 2015)

 

document.ActiveProjectLocation

 

return EastWest and NorthSouth only if the Project Base Point was moved cliped

it will returns the origin point (0, 0, 0) if the Project Base Point was moved unclipped

is this a bug? or that's how it works?

 

another issue is:

formatoptions.DisplayUnits = units.GetFormatOptions(UnitType.UT_Length).DisplayUnits;

 

this return DUT_MILIMETERS even if the project units is in CM or Meter

again is this a known bug?

 

 

 

 

0 Likes
Message 4 of 5

FAIR59
Advisor
Advisor

for projectunits try:       Units units= document.GetUnits();

0 Likes
Message 5 of 5

Moshe-A
Mentor
Mentor

yes i did that

 

i have pretty much solved all my issues, the only issue left is this:

 

 document.ActiveProjectLocation

 

return EastWest and NorthSouth only if the Project Base Point was moved cliped

it will returns the origin point (0, 0, 0) if the Project Base Point was moved unclipped

is this a bug? or that's how it works?  (in Revit 2015)

 

 

 

0 Likes