After adding shafts with the latest Rhino.Inside build, I found I couldn’t select the shaft in Revit to edit or delete it. Is this a bug, or am I missing something?
In the meantime I had to go back to the previous Create Shaft user object, and make some small updates to make it work with the latest versions. Just in case it is useful to anyone else, here is the updated python script:
import clr
clr.AddReference('System.Core')
clr.AddReference('RhinoInside.Revit')
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from System import Enum
import rhinoscriptsyntax as rs
import Rhino
import RhinoInside
import Grasshopper
import RhinoInside.Revit.Convert.Geometry.GeometryEncoder as GE
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
from RhinoInside.Revit import Revit, Convert
from Autodesk.Revit import DB
# access the active document object
doc = Revit.ActiveDBDocument
def show_warning(msg):
ghenv.Component.AddRuntimeMessage(RML.Warning, msg)
def show_error(msg):
ghenv.Component.AddRuntimeMessage(RML.Error, msg)
def show_remark(msg):
ghenv.Component.AddRuntimeMessage(RML.Remark, msg)
def to_curvearray(curve_list):
c_array = DB.CurveArray()
for i in curve_list:
c_array.Append(GE.ToCurve(i))
return c_array
PREV_SHAFT = None
if isinstance(BC, int):
BC = doc.GetElement(DB.ElementId(BC))
if isinstance(TC, int):
TC = doc.GetElement(DB.ElementId(TC))
if isinstance(BC, DB.Level) and isinstance(TC, DB.Level):
t = DB.Transaction(doc, '<give a descriptive name to your transaction>')
t.Start()
try:
if isinstance(PREV_SHAFT, DB.ElementId):
doc.Delete(PREV_SHAFT)
clist = to_curvearray(C)
new_shaft = doc.Create.NewOpening(
BC,
TC,
clist
)
bop = new_shaft.Parameter[DB.BuiltInParameter.WALL_BASE_OFFSET]
if bop and isinstance(BCO, (int, float)):
bop.Set(BCO)
top = new_shaft.Parameter[DB.BuiltInParameter.WALL_TOP_OFFSET]
if top and isinstance(TCO, (int, float)):
top.Set(TCO)
SE = new_shaft
PREV_SHAFT = new_shaft.Id
t.Commit()
except Exception as txn_err:
show_error(str(txn_err))
t.RollBack()