I still learn API stuff. I found a fine script which duplicates types, but there are a lot of Duplicate-Methods(views, material,…). I use it for dublicate type for Generic_Models
Which one is here used? (Revit 2018.3.3):
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
result = []
insymbol = UnwrapElement(IN[0])
symbolnames =IN[1]
for s in symbolnames:
TransactionManager.Instance.EnsureInTransaction(doc)
newsymbol = insymbol.Duplicate(s)
result.Add(newsymbol.ToDSType(True))
TransactionManager.Instance.TransactionTaskDone()
OUT = result
I’m not sure why this has the transaction in the for loop… feels like it’s asking for things to go slower, but it may be a requirement for making new symbols I guess… anyway…
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
TransactionManager.Instance.EnsureInTransaction(doc)
result = []
insymbol = UnwrapElement(IN[0])
symbolnames =IN[1]
for s in symbolnames:
newsymbol = insymbol.Duplicate(s)
result.Add(newsymbol.ToDSType(True))
TransactionManager.Instance.TransactionTaskDone()
OUT = result
Perhaps try using some list comprehension to simplify further?
Haven’t tested myself but this should be a good start point.
doc = DocumentManager.Instance.CurrentDBDocument
insymbol = UnwrapElement(IN[0])
symbolnames =IN[1]
TransactionManager.Instance.EnsureInTransaction(doc)
result = [ insymbol.Duplicate(s) for s in symbolnames ]
TransactionManager.Instance.TransactionTaskDone()
OUT = [ r.ToDSType(True) for r in result ]
Comment our each line and describe in plain English (or your native language) what it does. This will ensure you know what each line is doing, ensuring you have the knowledge to continue to grow and will help troubleshooting later.
Do not get in the habit of using python nodes unbound in your graph like the above for repeated, long term use. Each of that code set will need to be addressed on a 1x1 basis in every copy of every graph you have when the inevitable Python 3 conversion comes. Wrap it in a custom node and use a package you deploy to ensure the whole office gets the updates as needed.
Do not forget to simplify your environmental set up as well. Things like ‘import *’ and ‘UIDoc’ when not needed is just sloppy. Simplified imports is a best practice - otherwise you are borrowing the entire bookcase when you really just need ‘FamilySymbol’.