- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all,
I am working with python shell in dynamo trying to add a connector element to a family's planar face. Please see the code below:
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import math
import System
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
#import Autodesk.Revit.UI.Selection
from Autodesk.Revit.DB.Electrical import ElectricalSystemType
from Autodesk.Revit.DB.Structure import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion);
doc = DocumentManager.Instance.CurrentDBDocument;
familyElement = UnwrapElement(IN[0]);
TransactionManager.Instance.TransactionTaskDone();
familyDoc = doc.EditFamily(familyElement.Family);
Id = familyElement.Id;
ref = Reference(familyElement);
TransactionManager.Instance.EnsureInTransaction(doc);
geometryOptions = Options();
geometryOptions.ComputeReferences = True;
geometryOptions.IncludeNonVisibleObjects = False;
# Get the geometry of the family element
geometryElement = familyElement.Geometry[geometryOptions];
planarFace=None;
faces = [];
for geometryObject in geometryElement:
if isinstance(geometryObject, Solid):
solid = geometryObject
for face in solid.Faces:
faces.append(face)
if isinstance(face, PlanarFace):
planarFace = face;
break;
TransactionManager.Instance.TransactionTaskDone();
TransactionManager.Instance.EnsureInTransaction(doc);
# Create the electrical connector
connector = ConnectorElement.CreateElectricalConnector(familyDoc, ElectricalSystemType.PowerBalanced, planarFace.Reference);
# Commit the transaction
TransactionManager.Instance.TransactionTaskDone();
OUT = faces;
I get the error, The reference is not a planar face. Parameter name: planarFace.
If I do OUT = planarFace, then it is indeed an Autodesk.Revit.DB.PlanarFace element. So I am not sure what I am doing wrong. By the way, IN[0] is a family symbol in my project.
Any help would be greatly appreciated. Thank you!
Solved! Go to Solution.