Level Parameter Bug - Read only

Hi all,

I have been playing about with a Dynamo graph and have run across what appears to be a bug. Happy to be corrected however!

I am trying to adjust some Revit element levels, however have been hampered by random ‘read-only’ errors on various elements.

I’ve done a little bit of testing on various elements, and I cannot find any logical outcomes. The level parameter appears to be set to read only completely at random.

In this example I have placed a number of Air Terminals, then simply run the Clockwork Element.ParameterIsReadOnly node on the Level parameter. The air terminals are non-hosted elements.

So of course I assumed that something was impacting on the level parameter for those that were not accessible.
I’ve tried different files, different element types and categories, messing about with element ownership (workshared). There isn’t any commonality between what is set read only and what isn’t.

To make things even more confusing, every time I adjust any element, (including non-associated ones eg. not of the same category/type/family), the elements all randomly reset whether the Level parameter is read-only.

Help! What is going on here? Does anyone have any input as to how I can free up this parameter consistently? I have found a few threads that touch on this topic, but no outcomes.

cheers

Strange, pretty much the same code as in clockwork node and different results :smiley:


Ok, your Python code is well above my expertise! What I am gathering is that you are using Python to check if those parameters are read-only, and getting all false results?

My assumption is that the Clockwork node is working and the parameters (some) are indeed set to read-only, as I stumbled across this issue while trying to write to the Level parameter using element.SetParameterByName. The clockwork node was just used as a separate check and wasn’t even used until I identified the problem existed.

If it helps, I am using Dynamo 1.0.0.1180 and Clockwork package 0.90.7

I’ve experienced this same behaviour as well and couldn’t get around it with the OOTB nodes.
I finally solved it by using some python code.

You can use this:

with the following python code:

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

element = UnwrapElement(IN[0])
ref_level = UnwrapElement(IN[1])

TransactionManager.Instance.EnsureInTransaction(doc)

for i,x in enumerate(element):
	ref_levelid = ref_level[i].Id
	
	object_param_level = x.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM)

	object_level = doc.GetElement(object_param_level.AsElementId())

	object_param_level.Set(ref_levelid)

TransactionManager.Instance.TransactionTaskDone()

OUT = element

Hi @SimonG

Modify custom node as shown in the image below and it should work for you.

Thanks guys - will give it a go and see if I can get it working!

Just an update:

@Kulkul - your method works to get elements to report as not read-only, however I still can’t write to those parameters. Not sure if this this is just reporting false results or I’m not doing something else right?

@T_Pover - This seems to work - thanks!. I have managed to get all elements to write to the Level parameter using the Python script.

I actually need to write to both “Level” and “Offset” parameters in the same transaction, so that the element doesn’t actually move in space. I guess I will have to start learning a bit of Python!

cheers
S

Hi Simon,

You can change the offset by replacing the appropriate section with the following code:

element = UnwrapElement(IN[0])
ref_level = UnwrapElement(IN[1])
offset = IN[2]

TransactionManager.Instance.EnsureInTransaction(doc)

for i,x in enumerate(element):
	ref_levelid = ref_level[i].Id
	
	object_param_level = x.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM)

	object_level = doc.GetElement(object_param_level.AsElementId())

	object_param_offset = x.get_Parameter(BuiltInParameter.INSTANCE_FREE_HOST_OFFSET_PARAM)

	object_newoffset = offset[i]

	object_param_level.Set(ref_levelid)
	object_param_offset.Set(object_newoffset)

TransactionManager.Instance.TransactionTaskDone()

You can now plug in an offset value as extra input, but you’ll probably have to convert it to the right units (in my case I have to divide by 304.8).

2 Likes

Thanks @T_Pover !!

Works a treat. I had a crack myself but took a guess at the parameter identifier - and got it wrong.
Was trying to use INSTANCE_OFFSET_POS_PARAM.

Side question - how do I identify the correct built in parameter identifier?! (not sure on the correct terminology either)
If I modify the task to work on Ducts, the parameter is different e.g. “Reference Level” instead of “Level”

I used the Clockwork node Document.ListBuiltInParametersByName to try to identify the correct one. Had a go with a few including INSTANCE_REFERENCE_LEVEL_PARAM but no dice.

cheers
S

You’re welkcome.
You can use the Built In Parameter Checker to find all the built in parameters:
http://whatrevitwants.blogspot.nl/2014/05/built-in-parameter-checker-updated-for.html

For Ducts you can probably just use the normal SetParameter node to set the Reference Level. At least that works for me.

Ok great.

I just about forgot that the issue was with the Level parameter only, but having said that, it would be nice not to have two separate graphs to work with.

Will have a go at the built in parameter checker, as I’m sure it will come in handy in the future.

thanks again

HI

I’ve been trying to change level for pipes too, but my python skills are very limited, but I think that I have found the right BuiltInParameters!! You can see my code below. :slight_smile: I get an error in line 24
Another issue is, is it possible to use the start and end offset param or is it not possible?? they look as they are read only.
Thanks in advance
Here comes the code:

import clr

clr.AddReference(‘RevitAPI’)

from Autodesk.Revit.DB import *

clr.AddReference(“RevitNodes”)

import Revit

clr.ImportExtensions(Revit.Elements)

clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference(“RevitServices”)

import RevitServices

from RevitServices.Persistence import DocumentManager

from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

element = UnwrapElement(IN[0])

ref_level = UnwrapElement(IN[1])

offset = IN[2]

TransactionManager.Instance.EnsureInTransaction(doc)

for i,x in enumerate(element):

ref_levelid = ref_level[i].Id



object_param_level = x.get_Parameter(BuiltInParameter.RBS_START_LEVEL_PARAM)



object_level = doc.GetElement(object_param_level.AsElementId())



object_param_offset = x.get_Parameter(BuiltInParameter.RBS_OFFSET_PARAM)



object_newoffset = offset[i]

object_param_level.Set(ref_levelid)

object_param_offset.Set(object_newoffset)

TransactionManager.Instance.TransactionTaskDone()

OUT = element

Sorry for asking for help, it was not necessary, because the python script is working. I discovered that I gave a wrong input.(list with start and end offset, It should only be with start offset) So feel free to use the script. :slight_smile:

Hallo T_Pover,


I hope it is ok to write you… I have a question and i ll be happy if you could help me!! I am trying to get in a roomtag in revit the values of the finish floor level… i have started in Dynamo with these Codes, but i could not get it… I really appreciat it if you can correct me … Thanks alot from Germany!! Haseeb

Hello @haseebn,

I don’t really understand your question, maybe you could expand on your question a bit?
It would also be better to create a new post for this as it isn’t really related to the previous posts in this thread.

dear ,

i looking to change MEP element offset by dynamo

i tried to use this script but is give me error in line 25

i asking if you have another way to solve this?