CPython and PyRevit

CPython and PyRevit

pedramno
Explorer Explorer
2,874 Views
8 Replies
Message 1 of 9

CPython and PyRevit

pedramno
Explorer
Explorer

Hello All,

first of all, this question might be repetitive. if so, please point me to the right solution.

Here is my question: I need to use CPython via PyRevit to have access to libraries such as numpy and pandas. At the same time, I want to take advantage of Pyrevit’s capabilities such as forms etc. As far as I understood, I can’t have both of these on a single script file. If I got this correctly, is there any way to do this?

Thanks in advance

Accepted solutions (1)
2,875 Views
8 Replies
Replies (8)
Message 2 of 9

jeremy_tammik
Alumni
Alumni

Sounds like a sensible question to me. However, this is not the optimal place for it. This forum is for discussing the Revit API, pure and simple. You might want to check out the issues and solutions in the pyRevit repository:

  

https://github.com/eirannejad/pyRevit

  

Quite a few people here in the forum also use pyRevit, though, and may be able to help. I am sure your goal can be achieved. There are many ways to disentangle and compartmentalise functionality. One important aspect to ponder is: how tightly are your Revit API bit and pieces interwoven with your numpy and pandas bits? I should hope that they are already pretty well decoupled to start with. In that case, you can make use of numerous IPC solutions to establish the connection required:

   

https://en.wikipedia.org/wiki/Inter-process_communication

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 9

pedramno
Explorer
Explorer
Thanks very much, Jeremy. I also checked the pyRevit forum and asked the same question there. The numpy part is quite decoupled since it is meant to help me with the data exchange process from other data sources and after that point, everything would be focused on Revit APIs. I'm not pretty familiar with IPC solutions but I'll take a look at them to familiarize myself more with them.
Message 4 of 9

RIPENG
Enthusiast
Enthusiast
Accepted solution

Dealt with the same challenge a little while back.

 

Please click here for a short discussion on Python subprocess in the Revit/pyRevit context.

 

While I am not a Revit API / Python / pyRevit expert I can report that subprocess worked well enough. Learning subprocess should be a productive use of time assuming the underlying characteristics are a good match for your application.

 

-Jake

Message 5 of 9

pedramno
Explorer
Explorer

Thanks, Jake. I tried the same process, and it also worked perfectly for my case. Appreciate it.

0 Likes
Message 6 of 9

RIPENG
Enthusiast
Enthusiast

Thanks for giving it a go. And thanks for the feedback.

 

-Jake

Message 7 of 9

minet.axel
Enthusiast
Enthusiast

Hello is there a similar solution for c#? I want to solve this problem of dll hell.

0 Likes
Message 8 of 9

jeremy_tammik
Alumni
Alumni

Almost everything that exists in Python is open source, so you can of course re-implement the same in C#. Many other solutions have also been discussed. In general, the easiest solution is to use the same DLL in all your components and avoid the problem completely. The second-simplest solution is to decouple the components from each other and use some method to communicate the relevant data between them, e.g., IPC. Here is a collection of related discussions by The Building Coder:

 

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 9 of 9

jeanmarc.couffin
Advocate
Advocate

For the sake of completeness, questions related to pyRevit should be routed to https://discourse.pyrevitlabs.io/

 

This type of question has been formulated or answered in many different ways on the pyRevit forum https://discourse.pyrevitlabs.io/search?q=subprocess

 

 

0 Likes