Bonjour,
J’ai fait un script dynamo pour remplacer plusieurs famille (avec ou sans hôte) par une seule.
Votre code python (Kulkul) me parait idéale mais je n’arrive pas à l’adapter pour une liste de plusieurs niveaux.
Pourriez-vous m’aider, merci
[Translated with google]
Hello,
I made a dynamo script to replace several families (with or without host) by one.
Your python code (Kulkul) seems ideal but I can not adapt it for a list of several levels.
Could you help me, thanks
sorry for my English
Since this post is over a year old and already has a solution I’m going to break this into a new topic. This way your question can be answered and marked as a solution for the next person to have the same problem.
1 Like
Thank you Jacob,
I found this python code on the forum (https://forum.dynamobim.com/t/familyinstance-bypoint-overwrites/10258/13),
import clr
clr.AddReference("RevitServices")
clr.AddReference("RevitNodes")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
def ptslist(obj1):
if hasattr(obj1,"__iter__"): return obj1
else: return [obj1]
famType = UnwrapElement(IN[0])
pts = ptslist(IN[1])
lvl = UnwrapElement(IN[2])
elems = []
for pt in pts:
TransactionManager.Instance.EnsureInTransaction(doc)
elems.append(doc.Create.NewFamilyInstance(pt.ToRevitType(True), famType, lvl, Structure.StructuralType.NonStructural))
TransactionManager.Instance.TransactionTaskDone()
OUT = elems
which allows to insert a family into a view…
I wish I could use it with a list of several views, but I do not know how to modify the code
Thank you, your help would be valuable to me
I’m moving across town today so I don’t think I’ll have time to get to editing and testing python (which I typically avoid, preferring nodes instead).
I am a bit confused though - are you trying to change out existing families or make new ones?
I thank you for interest in my concerns.
My script retrieves the coordinates of existing families on different levels,
then I insert another family at the location of these same coordinates
and I delete the old family.
The basic idea is to replace families with a different host and / or catagory by a new family