Hey guys,
After creating walls by room boundaries using Modelicals “Wall finishes by room” node i convert these walls to parts and now want to further use these created elements.
sadly i’m not the best at using python and need help doing this. Output should be a list of the created parts for further use.
cheers and thanks.
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
#feed IN[0] with elements
elts = []
Ids = []
prt = []
for i in IN[0]:
elts.append(UnwrapElement(i))
for e in elts:
Ids.append(e.Id)
IDS = List[ElementId](Ids)
# Start Transaction tt
TransactionManager.Instance.EnsureInTransaction(doc)
if PartUtils.AreElementsValidForCreateParts(doc, IDS):
parts = PartUtils.CreateParts(doc, IDS)
#my nonsense trying to get These just created parts. or is there another way?
pid = PartUtils.GetAssociatedParts(doc, parts.GUID, false, false );
# End Transaction - by original script.
TransactionManager.Instance.TransactionTaskDone()
TransactionManager.Instance.ForceCloseTransaction()
#This was originally IDS but just gave me a string list of the parents IDs.
OUT = pid
#wallfinish.dyn (11.1 KB)