-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andreas Dieckmann
committed
Jan 14, 2020
1 parent
31c6b0f
commit 609e7ff
Showing
51 changed files
with
597 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import System | ||
import clr | ||
clr.AddReference('RevitAPI') | ||
from Autodesk.Revit.DB import * | ||
|
||
clr.AddReference("RevitServices") | ||
import RevitServices | ||
from RevitServices.Persistence import DocumentManager | ||
|
||
def ElementsByCategory(bic, doc): | ||
collector = FilteredElementCollector(doc).OfCategory(bic).WhereElementIsNotElementType() | ||
return collector.ToElements() | ||
|
||
inputdoc = UnwrapElement(IN[2]) | ||
if not inputdoc: doc = DocumentManager.Instance.CurrentDBDocument | ||
elif inputdoc.GetType().ToString() == "Autodesk.Revit.DB.RevitLinkInstance": doc = inputdoc.GetLinkDocument() | ||
elif inputdoc.GetType().ToString() == "Autodesk.Revit.DB.Document": doc = inputdoc | ||
else: doc = DocumentManager.Instance.CurrentDBDocument | ||
|
||
if isinstance(IN[0], list): OUT = [ElementsByCategory(x, doc) for x in IN[0]] | ||
else: OUT = ElementsByCategory(IN[0], doc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import System | ||
import clr | ||
clr.AddReference('RevitAPI') | ||
from Autodesk.Revit.DB import * | ||
|
||
clr.AddReference("RevitNodes") | ||
import Revit | ||
clr.ImportExtensions(Revit.Elements) | ||
|
||
clr.AddReference("RevitServices") | ||
import RevitServices | ||
from RevitServices.Persistence import DocumentManager | ||
|
||
def GetBicFromInput(var): | ||
bic = None | ||
if var: | ||
cattype = var.GetType().ToString() | ||
if cattype == "Revit.Elements.Category": bic = System.Enum.ToObject(BuiltInCategory, var.Id) | ||
elif cattype == "Autodesk.Revit.DB.BuiltInCategory": bic = var | ||
elif cattype == "System.String": | ||
found = [x for x in bics if x.ToString() == var] | ||
if len(found) > 0: bic = found[0] | ||
return bic | ||
|
||
doc = DocumentManager.Instance.CurrentDBDocument | ||
bics = System.Enum.GetValues(BuiltInCategory) | ||
|
||
if isinstance(IN[0], list): OUT = [GetBicFromInput(x) for x in IN[0]] | ||
else: OUT = GetBicFromInput(IN[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import System | ||
import clr | ||
clr.AddReference('RevitAPI') | ||
from Autodesk.Revit.DB import * | ||
|
||
clr.AddReference("RevitNodes") | ||
import Revit | ||
clr.ImportExtensions(Revit.Elements) | ||
|
||
clr.AddReference("RevitServices") | ||
import RevitServices | ||
from RevitServices.Persistence import DocumentManager | ||
|
||
def GetCatFromInput(var): | ||
cat = None | ||
if var: | ||
cattype = var.GetType().ToString() | ||
if cattype == "Autodesk.Revit.DB.Category": cat = var | ||
elif cattype == "Autodesk.Revit.DB.BuiltInCategory": cat = Category.GetCategory(doc, var) | ||
elif cattype == "System.String": | ||
found = [x for x in bics if x.ToString() == var] | ||
if len(found) > 0: cat = Category.GetCategory(doc, found[0]) | ||
return cat | ||
|
||
doc = DocumentManager.Instance.CurrentDBDocument | ||
bics = System.Enum.GetValues(BuiltInCategory) | ||
cats = UnwrapElement(IN[0]) | ||
|
||
if isinstance(IN[0], list): OUT = [GetCatFromInput(x) for x in cats] | ||
else: OUT = GetCatFromInput(cats) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import clr | ||
clr.AddReference('System.Drawing') | ||
import System.Drawing | ||
|
||
def ColorByName(str): | ||
syscol = System.Drawing.Color.FromName(str) | ||
return syscol.R,syscol.G,syscol.B | ||
|
||
|
||
if isinstance(IN[0], list): OUT = map(list, zip(*[ColorByName(x) for x in IN[0]])) | ||
else: OUT = ColorByName(IN[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import clr | ||
clr.AddReference('System.Drawing') | ||
import System.Drawing | ||
|
||
def GetColorName(color): | ||
if hasattr(color, "Red"): | ||
if color.Red == 0 and color.Green == 0 and color.Blue == 0: return "Black" | ||
else: | ||
lookup = [x for x in knowncols if x.R == color.Red and x.G == color.Green and x.B == color.Blue] | ||
if len(lookup) > 0: return lookup[0].Name | ||
else: return None | ||
else: return None | ||
|
||
knowncols = [System.Drawing.Color.FromKnownColor(x) for x in System.Enum.GetValues(System.Drawing.KnownColor)] | ||
if isinstance(IN[0], list): OUT = [GetColorName(x) for x in IN[0]] | ||
else: OUT = GetColorName(IN[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import clr | ||
import System | ||
clr.AddReference('RevitAPI') | ||
clr.AddReference('RevitAPIUI') | ||
import Autodesk | ||
|
||
rAssembly = [x for x in System.AppDomain.CurrentDomain.GetAssemblies() if x.GetName().Name == 'RevitAPI'][0] | ||
OUT = [x.Name for x in rAssembly.GetTypes() if x.Namespace is not None and x.Namespace.startswith("Autodesk.Revit.") and x.BaseType == System.Enum] | ||
OUT = sorted(OUT, key=str.lower) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.