So I have been fighting the dynamo upgrade issue hard and got all 40 tools fixed but these 2 damn they are messing with me.
the first one the python script will not close I tries chatGPD and its fix made things worse.
the tool basically creates our typical worksets and then puts all boneyard template items that are in a bounding box.and after that it turns off the newly created worksets. I can bypass the python script and manually turn off the worksets but damn I want to finish it.
The secon one is that it links in a revit file and creates the levels from that link. I can get it to link the file but not copy the links (I think its the BimorphNodes.
Ive attached the dynamo files and thanks for any help you can give me. After fixing so many files these two lol
Hi @jarod.tulanowski for copy levels from link in 2026 you could try somehing here, hope it is what you mean, but as you see we get this "popup for duplicate types, as we do when try try manuel as well…i couldnt get the CustomDuplicateHandler for suppres that to work for cpython 3 or pythonnet 3 as we could in ironpython 2-3…not sure why…guees we need @c.poupin here for bring light testtttt.dyn (4.3 KB)
import clr
import sys
import System
from System.Collections.Generic import List
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
uidoc = uiapp.ActiveUIDocument
app = uiapp.Application
sdkNumber = int(app.VersionNumber)
lst_wkset_name = IN[0]
bool=IN[1]
outWorkSet = []
if doc.IsWorkshared:
collCurrentWkSet = FilteredWorksetCollector(doc).OfKind(WorksetKind.UserWorkset).ToWorksets()
lstCurrentWkst = sorted([x.Name for x in collCurrentWkSet])
#
defaultVisibility = WorksetDefaultVisibilitySettings.GetWorksetDefaultVisibilitySettings(doc)
#
for wksetName in lst_wkset_name:
if wksetName not in lstCurrentWkst:
#TransactionManager.Instance.ForceCloseTransaction()
TransactionManager.Instance.EnsureInTransaction(doc)
xworkset = Workset.Create(doc, wksetName)
doc.Regenerate()
defaultVisibility.SetWorksetVisibility(xworkset.Id,bool)
defaultVisibility.IsWorksetVisible(xworkset.Id)
#
outWorkSet.append(xworkset.Name)
TransactionManager.Instance.TransactionTaskDone()
else:
outWorkSet.append(wksetName)
OUT = outWorkSet
for the second, here is an example of use IDuplicateTypeNamesHandler (only PythonNet3)
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import List
doc = DocumentManager.Instance.CurrentDBDocument
class CustomCopyHandler(IDuplicateTypeNamesHandler):
__namespace__ = "CustomCopyHandler_g9MytmEA" # name space with a short uuid
#
def __init__(self):
super().__init__()
def OnDuplicateTypeNamesFound(self, args):
return DuplicateTypeAction.UseDestinationTypes
def to_list(x):
if isinstance(x, (list, tuple)): return x
return [x]
link_inst = UnwrapElement(IN[0])
elements = [UnwrapElement(e) for e in to_list(IN[1]) if e is not None]
out_list = []
if link_inst and elements:
link_doc = link_inst.GetLinkDocument()
tf = link_inst.GetTotalTransform()
ids_to_copy = List[ElementId]()
for e in elements:
if hasattr(e, "Id"):
ids_to_copy.Add(e.Id)
options = CopyPasteOptions()
options.SetDuplicateTypeNamesHandler(CustomCopyHandler())
TransactionManager.Instance.EnsureInTransaction(doc)
new_ids = ElementTransformUtils.CopyElements(
link_doc,
ids_to_copy,
doc,
tf,
options
)
TransactionManager.Instance.TransactionTaskDone()
for nid in new_ids:
out_list.append(doc.GetElement(nid))
OUT = out_list