Hello all
I am new to Dynamo.
I have created a new script (see attached) where I am making 8 new door types inside a door family. The door types do populate correctly but the Width and Height dimensions do not change after I run the script. I am also getting this error from Dynamo.
FamilyParameter.SetValue operation failed.
Number of items does not match the number of keys
Your help will be greatly appreciated.
John
jmark
September 4, 2024, 3:30am
2
Hi Jon, i cannot recreate the problem you’re getting but if you just need to work on width and height, you can just use this python script
import clr
import sys
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')
import System
from System import Array
from System.Collections.Generic import *
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry 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
clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
# Current doc/app/ui
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = uiapp.ActiveUIDocument
width_lst = IN[0]
height_lst = IN[1]
# Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
type_names = zip(width_lst, height_lst)
new_types = []
for w, h in type_names:
new_type_name = "{}in x {}in".format(w, h)
fam_man = doc.FamilyManager
new_fam_type = fam_man.NewType(new_type_name)
ht_param = fam_man.get_Parameter(BuiltInParameter.GENERIC_HEIGHT)
wt_param = fam_man.get_Parameter(BuiltInParameter.GENERIC_WIDTH)
fam_man.Set(ht_param, float(h / 12))
fam_man.Set(wt_param, float(w / 12))
new_types.append(new_type_name)
TransactionManager.Instance.TransactionTaskDone()
OUT = new_types
sovitek
September 4, 2024, 5:10am
3
Hi @john.deleonQDFBH you could try some of these OOTB nodes for family document…and probably a transaction after you have created new types
I figured it out.
I did not set lacing to LONGEST at the FamilyParameter.SetValue node. It was set to AUTO.
I thought I knew how to lace my tennis shoes, I guess not lol.
What is Lacing?
1 Like
sovitek
September 4, 2024, 7:18pm
6
Hi @john.deleonQDFBH take a look here