I use Maxwell render and i want know if i can import its module called Pymaxwell to GhPython; i use this module with Python 2.7 by adding it to site-packages folder.
Is that possible?
It would be easier if you asked the Maxwell guys.
I cannot help because I am not certain, and don’t have Maxwell to test.
Thanks , it’s a module like any other python module (numpy for example)
Ehm, OK; unfortunately not all Python modules are the same. Some modules (like
numpy) cannot be easily loaded directly in Rhino because they reference CPython. Rhino uses IronPython. Only pure-Python modules are always working.
I don’t know if this is the case of the Maxwell module. If it is, you might try “GhPythonRemote”, an add-in that tries to make loading CPython components possible: https://www.food4rhino.com/app/gh-python-remote
I have GhPythonRemote before but i don’t understand how to use it or what it do exactly
i will try to understand it
I installed it and i use Anaconda2
The next step is asking Maxwell developers about some informations
Thanks for help
I think the pdf file must include some informations to help beginners
cd C:“anaconda scripts folder” (C:\Anaconda2\Scripts)
Than the line from pdf file to create virtual environment: conda create …
Than: conda init
conda activate rhinoremote
And finally installation : pip install…
I put Pymaxwell in C:\Anaconda2\envs\rhinoremote\lib\site-packages
I hope this help someone in future
This is my first test with Grasshopper and Maxwell
Long time ago i made this tool with Python, i will try to recreate it with Grasshopper
in standalone ironpython installation you can create a *.pth file inside the /Lib/(1) folder. The contents of this file is the path to your local CPython2 installation. That trick will copy all modules you have in CPython2 in there and make them available in IronPython.
Still some modules are not working well.
(1) - I’ll have to double check the folder. Not in front of the PC now.
Thanks ; i will check that
What is CPython? is it a plugin for Python?
CPython is the regular Python. There is C in front to designate it is written in C
Ok; i did that before but ironPython can’t detect the plugin, and GhPythonRemote is the only way to use it
Hey, GHPythonRemote developer here, glad you found some use for it! Thank you for your comments on the installation instructions, I’m always looking to make the installation easier for new users of the plugin. I’m not sure about a couple of details though:
cd C:"anaconda scripts folder"should only be needed if you (1) did not check “add conda to my PATH” during installation (the instructions recommend you do it) and (2) use cmd.exe instead of the “Anaconda prompt” (the instructions tell you to do that if you did not do (1)). I’m trying to keep that part of the instructions as short as possible, because I don’t want them to become a tutorial on how to setup a Python environment. But maybe you can recommend a sentence or two that would have helped you, making the whole thing clearer?
conda init: I had no idea this command even existed, it looks like a new command from Conda v4.6. What told you you needed to run it? The documentation for it is very sparse, the inline help says it is experimental, and running
conda init --dry-run --verboseon my machine shows it would only do bogus changes, like switch
/in paths to
\… So unless I’m missing something, I don’t think this needs to go in the doc for now, but I’ll keep an eye on it.
Just as a confirmation for you, it looks like PyMaxwell can only be installed by copying a .pyd file. IronPython cannot load .pyd files (they are basically DLLs with a C interface, which IronPython knows nothing about). So if you want to use it in GH, you have to run a CPython in parallel where it will be loaded, e.g. using GHPythonRemote.
You could also have a look at COMPAS to do that, https://compas-dev.github.io/main/api/compas.rpc.html
Hi thank you Pierre
1- That’s why i didn’t check it; but i added the path manually
2- “Anaconda prompt” i tried it but i got the same error message in cmd.exe and nothing work until i use cd C:…
3- When i created the env and tried to activate it i got error message with suggestion to use: conda init
when i did that the installation done and i can use conda without need to type cd C … everytime.
i am not developer and i don’t know why the errors happened
I tried with GH_CPython but i have no idea how to use it
and what is GHPyR? , how i can use it with GhPython?
I don’t recommend this one anymore, development stopped completely on it and I believe COMPAS provides similar functionality.
I meant GHPythonRemote
That should have worked without
cd ... or
conda init, very strange. I’ll try this again on a fresh install some day. Thanks for reporting.
I install COMPAS with pip and Conda
if i use GHPyR why i need compas? i already load pymaxwell and worked fine
it is pymaxwell (python script) with pymaxwell.pyd
COMPAS and GHPythonRemote are two independant Rhino plugins, that both achieve that same goal of interacting with a CPython engine from Rhino. You need one or the other, but not both at the same time. I was only mentioning COMPAS as it has a different approach that can be easier to use in some cases (notably if you need to interact with python 3).