Built-In Enums?

Built-In Enums?

Anonymous
Not applicable
3,558 Views
10 Replies
Message 1 of 11

Built-In Enums?

Anonymous
Not applicable
I'm finding that quite a few of the Built-In parameters are stored as
integers, displayed in the Revit UI as strings. Which means that there
is an enum for those values somewhere...

But how do I access them, for display only, without writing my own code
to handle them on a case-by-case basis for hundreds of built-in parameters?

For instance:
Walls, Location Line or Structural Usage parameters:

The Built-In "Location Line" parameter appears to be
"WALL_KEY_REF_PARAM". I've found a "WallKeyRef" Enum in the Object
browser, but can't seem to access it because it isn't in a namespace
within RevitAPI.dll? Also, there's no explicit link I can find (name,
reference id, whatever) between the API-available parameter definition,
the built-in parameter name, and the enum, to where I could handle other
cases programatically with the same sub/function.

For the "Structural Usage" parameter, there appears to be *two*
built-ins: "WALL_STRUCTURAL_USAGE_TEXT_PARAM" (which holds the string I
want to display!), and "WALL_STRUCTURAL_USAGE_PARAM" (which holds the
integer). Again, there is a "WallStructuralUsage" enum, but it is
inaccessible. And again, no explicit link between everything.

I *do* notice that the enums that I have found, if they can be accessed,
are named similarly to the parameters, as are the two structural params
above, but I am leery of relying on these conventions in my code,
because I have always found Autodesk DB programming to be fraught with
inconsistencies in naming things like this...

--
Brian Winterscheidt
LWPB Architecture
Oklahoma City, Oklahoma
0 Likes
3,559 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable
Brian,
I believe that if you have an instance of an object and you recover the
parameter value as a string (instead of the integer value), then it comes
back as shown in the UI. So that would help if you just want to display the
parameter's current value.

"Brian Winterscheidt" wrote in message
news:[email protected]...
I'm finding that quite a few of the Built-In parameters are stored as
integers, displayed in the Revit UI as strings. Which means that there
is an enum for those values somewhere...

But how do I access them, for display only, without writing my own code
to handle them on a case-by-case basis for hundreds of built-in parameters?

For instance:
Walls, Location Line or Structural Usage parameters:

The Built-In "Location Line" parameter appears to be
"WALL_KEY_REF_PARAM". I've found a "WallKeyRef" Enum in the Object
browser, but can't seem to access it because it isn't in a namespace
within RevitAPI.dll? Also, there's no explicit link I can find (name,
reference id, whatever) between the API-available parameter definition,
the built-in parameter name, and the enum, to where I could handle other
cases programatically with the same sub/function.

For the "Structural Usage" parameter, there appears to be *two*
built-ins: "WALL_STRUCTURAL_USAGE_TEXT_PARAM" (which holds the string I
want to display!), and "WALL_STRUCTURAL_USAGE_PARAM" (which holds the
integer). Again, there is a "WallStructuralUsage" enum, but it is
inaccessible. And again, no explicit link between everything.

I *do* notice that the enums that I have found, if they can be accessed,
are named similarly to the parameters, as are the two structural params
above, but I am leery of relying on these conventions in my code,
because I have always found Autodesk DB programming to be fraught with
inconsistencies in naming things like this...

--
Brian Winterscheidt
LWPB Architecture
Oklahoma City, Oklahoma
0 Likes
Message 3 of 11

Anonymous
Not applicable
David Bartliff wrote:
> Brian,
> I believe that if you have an instance of an object and you recover the
> parameter value as a string (instead of the integer value), then it comes
> back as shown in the UI. So that would help if you just want to display the
> parameter's current value.


On length/area/volume/angle parameters stored as doubles, I have used
the .AsValueString to return what is seen in the UI (or something close
to it).

On most integer-based built-in parameters, I can't get those same results:
.ToString returns the parameter name
.AsValueString returns nothing
.AsString returns nothing
.AsDouble returns 0
.AsInteger returns numeric value
.AsElementId returns nothing/invalid id

Am I going about this the wrong way?

--
Brian Winterscheidt
LWPB Architecture
Oklahoma City, Oklahoma
0 Likes
Message 4 of 11

Anonymous
Not applicable
At first, I didn't understand what you were looking for, but yes you are on the right track and you need a switch/ select case statement:

[code]

