@MelleH
This one works for me:
import clr #.NET Laden
import sys #sys is de fundamentele Python bibliotheek
#de standaard IronPython-bibliotheken
#sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib') #Imports the
#standaard IronPython-bibliotheken, die alles dekken, van servers en
#encryptie tot reguliere expressies.
import System #The System namespace in de hoofdmap .NET
from System import Array #.NET class voor het verwerken van array-informatie
import System.Collections.Generic as MGen #Module kan nu benaderd worden met MGen.xxxx
#from System.Collections.Generic import * #Hiermee kunt u generieke afhandelen. Revit's API
#soms wil hard-getypte 'generieke' lijsten, genaamd ILists. Als je niet nodig hebt
#deze kunt u deze regel verwijderen.
clr.AddReference('ProtoGeometry') #Een Dynamo-bibliotheek voor zijn proxygeometrie
#classes. Je hebt dit alleen nodig als je interactie hebt met geometrie.
import Autodesk.DesignScript.Geometry as AGeo #Module kan worden opgeroepen a=met AGeo.xxxx
#from Autodesk.DesignScript.Geometry import * #Laadt alles in Dynamo's
#geometriebibliotheek
clr.AddReference("RevitNodes") #Dynamo's nodes voor Revit
import Revit #Laad in de Revit-namespaces in RevitNodes
clr.ImportExtensions(Revit.Elements) #Meer laden van Dynamo's Revit-bibliotheken
clr.ImportExtensions(Revit.GeometryConversion) #Meer laden van Dynamo's
#Revit-bibliotheken. Je hebt dit alleen nodig als je interactie hebt met geometrie.
clr.AddReference("RevitServices") #Dynamo's classes voor het omgaan met Revit-documenten
import RevitServices
from RevitServices.Persistence import DocumentManager #Een interne Dynamo class
#dat het document bijhoudt waaraan Dynamo momenteel is gekoppeld
from RevitServices.Transactions import TransactionManager #Een Dynamo class voor
#transacties openen en sluiten om de database van het Revit-document te wijzigen
clr.AddReference("RevitAPI") #Verwijzing naar Revit's API DLL's toevoegen
clr.AddReference("RevitAPIUI") #Verwijzing naar Revit's APIUI DLL's toevoegen
import Autodesk #Loads the Autodesk namespace
import Autodesk.Revit.DB as RDB #Loading Revit's API UI classes module kan nu worden aangeroepen met RDB.xxxx
#from Autodesk.Revit.DB import * #Loading Revit's API UI classes
import Autodesk.Revit.UI as RUI # Loading Revit's API UI classes als RUI.xxxx
#from Autodesk.Revit.UI import * #Loading Revit's API UI classes
doc = DocumentManager.Instance.CurrentDBDocument #Dit is het actieve Revit document
uiapp = DocumentManager.Instance.CurrentUIApplication #Een handle instellen voor het actieve Revit UI-document
app = uiapp.Application #Een handle instellen op de momenteel geopende instantie van de Revit-toepassing
uidoc = uiapp.ActiveUIDocument #Een handle instellen op de momenteel geopende instantie van de Revit UI-toepassing
revit_version = int(doc.Application.VersionNumber)
# code omrekenen revit feet naar huidig ingestele document units
if revit_version >= 2022:
ForgeLength = "autodesk.spec.aec:length-1.0.0" # zie voor lijst ForgeTypeIds.xlsx in de map handleidingen
ForgeTypeLength = RDB.ForgeTypeId(ForgeLength)
getDocUnits = doc.GetUnits()
getDisplayUnitsLength = getDocUnits.GetFormatOptions(ForgeTypeLength).GetUnitTypeId()
else:
getDocUnits = doc.GetUnits()
getDisplayUnits = getDocUnits.GetFormatOptions(RDB.UnitType.UT_Length).DisplayUnits
def ToRevitUnitsLength(InVal):
if revit_version >= 2022:
return RDB.UnitUtils.ConvertToInternalUnits(InVal, getDisplayUnitsLength)
else:
return RDB.UnitUtils.ConvertToInternalUnits(InVal, getDisplayUnits)
def ToDynamoUnitsLength(InVal):
if revit_version >= 2022:
return RDB.UnitUtils.ConvertFromInternalUnits(InVal, getDisplayUnitsLength)
else:
return RDB.UnitUtils.ConvertFromInternalUnits(InVal, getDisplayUnits)
def ToRevitUnitsLengthFromMM(InVal):
if revit_version >= 2022:
return RDB.UnitUtils.Convert(InVal, RDB.UnitTypeId.Millimeters, RDB.UnitTypeId.Feet)
else:
return RDB.UnitUtils.Convert(InVal, RDB.DisplayUnitType.DUT_MILLIMETERS, RDB.DisplayUnitType.DUT_DECIMAL_FEET)
def ToRevitUnitsLengthFromMM(InVal):
if revit_version >= 2022:
return RDB.UnitUtils.Convert(InVal, RDB.UnitTypeId.Millimeters, RDB.UnitTypeId.Feet)
else:
return RDB.UnitUtils.Convert(InVal, RDB.DisplayUnitType.DUT_MILLIMETERS, RDB.DisplayUnitType.DUT_DECIMAL_FEET)
def GroupByKey(Items,Keys):
UKeys=[]
for Key in Keys:
if Key not in UKeys:
UKeys.append(Key)
GrpList=[]
for empt in range(len(UKeys)):
GrpList.append([])
Inds=[]
for Key in Keys:
Inds.append(UKeys.index(Key))
for Item, Ind in zip(Items, Inds):
GrpList[Ind].append(Item)
return [GrpList,UKeys]
def GetName(ele):
elename = None
try:
elename = ele.Name
except:
elename = RDB.Element.Name.__get__(ele)
return elename
# einde code omrekenen revit feet naar huidig ingestelde document units
# Hieronder kan je dan gaan programmeren
# Gebruik boiler template
#Start Transaction
#TransactionManager.Instance.EnsureInTransaction(doc)
#Eind Transactie
#TransactionManager.Instance.TransactionTaskDone()
adetailgroup = UnwrapElement(IN[0])
views = UnwrapElement(IN[1])
groups = UnwrapElement(IN[2])
ids = []
for a in adetailgroup:
ids.append(a.Id)
#Start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
s=0
for g in groups:
RDB.Group.ShowAttachedDetailGroups(g, views ,ids[s])
s += 1
#Eind Transactie
TransactionManager.Instance.TransactionTaskDone()
OUT = views
Attached detail group.dyn (23.8 KB)
Make sure that the view isn’t a viewtemplate