Replies: 5 comments 7 replies
-
|
intended for side databases import traceback
from pyrx import Ap, Db
@Ap.Command()
def doit2():
try:
db = Db.Database(False, True)
db.readDwgFile("E:\\temp\\Floor Plan Sample1.dwg")
db.closeInput(True)
@Ap.using_scope()
def using_1():
ms = db.modelSpace()
ents = [Db.Entity(id) for id in ms.objectIds(Db.Entity.desc())]
types = [ent.isA().dxfName() for ent in ents]
print(len(types))
@Ap.using_scope()
def using_2():
ms = db.modelSpace()
ents = [Db.Entity(id) for id in ms.objectIds(Db.Entity.desc())]
types = [ent.isA().dxfName() for ent in ents]
print(len(types))
except Exception as err:
traceback.print_exception(err) |
Beta Was this translation helpful? Give feedback.
-
|
to be published in v2.2.31 |
Beta Was this translation helpful? Give feedback.
-
|
Do I understand correctly that the PyRx/tests/test_core/test_PyDb/test_Database.py Lines 365 to 374 in 4c53df8 |
Beta Was this translation helpful? Give feedback.
-
|
Hi, so I was looking for a way to control when objects are garbage collected Regarding the test, if it does not crash CAD, then it passes. However, I see your point, I can improve the tests class A:
def __init__(self, name):
self.name = name
print(f"Object {self.name} created")
def __del__(self):
print(f"Object {self.name} destroyed")
def foo():
one = A("one")
@Ap.using_scope()
def _() -> None:
two = A("two")
three = A("three") |
Beta Was this translation helpful? Give feedback.
-
|
I have a question, how can I add new stuff, for example, this decorator, but not introduce a new namespace? How can I have both pure python and C++ in the same module, from the perspective of the user? @Ap.using_scope, or just @using_scope I just want stuff to be there without having to hunt for it, i.e. I rarely use @command, I’m too lazy to type import command. if that make sense |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
adds a scope to a function
Beta Was this translation helpful? Give feedback.
All reactions