Message 1 of 8
Error when trying to divide part based on reference plane
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am trying to divide elements into parts programmatically. I have a bit of experience in native Dynamo, but no experience using the Revit API.
The following screenshot is a prototype of what I am trying to do. I would like to divide the part into two divisions based on the reference plane.
Here is the code I have so far:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI 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
# Collecting element IDs of parts
partElementId = UnwrapElement(IN[0]).Id
partElementId_int = int(partElementId.ToString())
partElementIdList = List[ElementId](partElementId_int)
# Collecting element IDs of ref planes
refPlaneElementId = UnwrapElement(IN[1]).Id
refPlaneElementId_int = int(refPlaneElementId.ToString())
refPlaneElementIdList = List[ElementId](refPlaneElementId_int)
curveArray = []
# Creating XY plane
xyPlane = Plane.CreateByNormalAndOrigin(XYZ(0,0,1), XYZ(0,0,0))
# Creating transaction
TransactionManager.Instance.EnsureInTransaction(doc)
# Dividing part
xyDivisionPlane = SketchPlane.Create(doc, xyPlane)
PartUtils.DivideParts(doc, partElementIdList, refPlaneElementIdList, curveArray, xyDivisionPlane.Id)
# Closing transaction
TransactionManager.Instance.TransactionTaskDone()
OUT = []
(I used the "Select Model Element" node to collect the part and reference plane for simplication purposes)
When I execute the script, I get the error:
"Exception: One or more element ids was not permitted for dividing parts. Elements should be parts that are not yet divided and maximum distance from an original has not yet been reached."
Can someone explain to me what this error means?
Thanks!