pyrevitlabs / pyRevit

Rapid Application Development (RAD) Environment for Autodesk Revit®
http://wiki.pyrevitlabs.io
GNU General Public License v3.0
1.33k stars 338 forks source link

pyRevit: CPython (Python 3) equivalent of the IronPython (Python 2) "import clr" #1311

Closed bdschust18 closed 3 years ago

bdschust18 commented 3 years ago

Good day.  

In IronPython, the clr module points to the following:

SCRIPT:

import clr print(dir(clr)

OUTPUT:

['AddReference', 'AddReferenceByName', 'AddReferenceByPartialName', 'AddReferenceToFile', 'AddReferenceToFileAndPath', 'AddReferenceToTypeLibrary', 'ArgChecker', 'ClearProfilerData', 'CompileModules', 'CompileSubclassTypes', 'Convert', 'Deserialize', 'Dir', 'DirClr', 'EnableProfiler', 'GetBytes', 'GetClrType', 'GetCurrentRuntime', 'GetDynamicType', 'GetProfilerData', 'GetPythonType', 'GetString', 'GetSubclassedTypes', 'ImportExtensions', 'IsNetStandard', 'LoadAssemblyByName', 'LoadAssemblyByPartialName', 'LoadAssemblyFromFile', 'LoadAssemblyFromFileWithPath', 'LoadTypeLibrary', 'Reference', 'References', 'ReferencesList', 'ReturnChecker', 'RuntimeArgChecker', 'RuntimeReturnChecker', 'Self', 'Serialize', 'SetCommandDispatcher', 'StrongBox', 'Use', 'name', 'package', 'accepts', 'returns']

When running this with CPython, it seems to point to a completely different module (I believe pythonnet).  

SCRIPT:

! python3

import clr print(dir(clr)

OUTPUT:

-- too long to post here, but not the same as the first output.  

My question is what is the equivalent module or method to obtain the correct clr module.

Thank you in advance.  

eirannejad commented 3 years ago

It is import clr but the implementation of the clr module in IronPython and PythonNet (cpython in dotnet) are different.