Hi all,
How can I receive the pipes that are in my document?
import Autodesk #Loads the Autodesk namespace
import Autodesk.Revit.DB as RDB #Loading Revit's API UI classes module kan nu worden aangeroepen met RDB.xxxx
#from Autodesk.Revit.DB import * #Loading Revit's API UI classes
import Autodesk.Revit.UI as RUI # Loading Revit's API UI classes als RUI.xxxx
#from Autodesk.Revit.UI import * #Loading Revit's API UI classes
doc = DocumentManager.Instance.CurrentDBDocument #Dit is het actieve Revit document
uiapp = DocumentManager.Instance.CurrentUIApplication #Een handle instellen voor het actieve Revit UI-document
app = uiapp.Application #Een handle instellen op de momenteel geopende instantie van de Revit-toepassing
uidoc = uiapp.ActiveUIDocument #Een handle instellen op de momenteel geopende instantie van de Revit UI-toepassing
revit_version = int(doc.Application.VersionNumber)
# code omrekenen revit feet naar huidig ingestele document units
if revit_version >= 2022:
ForgeLength = "autodesk.spec.aec:length-1.0.0" # zie voor lijst ForgeTypeIds.xlsx in de map handleidingen
ForgeTypeLength = RDB.ForgeTypeId(ForgeLength)
getDocUnits = doc.GetUnits()
getDisplayUnitsLength = getDocUnits.GetFormatOptions(ForgeTypeLength).GetUnitTypeId()
else:
getDocUnits = doc.GetUnits()
getDisplayUnits = getDocUnits.GetFormatOptions(RDB.UnitType.UT_Length).DisplayUnits
def ToRevitUnitsLength(InVal):
if revit_version >= 2022:
return RDB.UnitUtils.ConvertToInternalUnits(InVal, getDisplayUnitsLength)
else:
return RDB.UnitUtils.ConvertToInternalUnits(InVal, getDisplayUnits)
def ToDynamoUnitsLength(InVal):
if revit_version >= 2022:
return RDB.UnitUtils.ConvertFromInternalUnits(InVal, getDisplayUnitsLength)
else:
return RDB.UnitUtils.ConvertFromInternalUnits(InVal, getDisplayUnits)
def ToRevitUnitsLengthFromMM(InVal):
if revit_version >= 2022:
return RDB.UnitUtils.Convert(InVal, RDB.UnitTypeId.Millimeters, RDB.UnitTypeId.Feet)
else:
return RDB.UnitUtils.Convert(InVal, RDB.DisplayUnitType.DUT_MILLIMETERS, RDB.DisplayUnitType.DUT_DECIMAL_FEET)
def ToRevitUnitsLengthFromMM(InVal):
if revit_version >= 2022:
return RDB.UnitUtils.Convert(InVal, RDB.UnitTypeId.Millimeters, RDB.UnitTypeId.Feet)
else:
return RDB.UnitUtils.Convert(InVal, RDB.DisplayUnitType.DUT_MILLIMETERS, RDB.DisplayUnitType.DUT_DECIMAL_FEET)
def get_parameter_value_by_name(element, parameterName):
return element.LookupParameter(parameterName).AsString()
#einde code omrekenen revit feet naar huidig ingestele document units
#alle elementen van OST category ophalen
alleElementen = RDB.FilteredElementCollector(doc)
alleElementen.OfCategory(RDB.BuiltInCategory.OST_PipeSegments)
alleElementen.WhereElementIsNotElementType()
#ID ophalen voor parameter
ID = alleElementen.ToElementIds()
ParameterNaam="bouwnummer"
param = list()
for MyE in alleElementen:
try:
param.append(get_parameter_value_by_name(MyE, ParameterNaam))
except:
param.append(None)
OUT= alleElementen.ToElements()
I can get the Pipe Segment but it give me alot of elements, I only want the pipes I drew.
The WhereElementIsNotElementType() doesnt work with PipeSegments