Copying a value parameter to another parameter

How can I transfer the value of one parameter to another? for example, I have a length and I need to copy the value to O_Number

What did you try? @Andrey-SPGR

Hi, Jean-Marc. I need the length parameter to be copied to O_Количество.

Bear with me, but usually user forums are meant to help people doing stuffs, not help people asking for other to do it for them. You need to try a bit. Not just wait for someone to pickup your request and provide you with the result.

you could try with the rpw moddule here.
there are some examples in the code to achieve what you are after.

And I am not asking to write for me. I don’t know where to look. No offense. Thanks

from pyrevit import revit, DB
# collect your **element** first
with revit.Transaction('Transaction name'):
    param = element.get_Parameter(DB.BuiltInParameter.NAME_OF_BUILTIN_PARAM)
    param_data = element.get_Parameter(DB.BuiltInParameter.NAME_OF_BUILTIN_PARAM).AsString() #depends on the parameter data type

with Transaction(doc) as t:
t.Start(‘some text’)
param = element.get_Parameter(DB.BuiltInParameter.Length)
param_data = element.get_Parameter(DB.BuiltInParameter.Length).AsString()
param.Set(param_data )

what should be the name t.Start?
and it will work if I do this?

if you use with revit.Transaction('Transaction name'):
no need for t.Start or Commit

and it won’t work because:

  • param must be the parameter you want to copy the data to
  • param data will need to fetch the data from the source parameter
  • for DB.BuiltInParameter.NAME_OF_BUILTIN_PARAM, NAME_OF_BUILTIN_PARAM must be the name of the parameter according to the RevitAPI. You need to explore a bit with revit lookup to grab its name in both cases
  • element.LookupParameter(string name) or element.get_Parameter(string name) or alement.get_Parameter(Guid guid)
    it is easier for shared parameter to get them with LookupParameter as you will be able to get its data by its name directly

Hello. How should I work with the revit lookup?
Is there an example of some kind?

you are almost there, you need yo enclose what you have in the Transaction in a loop to go through your elements:

with revit.Transaction('what you are doing'):
    for element in cable_tray_collector:
        param = element.LookupParameter("your_recipient_param_name")
        param_data = element.LookupParameter("your_source_param_name").AsValueString()
        param.Set(param_data )

you might have to convert param_data to integer or number: param.Set(int(param_data))

Jean-Marc, don’t be angry. A thousand apologies. But what could be wrong?

no worries @Andrey-SPGR

you are passing the document as an argument to the revit.Transaction where it expects a string / name


with revit.Transaction('what you are doing'):


with revit.Transaction(doc):

you seem to be using vscode:
you should be able to get

that contains explainations about modules methods using F12 (or right click: go to definition) on the keyword you are looking for.

you mean this

Jean-Marc, THANK YOU VERY MUCH. Everything worked out.

jean-marc, how can i convert to meters?