Process only the selected element


#1

Hi,
I got the following python script from another post here (https://forum.dynamobim.com/t/dividing-parts-with-dynamo/5388.
Basically it converts a select wall to parts then sub-divides the generated parts into sub-parts.
Our design process is we convert all walls to Parts, so I require the python script to work on the selected part only.
As I am relatively new to python, I have been trying to modify it with out success.

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

#Preparing input from dynamo to revit
wall = UnwrapElement(IN[0])
divisionLines = [l.ToRevitType(True) for l in IN[1]]
sketchPlane = UnwrapElement(IN[2])

#Create a list for the wall and the divisionLines
wallList = List[ElementId]()
wallList.Add(wall.Id)
intersectionElementsIds = List[ElementId]()
curveArray = List[Curve](divisionLines)

#All actions that makes changes to the Revit database needs to be inside a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

if PartUtils.AreElementsValidForCreateParts(doc, wallList):
	createParts = PartUtils.CreateParts(doc, wallList)
	doc.Regenerate()

parts = PartUtils.GetAssociatedParts(doc, wall.Id, 0, 0)
ipart = []
	
for i in parts:
	if i = 2:
	partDivide = PartUtils.DivideParts(doc, ipart[i], intersectionElementsIds, curveArray, sketchPlane.Id)

TransactionManager.Instance.TransactionTaskDone()

OUT = partDivide

Any help would be greatly appreciated.

Regards,
Eddie


#2

NEVERMIND… I’ve manage to resolve it myself