Create Parts of selection or result objects

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)

1 Like

Hi @wunnenstein

Your getting empty values for wall finishes by room node. Make sure you have the wall types in your model. Watch this video https://youtu.be/RKE3Ph98Vns

Hey Kulkul. The main part of the script works correctly. I had to translate Modelicals node for using the German words (see the other thread I replied to recently). Maybe that’s why it didn’t work for you.

I just need help with the last part, having the parts elements the script has created as an output list to set parameter values to them afterwards.

Thanks.