Problem using RhinoCommon in PyCharm

Hi forum,
This might be quite obvious to many of you, but I’ve only recently started working with Python in general, not to mention the strange and constantly shifting integration of coding tools within Rhino.

I am trying to move away from IronPython for us to be able to use tools like pandas and numpy. But now that I’m trying to move everything I wrote in the Python tool in grasshopper, I can’t seem to make it work. I tried starting with very small examples:

import rhino3dm as rg

pt1 = rg.Point3d(0, 0, 0)
pt2 = rg.Point3d(0, 0, 1)
line1 = rg.Line(pt1, pt2)
line_length = rg.Line.Length(line1)

print(line_length)

I installed the rhino3dm module along with the rhino-stubs one.
If I don’t do the “rg.Line.Length(line1)” part it seems that it works, print(line1) gives me:

<rhino3dm._rhino3dm.Line object at 0x0000018C04A694B0>

Whereas when trying to just add a length command to it brings up an error:

Traceback (most recent call last):
  File "C:\Users\...\TEST\main.py", line 7, in <module>
    line_length = rg.Line.Length(line1)
TypeError: 'property' object is not callable

That’s even before I even started thinking about how to import our own geometry from GH/Rhino into PyCharm not to mention export the results back.

Any ideas? What am I doing wrong? Will I have to re-write all of our codes with compute_rhino3d instead? I can’t even find a way to create a simple Point3D with compute_rhino3d commands…

I’m even willing to pay for private lessons regarding this entire thing, it’s almost impossible to find concrete information for beginners.

Thanks in advance,
Lev

Hi @l.zhitnik,

TypeError: 'property' object is not callable

Length is a property. But you are using it like a method.

Try:

line_length = line1.Length

– Dale

1 Like

Thank you Dale, that certainly works.
That was a small and stupid mistake on my part, I do have another question if you don’t mind:
Some of the commands I use are from rhinoscriptsyntax, even though most of my functions are written almost exclusively with RhinoCommon. I noticed that it’s impossible to import it into PyCharm, unlike the RhinoCommon API. Is that something I can solve?

Hi @l.zhitnik,

RhinoScriptSyntax is open source.

Keep in mind that RhinoScriptSyntax uses RhinoCommon, not Rhino3dm.

You can use RhinoCommon from CPython/PyCharm by using Rhino.Inside.

– Dale

1 Like

Thank you so much, I’ll go over it and try to make it work!

Hi Dale, I really appreciate your help. I’d like to ask a follow up question if I may:
I installed rhinoinside easily and it works brilliantly so far. I also downloaded the rhinoscript repository and added it to venv (although I don’t know if that is what I should be doing).

when trying to import rhinoscriptsyntax I’m getting the following error:

Traceback (most recent call last):
  File "C:\Users\...\test2.py", line 1, in <module>
    import rhinoscriptsyntax
  File "C:\Users\levzh\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscriptsyntax.py", line 2, in <module>
    from rhinoscript.application import *
  File "C:\Users\levzh\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\__init__.py", line 8, in <module>
    import application, block, curve, dimension, document, geometry, grips, group
ModuleNotFoundError: No module named 'application'

I’ll add that I’m trying to work with the Python 3.10 Interpreter and not IronPython, that is the whole purpose of moving out of the GH environment for us.

I’m sorry if my questions are basic and thanks again

Lev