Dim nameValue As String = ""
Select Case param.StorageType
Case Parameters.StorageType.Double
nameValue += param.AsDouble().ToString()
Case Parameters.StorageType.ElementId
nameValue += param.AsElementId().ToString()
Case Parameters.StorageType.Integer
nameValue += param.AsInteger().ToString
Case Parameters.StorageType.None
nameValue += param.AsValueString '"NONE"
Case Parameters.StorageType.String
nameValue += param.AsString()
Case Else
nameValue += ""
End Select
[\code]

hope that helps !
0 Likes
Message 5 of 11

Anonymous
Not applicable
ppathak wrote:
> hope that helps !

unfortunately, no. I have this already. 😞


For Built-In parameters that have drop-down menus of options in the
Revit UI, typically of StorageType=Integer and ParameterType=Invalid, I
can't find a way to obtain anything other than the integer value.

Wall's "Location Line" has 6 possible values.

Wall's "Structural Usage" has 4 values.

Roof's "Rafter Cut" has 3 values.

Structural Column's "Top Release" and "Bottom Release" each have 4
possible values.

Structural Beam's "Lateral Justification" has 3, "z-Direction
Justification" and "Stick Symbol Location" have 4, "Structural Usage"
has 5 values.

And on and on.

I can't find a way to get from the integer to the built-in enum, so I'm
having to write a *lot* of enums myself. And translate them, or leave
them as english-only in my UI regardless of Revit language.


--
Brian Winterscheidt
0 Likes
Message 6 of 11

Anonymous
Not applicable
ppathak wrote:
> hope that helps !

not quite,
ppathak.

your code example only provides a way to properly, and *directly*,
translate non-String data into a String;
but Brian's issue is a bit more complex than that.

Take this example:
In the RVT GUI, the Wall Parameter "Structural Usage" displays as a listing
of Text:
Non-bearing
Bearing
Shear
Structural Combined

But what Brian has found is that in the actual *database* these values are
stored as integers;
where (guessing):
1 = Non-bearing
2 = Bearing
3 = Shear
4 = Structural Combined

Brian has also uncovered, through the use of the Object Browser, that there
are specialized Enums present that provide the "Translation Keys" for
getting from a database integer value to the GUI string value; for the
various Parameters that work in this way. Unfortunately, he has not been
able to find a way to access these Enums via RVT's API.

Your code example would likely translate an integer of 1, into a string of
"1";
and not the GUI String value that is needed.

--
CoreyL
0 Likes
Message 7 of 11

Anonymous
Not applicable
Brian and CoreyL,

Ah, .. I see it now. Sorry, I didn't understand the problem initially (even though I thought I did 🙂 ) ! Hope you find the solution soon, this would be helpful.

Prashant Edited by: ppathak on Oct 14, 2009 10:34 AM
0 Likes
Message 8 of 11

Anonymous
Not applicable
One place revit has stored MANY (but maybe not all) of its enumerators is Autodesk.Revit.Enums. Use the object browser (VS 2005, View/Object Browser) to find this list. On any objects you have your cursor on, rightclick and select, Goto Definition and if it is a Revit object, it will jump to the object browser. Sometimes you can find the enumeration list within the object itself. Start poking around there.

You can also find other enums namespaces in structrural and such. Usually the object your after will have a property that points out where to go, like wall, Structural usage:

Public Property StructuralUsage() As Autodesk.Revit.Structural.Enums.WallUsage

Member of: Autodesk.Revit.Elements.Wall


jvj Edited by: JamieVJohnson on Oct 14, 2009 9:45 AM
0 Likes
Message 9 of 11

Anonymous
Not applicable
OOPS .... JamieVJhonson beats me to it.... man I should have been quicker... 🙂

OK,
Here is another .. for the Rafter cut on the Roof :

footPrintRoof.EaveCuts = Autodesk.Revit.Enums.EaveCutterType.PlumbCut

Hope that helps !

Prashant

Edited by: ppathak on Oct 14, 2009 12:12 PM Edited by: ppathak on Oct 14, 2009 12:14 PM
0 Likes
Message 10 of 11

tiago.cerqueiraQPL4Y
Community Visitor
Community Visitor

Hey  Brian,

have you found the solution to this problem? I am facing the same situation as you. 

0 Likes
Message 11 of 11

RPTHOMAS108
Mentor
Mentor

Not sure everything has an enum but the ones that exist can be found with reflection.

 

However I believe the best source of information for this is RevitAPI.chm

0 Likes