Dynamo: Copy values between Revit® parameters
To copy values between different Revit parameters quickly, use Dynamo script. Let’s say that we entered information (parameters values) into many Revit family instances in our project just to realize that it should be on another place (in another parameter). Or we change our minds during the project (it happens).
So, in order to do the boring task of copying parameter values to another place quickly, let’s use the power of Dynamo.
The script is simple, it just uses Element.GetParameterValueByName
and Element.SetParameterByName
methods to get and set the values.
All you need to do is:
- Adjust selection method (example gets all instances of a category or select the elements manually),
- Type in the parameters names,
- Set if the parameters are type or instance,
- Run the script!
Make sure you are copying values of the same type. If not, make sure to cast into appropriate value type (integer, string, etc.)
Also, this script will not work on system families (see solution below).
For system families we will tweak the script a little bit:
Replace FamilyInstance.GetType
node with two additional nodes: FamilyType.Name
and FloorType.ByName
(or WallType.ByName
, or RoofType.ByName
etc.)
Download the scripts from the Warehouse
Additional tip: if you have multiple lacing going from one point, use Watch
node as an intermediate knot holder.
In which version of Dynamo and which package “familyinstance.gettype” will work?
You are right, I get the error message “Use Element.ElementType instead” on FamilyInstance.GetType node.
I have Dynamo 2.0.3.8810 an it works fine when I replace FamilyInstance.GetType node with Element.ElementType node. That node does not depend on any package.
Hi,
Do you what could be a problem that is doesn’t work for any wall, roof, floor families, but it works perfectly fine for doors, windows?
Hi, if you carefully look at the images above, and read my instructions, you will see that there are two approaches.
One for system families (walls, floors, roofs).
The other for external families (doors, windows etc).
HI
I can’t find the script to download in the Warehouse…how or where Can I download this script? Many thanks
Hi, thanks, you are right, the link did not work.
I corrected that, please try again:
https://www.engipedia.com/warehouse/revit/dynamo-copy-parameters-values/
Hi, thanks for the script. I tried it and it doesn’t seem to work well with parameters of the ‘integer’ type. I get the warning “Warning: Element.SetParameterByName operation failed.
The parameter’s storage type is not a string.” How can i do a workaround?
Hi Rene, the thing is, you need to cast string type into integer type before trying to write it into a parameter. You might use String.ToNumber node, then x:int; in Code block. Please check this post, there are several good solutions presented there: https://forum.dynamobim.com/t/convert-double-to-integer/6095/2
Hi Mirko, Thank you so much for the script. I am trying to use your script to copy “Workset” Value to a Shared Parameter, but it seams, it is nessassary for me to take a different apporach for copy&pasting “Workset” parameters. Would you please let me know what it needs to be done?
Hi, yes, I know, you get just a number.
You need to create custom Python script and put this code in:
import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
worksetnumber = IN[0]
doc = DocumentManager.Instance.CurrentDBDocument
collector = FilteredWorksetCollector(doc)
worksets = collector.OfKind(WorksetKind.UserWorkset).ToWorksets()
w = ''
for workset in worksets:
if str(workset.Id) == str(worksetnumber):
w = workset.Name
break
OUT = w
Stupid WordPress. Please add one tab in front of IF command and two tabs in front of BREAK command.
Thank you so much for your reply. Exactly, I just get numbers. I have Tried your code and it says –
“IronPythonEvaluator.EvaluateIronPythonScript operation failed. expected an indented block” –
(I made sure to added 1-tabs in front of “IF” command and 2-tabs in front of break command)
If you could offer a DYN file, it will truly save my day..
Hi Tim, I can’t right now, I am on my phone, you just need to validate the syntax, try with this tool https://extendsclass.com/python-tester.html
Just Kidding.!! it worked! [Run Completed]
import clr
clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
clr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import *
worksetnumber = IN[0]
doc = DocumentManager.Instance.CurrentDBDocument
collector = FilteredWorksetCollector(doc)
worksets = collector.OfKind(WorksetKind.UserWorkset).ToWorksets()
w = ”
for workset in worksets:
if str(workset.Id) == str(worksetnumber):
w = workset.Name
break
OUT = w
However,I could not see the target result(out put Parameter) its empty at the moment.
what should I use to copy Keynote from walls parameter to a shared parameter of the part of that wall?
I can’t find the “Parameter Name” module? For the input. How to I add that to the script
Hi Kisha, great question! That is not a module (node), I just took a “String” node and renamed it to “Parameter Name” so it’s clear what to input.