Skip to content

Commit 063da34

Browse files
committed
Fix Revit Lookup Snoop
1 parent fd7508d commit 063da34

File tree

1 file changed

+48
-19
lines changed
  • RevitPythonShell/DefaultConfig

1 file changed

+48
-19
lines changed

RevitPythonShell/DefaultConfig/init.py

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(self, uiApplication):
5151
try:
5252
rlapp = [app for app in uiApplication.LoadedApplications
5353
if app.GetType().Namespace == 'RevitLookup'
54-
and app.GetType().Name == 'App'][0]
54+
and app.GetType().Name == 'Application'][0]
5555
except IndexError:
5656
self.RevitLookup = None
5757
return
@@ -60,32 +60,61 @@ def __init__(self, uiApplication):
6060
import RevitLookup
6161
self.RevitLookup = RevitLookup
6262
# See note in CollectorExt.cs in the RevitLookup source:
63-
self.RevitLookup.Snoop.CollectorExts.CollectorExt.m_app = uiApplication
64-
self.revit = uiApplication
65-
66-
def lookup(self, element):
63+
#self.RevitLookup.Snoop.CollectorExts.CollectorExt.m_app = uiApplication
64+
#self.revit = uiApplication
65+
def IsInstalled(self):
6766
if not self.RevitLookup:
6867
print('RevitLookup not installed. Visit https://github.com/jeremytammik/RevitLookup to install.')
69-
return
70-
if isinstance(element, int):
71-
element = self.revit.ActiveUIDocument.Document.GetElement(ElementId(element))
72-
if isinstance(element, ElementId):
73-
element = self.revit.ActiveUIDocument.Document.GetElement(element)
74-
if isinstance(element, list):
75-
elementSet = ElementSet()
76-
for e in element:
77-
elementSet.Insert(e)
78-
element = elementSet
79-
form = self.RevitLookup.Snoop.Forms.Objects(element)
80-
form.ShowDialog()
68+
return False
69+
return True
70+
71+
def SnoopCurrentSelection(self):
72+
if self.IsInstalled()== True:
73+
form = self.RevitLookup.Views.ObjectsView()
74+
form.SnoopAndShow(self.RevitLookup.Core.Selector.SnoopCurrentSelection)
75+
def SnoopElement(self,element):
76+
if self.IsInstalled()== True:
77+
if element is None:
78+
print("element null object, Please input element to snoop")
79+
return
80+
if isinstance(element, int):
81+
element = doc.GetElement(ElementId(element))
82+
if isinstance(element, ElementId):
83+
element = doc.GetElement(element)
84+
if isinstance(element, list):
85+
elementSet = ElementSet()
86+
for e in element:
87+
elementSet.Insert(e)
88+
element = elementSet
89+
form = self.RevitLookup.Views.ObjectsView(element)
90+
self.RevitLookup.Core.ModelessWindowFactory.Show(form)
91+
def SnoopActiveView():
92+
if self.IsInstalled()== True:
93+
self.SnoopElement(doc.ActiveView)
94+
def SnoopDB(self):
95+
if self.IsInstalled()== True:
96+
form = self.RevitLookup.Views.ObjectsView()
97+
form.SnoopAndShow(self.RevitLookup.Core.Selector.SnoopDb)
8198

8299

83100
_revitlookup = RevitLookup(__revit__)
84101

85102

86-
def lookup(element):
87-
_revitlookup.lookup(element)
88103

104+
def SnoopCurrentSelection():
105+
_revitlookup.LookupCurrentSelection()
106+
'''
107+
## Example :
108+
## _revitlookup.SnoopElement(doc.ActiveView)
109+
## _revitlookup.SnoopElement(959510)
110+
## _revitlookup.SnoopElement(doc.ActiveView.Id)
111+
'''
112+
def SnoopElement(element):
113+
_revitlookup.SnoopElement(element)
114+
def SnoopActiveView():
115+
_revitlookup.SnoopActiveView()
116+
def SnoopDB():
117+
_revitlookup.SnoopDB()
89118
# ------------------------------------------------------------------------------
90119

91120

0 commit comments

Comments
 (0)