Skip to content

Commit

Permalink
#416 updated python
Browse files Browse the repository at this point in the history
  • Loading branch information
andydandy74 committed Oct 22, 2024
1 parent dc18b79 commit 98d8b6b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 37 deletions.
15 changes: 4 additions & 11 deletions nodes/3.x/python/Document.ProjectParameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
elif inputdoc.GetType().ToString() == "Autodesk.Revit.DB.Document":
doc = inputdoc
else: doc = None
version = IN[2]

names = []
cats = []
Expand All @@ -37,14 +36,8 @@
while iterator.MoveNext():
vag.append(iterator.Key.VariesAcrossGroups)
names.append(iterator.Key.Name)
if version > 2021:
pts.append(iterator.Key.GetDataType())
uts.append(iterator.Key.GetDataType())
pgs.append(iterator.Key.GetGroupTypeId())
else:
pts.append(iterator.Key.ParameterType)
uts.append(iterator.Key.UnitType)
pgs.append(iterator.Key.ParameterGroup)
pts.append(iterator.Key.GetDataType())
pgs.append(iterator.Key.GetGroupTypeId())
isvis.append(iterator.Key.Visible)
elem = doc.GetElement(iterator.Key.Id)
elems.append(elem)
Expand All @@ -64,7 +57,7 @@
# Return null if category is not supported by Dynamo
# This way the user knows there are unsupported categories assigned
thesecats.append(None)
builtincats.append(System.Enum.ToObject(BuiltInCategory, cat.Id.IntegerValue))
builtincats.append(System.Enum.GetName(BuiltInCategory, cat.Id.IntegerValue))
cats.append(thesecats)
bics.append(builtincats)
OUT = (names,cats,vag, pgs, pts, uts, isvis, elems, guids, isinst, bics)
OUT = (names,cats,vag, pgs, pts, isvis, elems, guids, isinst, bics)
15 changes: 4 additions & 11 deletions nodes/3.x/python/Document.ProjectParametersByCategory.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
elif inputdoc.GetType().ToString() == "Autodesk.Revit.DB.Document":
doc = inputdoc
else: doc = None
version = IN[3]

iterator = doc.ParameterBindings.ForwardIterator()
while iterator.MoveNext():
Expand All @@ -50,14 +49,8 @@
if cat.Id.IntegerValue == search_id:
names[i].append(iterator.Key.Name)
vag[i].append(iterator.Key.VariesAcrossGroups)
if version > 2021:
pts[i].append(iterator.Key.GetDataType())
uts[i].append(iterator.Key.GetDataType())
pgs[i].append(iterator.Key.GetGroupTypeId())
else:
pts[i].append(iterator.Key.ParameterType)
uts[i].append(iterator.Key.UnitType)
pgs[i].append(iterator.Key.ParameterGroup)
pts[i].append(iterator.Key.GetDataType())
pgs[i].append(iterator.Key.GetGroupTypeId())
isvis[i].append(iterator.Key.Visible)
elem = doc.GetElement(iterator.Key.Id)
elems[i].append(elem)
Expand All @@ -68,5 +61,5 @@
isinst[i].append(True)
else: isinst[i].append(False)
i += 1
if isinstance(IN[0], list): OUT = (names, vag, pgs, pts, uts, isvis, elems, guids, isinst)
else: OUT = (names[0], vag[0], pgs[0], pts[0], uts[0], isvis[0], elems[0], guids[0], isinst[0])
if isinstance(IN[0], list): OUT = (names, vag, pgs, pts, isvis, elems, guids, isinst)
else: OUT = (names[0], vag[0], pgs[0], pts[0], isvis[0], elems[0], guids[0], isinst[0])
3 changes: 2 additions & 1 deletion nodes/3.x/python/Family.PlacementType.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import System

def GetPlacementType(item):
if hasattr(item, "FamilyPlacementType"): return item.FamilyPlacementType
if hasattr(item, "FamilyPlacementType"): return System.Enum.GetName(FamilyPlacementType, item.FamilyPlacementType)
else: return None

items = UnwrapElement(IN[0])
Expand Down
31 changes: 17 additions & 14 deletions nodes/3.x/python/Level.Views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@
import Revit
clr.ImportExtensions(Revit.Elements)

import System
from System.Collections.Generic import *

def GetFirstAndAllViews(lvl):
firstView = None
try:
if lvl.Document.GetElement(lvl.FindAssociatedPlanViewId()): firstView = lvl.Document.GetElement(lvl.FindAssociatedPlanViewId())
except: pass
if viewlevels.Contains(lvl.Id): allViews = views[viewlevels.IndexOf(lvl.Id)]
else: allViews = []
return firstView, allViews

levels = UnwrapElement(IN[0])
version = IN[1]
elementlist = list()
for lvl in levels:
if version > 2017:
try:
if lvl.Document.GetElement(lvl.FindAssociatedPlanViewId()) == None:
elementlist.append(None)
else:
elementlist.append(lvl.Document.GetElement(lvl.FindAssociatedPlanViewId()))
except:
elementlist.append(None)
else:
elementlist.append(None)
OUT = elementlist
views = UnwrapElement(IN[1])
viewlevels = List[ElementId]([x.Id for x in UnwrapElement(IN[2])])

if isinstance(IN[0], list): OUT = list(zip(*[GetFirstAndAllViews(x) for x in levels]))
else: OUT = GetFirstAndAllViews(levels)

0 comments on commit 98d8b6b

Please sign in to comment.