def __init__(self, uiApplication):
'''
for RevitSnoop to function properly, it needs to be instantiated
with a reference to the Revit Application object.
'''
# find the RevitLookup plugin
try:
rlapp = [app for app in uiApplication.LoadedApplications
if app.GetType().Namespace == 'RevitLookup'
and app.GetType().Name == 'App'][0]
except IndexError:
self.RevitLookup = None
return
# tell IronPython about the assembly of the RevitLookup plugin
clr.AddReference(rlapp.GetType().Assembly)
import RevitLookup
self.RevitLookup = RevitLookup
# See note in CollectorExt.cs in the RevitLookup source:
self.RevitLookup.Snoop.CollectorExts.CollectorExt.m_app = uiApplication
self.revit = uiApplication
python类AddReference()的实例源码
def on_activate(self):
""" Activate module.
This method needs to set ip the CLR to Python binding and start Lightfield.
"""
lfpath = os.environ['LIGHTFIELD_ROOT']
lfaddinpath = os.path.join(os.environ['LIGHTFIELD_ROOT'], 'AddInViews')
sys.path.append(lfpath)
sys.path.append(lfaddinpath)
ref1 = clr.AddReference('PrincetonInstruments.LightFieldViewV4')
ref2 = clr.AddReference('PrincetonInstruments.LightField.AutomationV4')
#print(dir(ref), '\n\n')
#ref.LoadFrom(ref.Location)
verbose = list(clr.ListAssemblies(True))
short = list(clr.ListAssemblies(False))
#for i in short:
# print('ASSEMBLY:', i)
#for i in verbose:
# print('ASS:', i)
#for i in ref2.Modules:
# print('ASS Module:', i)
#for i in ref2.ExportedTypes:
# print('ASS Exported type:', i)
try:
for i in ref2.DefinedTypes:
print('ASS Defined type:', i)
except System.Reflection.ReflectionTypeLoadException as e:
for i in e.LoaderExceptions:
print('EXC:', i.Message)
print('ASS Entry point:', ref2.EntryPoint)
print('ASS is Dynamic:', ref2.IsDynamic)
from PrincetonInstruments.LightField.Automation import Automation
import PrincetonInstruments.LightField.AddIns as ai
lst = col.List[System.String]()
self.au = Automation(True, lst)
self.app = self.au.LightFieldApplication
self.exp = self.app.Experiment
self.exp.ExperimentCompleted += EventHandler(self.setAcquisitionComplete)
self.exp.ImageDataSetReceived += EventHandler(self.frameCallback)
self.exp.SettingChanged += EventHandler(self.settingChangedCallback)
self.app.UserInteractionManager.SuppressUserInteraction = True
self.prevExperimentName = self.exp.Name
print('Prev Exp', self.prevExperimentName)
#self.getExperimentList()
#self.openExperiment(name)
self.lastframe = list()
def _():
import sys
if sys.platform == 'cli':
import clr
clr.AddReference('IronPython.SQLite')
def get_hostname():
import clr
clr.AddReference('System.Windows.Forms')
import System.Windows.Forms as forms
return forms.Application.ProductName
def _():
import sys
if sys.platform == 'cli':
import clr
clr.AddReference('IronPython.SQLite')