Getting MEPModel from Selected Element?

running a SelectElements Node to a Python script… no problems getting the Element… but I need to access it’s MEPModel to get to the ConnectorManager

>> http://thebuildingcoder.typepad.com/blog/2010/06/retrieve-mep-elements-and-connectors.html

is this possible in python? I can easily do this in C# but i’d rather not build an addin for this.

Addition I guess there is no casting python

 

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *
clr.AddReference(‘RevitNodes’)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

parentList = None
elementlist= [None] #None = null
pfixtures = [None]
pipes = [None]
pipeFittings = [None]
elementsSelected = False

e = None
famInstance = None
mep = None

if IN is None:
OUT = IN
else:
if IN[0] is not None:
elementsSelected = True

if elementsSelected:
parentList = IN[0]
e = UnwrapElement(parentList[0])

if isinstance(e, Element):
famInstance = (FamilyInstance)e
mep = famInstance.MEPModel
else:
OUT = “false”
"""
#1st in list will already be taken
for i in range(0,len(parentList)):
for p in parentList[i].Parameters:
if p.Name == “Category”:
if str§ == “Category : Pipe Fittings”:
pipeFittings.append(parentList[i])
if str§ == “Category : Plumbing Fixtures”:
pfixtures.append(parentList[i])
if str§ == “Category : Pipes”:
pipes.append(parentList[i])
#remove 1st in list
pipes.pop(0)
pfixtures.pop(0)
pipeFittings.pop(0)
#Assign your output to the OUT variable.
OUT = (“Fixtures”, pfixtures, “Fittings”, pipeFittings, “Pipes”, pipes)
“”"
else:
OUT= “Nothing Selected”

Hi Nathan,

Read this topic http://dynamobim.org/forums/topic/the-mep-side-needs-a-lot-of-attention/

Hope it helps!

Hey that worked out great! thanks for the link!