简体   繁体   English

Revit Python宏和RevitPythonShell模块或已加载的软件包

[英]Revit Python Macros and RevitPythonShell Modules, or loaded packages

Both RevitPythonShell scripts and Revit Python Macros are relying on Iron Python. RevitPythonShell脚本和Revit Python宏都依赖于Iron Python。 In both cases, at least in Revit 15, neither require the installation of IronPython. 在这两种情况下,至少在Revit 15中,都不需要安装IronPython。 I believe RevitPythonShell installs with the capacity to process the ironPython script (rpsruntime.dll). 我相信RevitPythonShell可以安装处理IronPython脚本(rpsruntime.dll)的功能。 Revit must install with the same capacity. Revit必须以相同的容量安装。

Therefore, I assume the two programming environments are being executed from separate sources. 因此,我假设这两个编程环境是从单独的源执行的。 Is this accurate? 这个准确吗?

How would I be able to install an external module as I would typically use pip for? 我将如何像通常使用pip一样安装外部模块? Another words, if I wanted to use the docx, pypdf2, tika, or other library - is this possible? 换句话说,如果我想使用docx,pypdf2,tika或其他库,这可能吗?

I agree with your assumption that these two environments are probably completely separate and independent of each other. 我同意您的假设,即这两种环境可能是完全分离且彼此独立的。

Since the Python code that you write within them is pure .NET, it is easy to reference other .NET modules, assemblies, libraries, whatever you want to call them. 由于您在其中编写的Python代码是纯.NET,因此可以轻松引用其他.NET模块,程序集,库,无论您想调用它们如何。 They would reside in .NET assembly DLLs. 它们将驻留在.NET程序集DLL中。

Using pip to add external Python libraries is a completely different matter, however, and rather removed from the end user environment offered by these two. 但是,使用pip添加外部Python库是完全不同的事情,而是从这两者提供的最终用户环境中删除了。

To research that, you will have to dive into the IronPython documentation and see how that can be extended 'from within' so to speak. 要对此进行研究,您必须深入研究IronPython文档,并看看如何可以“从内部”扩展它。

For pure-python modules, it could be as easy as having a CPython installation (eg Anaconda) and pip installing to that, then adding the site-packages of that installation to the search path in RPS. 对于纯python模块,可以简单地进行CPython安装(例如Anaconda)和pip安装,然后将该安装的站点程序包添加到RPS中的搜索路径。

For modules that include native code (numpy and many others), this gets more tricky and you should google how to install those for IronPython. 对于包含本机代码(numpy和许多其他代码)的模块,这会变得更加棘手,您应该通过Google搜索如何为IronPython安装这些模块。 In the end, adding the installed module to your search path will give you access in RPS. 最后,将已安装的模块添加到您的搜索路径将使您能够使用RPS。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM