Closed htlcnn closed 5 years ago
Great find with the __namespace__
. I didn't know it's there. It would be great if you can write up your findings on using the CPython with Revit in a markdown file and I'll publish on the Wiki
I'm going to add a __timestamp__
global variable to the pyRevit engine. This way you can:
class CategoriesFilter(UI.Selection.ISelectionFilter):
__namespace__ = __commanduniqueid__ + __timestamp__
Keep us posted on your findings please.
Okay implemented timestamp and execid (unique id for each execution). The code can be simplified as
from pyrevit import EXEC_PARAMS
class CategoriesFilter(UI.Selection.ISelectionFilter):
__namespace__ = EXEC_PARAMS.exec_id
or less safer but with not pyrevit
import
from pyrevit import EXEC_PARAMS
class CategoriesFilter(UI.Selection.ISelectionFilter):
__namespace__ = __execid__
Will publish this soon with 4.7-beta3
I don't know much about underlying Python Engine of .NET. I just don't know if appending timestamp is proper way to do it, or it would polute the namespace or raise memory etc.
Anyways, I attach markdown writeup below:
Send me your info so I can add as part of Community
I've emailed you my info. Thanks!
@eirannejad I've read your commit above (https://github.com/eirannejad/pyRevit/commit/0073bbc6072c771f6bb507aeb8068a23cc917c87), I'd like to add that IronPython works fine without __namespace__
defined.
Describe the bug I implemented an
ISelectionFilter
interface in my script and use it foruidoc.Selection.PickObjects
. Here is my script:Note that in order to run the script without exception, I had to append
time.time()
to my class'__namespace__
. If I didn't do that, I would get this exception:To Reproduce Steps to reproduce the behavior:
__namespace__ = 'HTL'
uncommentedExpected behavior Script run without exception. Is there any method to avoid recreation of classes (or to override them) if they already exist in certain namespace?
Desktop