I am still juggling through PartUtils and cannot make it work. Here is what happens.
- I have elements in Revit (floors) as well as model lines (area boundary lines)
- I have managed to select all elements and also select all area boundary lines and extract those as curves or just get their element IDs.
- I used a pyhton Script to access PartUtils and use the DivideParts method where the boundary lines were supposed to be the dividision sketch.
The error I have stumbled upon now is unable to cast object of type Geometry or Model line to Autodesk DB Curve
the script is here (original by Konrad S)
#Copyright(c) 2015, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Analysis import *
clr.AddReference('System')
from System.Collections.Generic import List
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import ToProtoType, ToRevitType geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
#The inputs to this node will be stored as a list in the IN variable.
ElementsToBeParted = UnwrapElement(IN[0])
divisionLines = UnwrapElement(IN[1])
sketchPlane = UnwrapElement(IN[2])
#Define the division function to process
elementList = List[ElementId]()
#elementList.Add(ElementsToBeParted.Id)
intersectionElementsIds = List[ElementId]()
#intersectionElementsIds.Add(divisionLines.Id)
curveArray = List[Curve](divisionLines)
TransactionManager.Instance.EnsureInTransaction(doc)
if PartUtils.AreElementsValidForCreateParts(doc, elementList):
createParts = PartUtils.CreateParts(doc, elementList)
doc.Regenerate()
parts = PartUtils.GetAssociatedParts(doc, ElementsToBeParted.Id, 0, 0)
dividedParts = PartUtils.DivideParts(doc, parts, intersectionElementsIds, curveArray, sketchPlane.Id)
TransactionManager.Instance.TransactionTaskDone()
OUT = dividedParts