pyrevitlabs / pyRevit

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

pyRevit calling rhino inside python script? #2020

Open ay-ex opened 9 months ago

ay-ex commented 9 months ago

Thank for awesome pyRevit, @eirannejad - I used it now in multiple AEC-offices and it was a huge helper in each scenario! ☺️

Is your feature request related to a problem? Please describe. I was wondering if it was possible to call a python script - which usually runs in the context of Rhino.Inside.Revit - from pyRevit, or package it in a way that I could deploy it to our users as a regular pyRevit button?

A concrete use case would be: Some of our more complex model elements cannot be cut with RevitAPI, but Rhino is able to do so. So I created a Python script which first gets the elements from revit, turns them into rhino brep, do a boolean operation, and create the result as a direct shape back in rvt.

Describe the solution you'd like Would be great if I could call that logic from within a regular pyRevit script button. (adding imports or extending sys.path, and additional error handling for requirement checks would be fine for me to implement)

Describe alternatives you've considered Manually open Rhino.Inside.Revit and run said script. But this is clearly not the same nice user experience users of pyRevit usually have.

Let me know if I should elaborate further or clarify details of my question. Thank you so much in advance! 🙂

sweco-begertjanvdb commented 8 months ago

Best I can come up with is trying to launch rhino compute and use requests to communicate with it to serve geometry? However I think that sounds pretty complicated and would require considerable effort.

Does anybody have any ideas?

ay-ex commented 8 months ago

In another use case I invoked BlenderBIM from pyRevit, to patch up broken rvt-ifc-exports. But surely it is more trivial to start external python with ifcopenshell, than starting the rhino.inside engine and passing a python source code to be executed to it? maybe @eirannejad any ideas or pointers?

ay-ex commented 8 months ago

@sweco-begertjanvdb : oh, I had not heard about rhino compute yet - a rhino rest api server - fascinating! 🙂
but is that run in the same rvt-memory-context as rhino inside? (as it would need reference to the current rvt doc) (from the first glance at rhino compute docs, when it says it is "stateless", I would assume it cannot work with the reference to an open rvt model, even if it was started the rhino.inside.rvt way. 🤔 )

sweco-begertjanvdb commented 8 months ago

yeah that's why I said it's a long-shot. Because you'd have to convert geometry into obj or 3ds format, send it to that server. Wait for it to finish calculation and return obj, 3ds data.

ay-ex commented 8 months ago

ok I see, a long-shot indeed. but thank you for elaborating! then in that scenario rhino.inside would not even be needed, as the geometry conversion would need to happen on the rvt side anyways. 🤔