Element.GetParamtervalueByName for Key schedules

I try to copy & paste a parameter, which is the Key Name of a Key Schedule.

For “Element.GetParamtervalueByName” I get the following message.

Warning: Element.GetParameterValueByName operation failed.
Could not obtain element from the current document! The id may not be valid.

For “Element.SetParamtervalueByName” I get the message.

Warning: Element.SetParameterByName operation failed.
The best overloaded method match for ‘Revit.Elements.InternalUtilities.ElementUtils.SetParameterValue(Autodesk.Revit.DB.Parameter, double)’ has some invalid arguments

1.Where do I find both Nodes in Python?
2.I am not sure what I am looking at after the Boolmask; is there a way to isolate the actual value?

Model Comparison groot BD wapening.dyn (96.9 KB)

Hi, In my opinion you need to work with Parameter.Value list and set it as value input to Element.SetParameterByName node and not Element.Parameters

Hi @Drbohlav

This makes sense.

Unfortunately, Paramater.Value node returns the same message as the Element.GetParameterValueByName node.

Any thoughts on how to isolate KeySchedule-KeyName Parameter?

Kind regards,

Willem

This is only test and it works for wall category:

Bit of a workaround, but could you use a String From Object node direct from the Element.Parameters node, then use an Item at Index node to get just the relevant parameter & value, then separate that string?

Are these elements not from your active model? If they’re in a link then the error is exactly correct. The key elements wouldn’t exist in your model.

Elements between two version of the same model are being compared. The KeySchedules & Key Names are identical. Different Key schedules have the same Key name Parameter

OK, I did more or less the same.

Now I get the message

Warning: Element.SetParameterByName operation failed.
The parameter’s storage type is not a string

So I wonder how we have to format it in order to get recognized.

I think the issue may be that you are attempting to set a parameter value that is controlled by a key schedule. Therefore you would need to assign the key schedule value, rather than to the wall itself.
For example, if you set the Wall Finish of a room to be controlled by a Room Style key schedule, you cannot control that parameter from the room itself.

How are they being compared though? Is one version linked into the other? Are you accessing one version in the background? As I said before, Dynamo (and Revit) won’t be able to find the element if it doesn’t exist in the active document.

This is exactly the issue I’m mentioning above. Key schedule values are elements. The parameter value will return an element object and would require an element object to be set. That element has to exist in the active document, just like any other element you want to interact with directly.

@dan.buckingham is right, but I think you are dealing with the Key Schedule parameter. That’s why you’re getting an error with a missing element.

Yes, the old version is linked in the current version, with the GetLinkDocument node from Quasar.

The “Get/SetParametervalues” nodes go well for all types of parameters, but obviously only for the elements already present 4 moths ago when the models diverged.

The Key schedules are younger, so I copied them this morning into the actual model.

I am trying to adres the Key Name Parameter from the Key schedules, not the parameters that are being controlled by the Key schedules.

If the “Key schedule elements”, cannot relate by their internal ID, is there another strategy possible?
How can I select the matching “Key schedule elements” in the actual model?

I guess the have the same Category as to the types of elements the Key schedules refer to?

You can get the string value from the linked Keys (either with Dan’s method above or through the API method specifically for this) in order to compare names. You would then have to get the Keys from your active model and search for a matching name, either with a dictionary or a direct comparison. This would tell you which key element to use in the active model.

Thank you for reaching out.

I have 1285 elements to match with 22 unique keynames in the actual model.

Do you have an example of graph for direct comparison, so I might copy it?
The way I understand dictionaries it requires lists of equal length
Model Comparison transfer Key Schedule values.dyn (92.2 KB)

The dictionary would just be for the key schedule key name and element in the active document, so that matching the name with the linked element would immediately give you the respective element from the active document. Otherwise you have an extra step.

Hi @Nick_Boyts

thank you for your patience in order to sort this out.

I am not sure I understand how to set the Keyname using Dynamo in the first place.

I get the message the storage type is not a string, when I Try to set any value from the Keynames accessible in the actual model.

How can Keynames be adressed?

If there is a solution for this, the notion of a Dictionary is to replace the Keynames from the linked model with those from the actual model, no?

Kind regards,

Willem
Model Comparison transfer Key Schedule values Dictionary.dyn (93.5 KB)

As mentioned previously, a key schedule value is an element, not a string. That’s why you can’t just use the same string from your active document. The dictionary is to pair the name with the element so that you can use the matching name from the link document to get the appropriate key element from your active document. Your ScheduleKeys node looks like it gives you the element and the name, so you can use that to easily make your dictionary.

EDIT:
You’re doing something like this, where you’re trying to match the linked version of the key with the local version based on the shared name:

I moved the case, to reassign KeyNames to Rooms after the Room KeySchedules has been reloaded from excell.

I follow the scheme, but the Keys were not present in the dictionary.

Am I missing something?

If I look at the components, KeyNames appear not to be accepted as keys, no?

RoomStyleSpare park 02.dyn (77.6 KB)

Hi @Nick_Boyts

your suggestion to have a look at dictionaries served me well in some graphs last month.

So now I want to check again whether I can get the Room Styles assigned.

Looking back, the issue was not that much of an Issue…

If it is useful to anybody, please find it here…

Key Schedule vanuit Dynamo 03.dyn (16.2 KB)