Deeper Parameter Exploration

We already discussed

exploring element parameters

in some depth.
Nicholas raised a

question

on this that prompted me to take the discussion one step further:

Question:
I noticed for certain special parameters I can’t access the value.
For example with Lighting Fixtures, there are parameters like Light Loss Factor, Initial Intensity and Initial Color. The value field is a button, which opens a special window.
Do you think it’s possible to access the value of these parameters?
These parameters are available when there is a Light Source Definition in the family and can be found under the Type parameters.
When I check the ParameterType property on them, the result is “Invalid”.
Their value is “0” and its StorageType is Integer.

Answer:
I found a component that has the parameters that you are interested in.
It is the studio light, which I can insert using Modelling > Component CM > Load > Lighting Fixtures > M_Studio Light.rfa.
In the Revit user interface element properties dialogue, I see these properties, and I see that their value field is a button which opens a special custom dialogue to edit their settings.

Looking at the element instance parameters using the built-in parameter checker that is part of the

Revit API introduction labs
,
I see that several different parameters seem to be related to these.
They all seem to be associated with FBX and rendering.
Here is a partial list, as obtained from the built-in parameter checker (copy and paste to an editor to see complete text of truncated over-long lines):


FBX_LIGHT_LOSS_FACTOR_CTRL : Light Loss Factor : Integer
FBX_LIGHT_INITIAL_COLOR_CTRL : Initial Color : Integer
FBX_LIGHT_LOSS_FACTOR_METOD : Light Loss Input Method : Integer/Integer
FBX_LIGHT_INITIAL_COLOR_NAME : Temperature Color : Integer
FBX_LIGHT_INITIAL_INTENSITY_INPUT_METOD : Initial Light Intensity Input Method : Integer/Integer
FBX_LIGHT_SURFACE_LOSS : Surface Depreciation Loss : Double
FBX_LIGHT_LAMP_TILT_LOSS : Lamp Tilt Loss : Double
FBX_LIGHT_VOLTAGE_LOSS : Voltage Loss : Double
FBX_LIGHT_TEMPERATURE_LOSS : Temperature Loss : Double
FBX_LIGHT_COLOR_FILTER : Color Filter : Integer
FBX_LIGHT_INITIAL_COLOR_TEMPERATURE : Initial Color Temperature : Double
FBX_LIGHT_INITIAL_INTENSITY : Initial Intensity : Integer
FBX_LIGHT_BALLAST_LOSS : Ballast Loss : Double
FBX_LIGHT_TOTAL_LIGHT_LOSS : Total Light Loss Factor : Double

As you say, most of these have the storage type Integer, although some have Double, their values are all zero, and they are all marked as read-write.

Notice that a few of these have a rather strange value type of Integer/Integer, and their built-in parameter enumeration name has the suffix METOD. I assume this is a misspelling of ‘method’, and that these parameters internally provide access to some event handling routines which display the dialogues you are seeing for inputting the values.

Exploring these further, I found out how to read two of the parameter values that you are asking for.
As you say, these are type parameters, not instance ones.

I first set up my own values for the parameters I am exploring through the Revit user interface element properties dialogue, and then use the built-in parameter checker to see how to access the values through the API.

Select the studio light instance > Right click context menu > Element properties… > Edit/New to access the type properties. Type Properties > Light Loss Factor > a dialogue appears. Drag the slider or enter a value in the edit box, such as 3.45. Click OK twice. Select the instance again, open the built-in parameter checker, and select the type parameters by answering ‘No’ to the question:
“This element is a family instance, so it has both type and instance parameters. By default, the instance parameters are displayed. If you select ‘No’, the type parameters will be displayed instead. Would you like to see the instance parameters?”

Look at the value of the parameter FBX_LIGHT_TOTAL_LIGHT_LOSS ‘Total Light Loss Factor’. It contains the Light Loss Factor value you just entered.

Similarly, I set the values of Initial Intensity to 4567.00 lm and used the built-in parameter checker to find its value in the parameter FBX_LIGHT_LIMUNOUS_FLUX ‘Luminous Flux’.

I hope this answers your question, and also explains better what use we can make of the built-in parameter checker to explore the Revit model and its data. It also shows that we really do have pretty good access to the data we are interested in.


Comments

