Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ModelLine length does not reflect in GUI

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
dirk.neethling
520 Views, 8 Replies

ModelLine length does not reflect in GUI

Hello,

 

I am using Jeremy's BuildingCoder method

 

Creator.CreateModelLine

 

to draw planned and actual tunnel construction axes. However, the line lengths which I pass through the API do not reflect in the GUI. For example, the vector between the last face of a tunnel ring and the centroid of the new ring, has a constant length regardless of direction, equal to half the average ring width (the rings are conical in order to traverse turns), in this case AVG_HALF_WIDTH=1,406/2. In the API it goes in thus, for example:

 

l_ = Creator.CreateModelLine(doc, pnt, prev_ring_face);

 

with

+  pnt {(-0.793852403, -1.160418839, -9.490522163)}

+  prev_ring_face {(-1.192452544, -1.739473600, -9.495266745)}

 

and length being

(prev_ring_face-pnt).GetLength() = 0.70300000000000018 (see debugger screenshot1 attached)

 

This repeats for each tunnel ring.

In the GUI, when I select one of these vectors, the following dimension appears: 0,2143 (see attached screenshot1)

 

I reproduced this scenario for a simple line in the X-direction from an arbitrary point (0,0,20), using the length AVG_HALF_WIDTH=1,406/2:

 

XYZ start_test = new XYZ(0, 0, 20);

XYZ fin_test = new XYZ(AVG_HALF_WIDTH, 0, 20);

l_ = Creator.CreateModelLine(doc, start_test, fin_test);

var oLength = (doc.GetElement(l_.Id).Location as LocationCurve).Curve.Length;

 

with

+  start_test {(0.000000000, 0.000000000, 20.000000000)} Autodesk.Revit.DB.XYZ
+  fin_test {(0.703000000, 0.000000000, 20.000000000)} Autodesk.Revit.DB.XYZ

 

and oLength = 0.703

 

(see screenshot2)

 

The result in the GUI is again 0.2143  (see screenshot2), instead of the expected 0.703 which was passed through the API.

 

What is the reason for this discrepancy, or what am I doing wrong?

 

Thanks, dirk

 

8 REPLIES 8
Message 2 of 9

Dear Dirk,

 

the factor of your values is 0,3048, so I presume you must respect that API works with feet while GUI displays values in meters (depending on user settings).

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 3 of 9

Dear Revitalizer,
thanks for your answer, I'll test it now.
dirk
Message 4 of 9

Hi Dirk,

 

that's an important point:

Revit is not metric.

The model is measured in feet, and on ViewSheets, it operates in inches.

 

You always have to convert your values.

No need to test it, that's just a fact.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 5 of 9

ok, I'll change the code.
Message 6 of 9

Dear Revitalizer,

 

does this also apply to constants such as:

 

uiApp.Application.ShortCurveTolerance

Util.MinLineLength

 

i.e. are they also in feet?

 

dirk

 

Message 7 of 9

Hi Dirk,

 

yes, all the internal values are defined in the Imperial system.

It's an American product, no matter what the rest of the world may calculate with...

Metrication hasn't arrived the U.S. yet...

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 8 of 9

Dear Revitalizer,

 

another question, does this also apply to the default dimensions of FamilyInstances?

 

i.e. if say a Family Element was given the default width of 1,406m, and is then instatiated in Revit, does it's width stay 1,406, or does it now become

 

1,406/0,3048 = 4,6128  in the API and then in the GUI reverts back to 1,406?

 

dirk

Message 9 of 9

Hi Dirk,

 

the displayed values differ from the internal ones.

 

The user can set the displayed units, comma separators, digits and so on in the GUI.

These visible values can be got by the parameter.AsValueString() method.

 

But if there is a length parameter, for example, its value is stored in feet, so if you get its value by parameter.AsDouble(), you need to convert it before using it in your code, e.g. if you want to display it in a dialog.

I would recommend to calculate always in feet; no need for conversion until you interact with the user, changing his metric input into Revit's feet and vice versa.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community