-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#6473: The WIP state of my investigations - leaving this topic for now
- Loading branch information
1 parent
9ac6de8
commit f2dcaa3
Showing
7 changed files
with
104 additions
and
11 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 |
---|---|---|
@@ -1,11 +1,23 @@ | ||
import dr as darkradiant | ||
import darkradiant as dr | ||
from internal import CommandUtil | ||
|
||
# Python commands would be classes with static members | ||
class ResizeSelectedBrushesToBounds: | ||
def execute(self, min: dr.Vector3, max: dr.Vector3, material: str): | ||
# We can use type hints to make it possible to register its Signature in the CommandSystem | ||
@staticmethod | ||
def execute(min: dr.Vector3, max: dr.Vector3, material: str): | ||
print(min) | ||
print(max) | ||
print(material) | ||
|
||
import inspect | ||
for name, obj in inspect.getmembers(sys.modules[__name__], inspect.isclass): | ||
print(name) | ||
@staticmethod | ||
def canExecute(): | ||
return true | ||
|
||
print('We have the module: ' + __name__) | ||
|
||
# Proves that it's possible to access previously registered DR interfaces | ||
print(dr.ScriptingSystemInterface) | ||
print(dr.ScriptingSystem) | ||
|
||
CommandUtil.registerModule(__name__) |
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 darkradiant as dr | ||
import inspect | ||
|
||
class CommandUtil: | ||
@staticmethod | ||
def registerModule(moduleName): | ||
for name, obj in inspect.getmembers(sys.modules[moduleName], inspect.isclass): | ||
print(name + ' ' + str(obj)) | ||
registerClass(name, obj) | ||
|
||
@staticmethod | ||
def registerClass(name, obj): | ||
sig = inspect.signature(obj.execute) | ||
print(sig) | ||
|
||
for paramName in sig.parameters: | ||
print("Parameter {0} has type {1}".format(paramName, sig.parameters[paramName].annotation)) | ||
# Prove that we can identify DR types in the signature | ||
if sig.parameters[paramName].annotation == dr.Vector3: | ||
print('This parametr is a Vec3') | ||
#dr.ScriptingSystem.registerBuiltinScriptCommand(...) |
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