14 responses to “Deeper Parameter Exploration”

  1. Nicholas Avatar
    Nicholas

    Hello Jeremy,
    thanks for your time and effort on this matter. I have been trying to get this working today but I don’t understand how you get to the Integer/Integer storagetype. When I use the function GetParamStorageType, it returns Integer.
    param = fi.get_Parameter(Parameters.BuiltInParameter.FBX_LIGHT_LOSS_FACTOR_METOD)
    MsgBox(“Name: ” + param.Definition.Name + ” | Storage type: ” + GetParamStorageType(param).ToString)
    I’ve also ran your BuiltInParamsChecker but it displayed Integer and 0 as well.
    Maybe I’m doing something wrong :)

  2. Dear Nicholas,
    Thank you for your appreciation and sorry I was not clear enough, although I am also sorry to say I do not know how to put it any clearer.
    I just mentioned the Integer/Integer storage type above to say that it is probably somehow associated with the special input method. I retrieve that storage type through the method Type of the BuiltInParamsChecker ParameterData class:
    public string Type
    {
    get
    {
    // returns ‘Invalid’ for ‘ElementId’:
    ParameterType pt = _parameter.Definition.ParameterType;
    string s = ParameterType.Invalid == pt
    ? “”
    “/” + pt.ToString();
    return _parameter.StorageType.ToString() + s;
    }
    }
    I did not suggest that you try to access or use that value in any way, I do not believe that you can make any use of it. To see how I access it, look at the BuiltInParamsChecker source code.
    What I do suggest is to access the value of the built-in parameters FBX_LIGHT_TOTAL_LIGHT_LOSS and FBX_LIGHT_LIMUNOUS_FLUX, which correspond to two of the values you were asking about, ‘Total Light Loss Factor’ and ‘Luminous Flux’. Possibly the third one you are interested in is also accessible.
    I found those by setting the value through the user interface and then exploring the parameters returned by the API to find out where it showed up.
    Cheers, Jeremy.

  3. Nicholas Avatar
    Nicholas

    Hey Jeremy,
    I cannot find a way to display the correct value. With RvtMgdDbg I checked the parameters.
    Under ‘Snoop Parameters’ I see Light Loss Factor with:
    Storage Type: Integer
    Value: 0
    As value string: (empty)
    But under ‘Snoop Built-in Parameters’ I find FBX_LIGHT_TOTAL_LIGHT_LOSS and it says:
    Storage Type: Double
    Value: 1.23
    As value string: 1.230000
    As said I use param = fi.get_Parameter(Parameters.BuiltInParameter.FBX_LIGHT_TOTAL_LIGHT_LOSS)
    but could you give me the VB code to get from that to the actual value?
    I’ve tried param.AsValueString and param.AsDouble.ToString but they both return 0 instead of 1.23
    In your BuiltInParamsChecker.vb you also use AsDouble.ToString. When I run this, I also get a value of 0 for every FBX_LIGHT_… built-in parameter. Do you get the actual values for these?
    Thanks, Nicholas

  4. Dear Nicholas,
    You may be looking at the parameters on the instance, and not on the type or symbol that it is referencing.
    The instance also has these parameters, and their value is zero.
    The type has the real value, that you set in the user interface.
    Cheers, Jeremy.

  5. Nicholas Avatar
    Nicholas

    Thanks Jeremy, you were right. It’s strange how the family instance also has these built-in parameters. As far as I know, these special light source parameters cannot be added or edited by the user, so they’re always Type parameters.
    Anyway, I now accessed them via the ObjectType:
    param =
    elem.ObjectType.get_Parameter(Parameters.BuiltInParameter.FBX_LIGHT_TOTAL_LIGHT_LOSS)
    This works! Thanks a lot!
    I found this post very interesting and I hope it can help other people as well.
    Greetings,
    Nicholas

  6. Dear Nicholas,
    I am very glad you got it working. Perseverance paid off.
    Cheers, Jeremy.

  7. Dear Jeremy,
    A general question about parameters – how can I set a parameter’s value to nothing? In the element parameters dialog I can select the entire parameter value, delete it, and it shows as empty. This works regardless of its type – whether it is a string, integer, single, double, etc. How can I do this via the Revit API? For string parameters this is simple, but what about parameters of other types?
    Thanks for any light you can shed on this.

  8. Hi Paul,
    Thank you for this interesting question. Unfortunately, the answer, as far as I know, is simply that you cannot. Nor is there a way to determine through the API whether a parameter has yet been assigned a value or not.
    Cheers, Jeremy.

  9. Dear Jeremy,
    Actually I have to admit I was wrong about being able to delete a parameter’s value in the UI.
    It will show as empty when it hasn’t been assigned a value yet, but if you try to delete a numeric parameter value the UI will insist you enter a number.
    Thanks,
    Paul

  10. Hi Paul,
    Thank you for the additional information. Then at least as regards setting the parameter, the API is on a par with the user interface: both cannot set to parameter value to nothing; whereas in the user interface, you can see that it is set to nothing, and the API cannot determine this state.
    Cheers, Jeremy.

  11. Hello Jeremy . Thanks for your brilliant and exhaustive work.
    I am trying to retrieve all geometry instance parameters for each model category. I need this for costs calculating. I want the user to select it in a configuration window which parameter he wants. So I am not looking for a particular object parameter value. That will come later. First I need to know dynamically which parameters are available. For example in Walls those are Area, Length and Volume. In roofs: Thickness, Volume and Area. But how can I get to know this if there is nothing drawn yet? This would be great, users could configure the application and save the configuration for future projects.
    Thanks

  12. Dear José,
    Thank you for your appreciation.
    I am not aware of any method to know in advance which parameters an element might have if no such element exists yet. The easiest solution I can think of is to insert such an element within a temporary transaction, query it for its parameters, and then abort and roll back the transaction again.
    By the way, your web site does not display anything at all on my version of Firefox, which is 3.6.15, in case this is of interest to you. The exact version I am using is
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15 ( .NET CLR 3.5.30729; .NET4.0E)
    Cheers, Jeremy.

  13. Found Something!
    http://thebuildingcoder.typepad.com/blog/2010/01/retrieving-project-parameters.html
    Anyhow I decided to use parameters AFTER assigning an element and not BEFORE. Then I have much less to worry.
    Thanks!

  14. Dear José,
    Felicitaciones!
    Your web site does not work on Firefox 4.0 either…
    Cheers, Jeremy.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading