How to store token within document?

Playing with compute and rhino3dm at the moment and have few problems.

If I use example from

I paste token and everything is ok but if I don’t want to use Tkinter and try to store token in document as

auth_token = “my_token_from_compute_login”
compute_rhino3d.Util.authToken = auth_token

everything goes south…
get errors like

  Traceback (most recent call last):
  File "/home/lukasz/.local/lib/python2.7/site-packages/compute_rhino3d/Curve.py", line 552, in Split
    response = Util.ComputeFetch("rhino/geometry/curve/split-curve_brep_double", args)
  File "/home/lukasz/.local/lib/python2.7/site-packages/compute_rhino3d/Util.py", line 17, in ComputeFetch
    response = urllib2.urlopen(req, json.dumps(args))
  File "/usr/lib/python2.7/json/__init__.py", line 244, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python2.7/json/encoder.py", line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python2.7/json/encoder.py", line 270, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <rhino3dm._rhino3dm.Circle object at 0x7fd41d28bb90> is not JSON serializable

I’m sure I’m doing something wrong.
Is there some way of storing token within document?

The other thing is when I look at
https://compute.rhino3d.com/sdk
there is tons of stuff like

2401 [/rhino/geometry/circle/getplane](https://compute.rhino3d.com/rhino/geometry/circle/getplane)
2402 [/rhino/geometry/circle/getradius](https://compute.rhino3d.com/rhino/geometry/circle/getradius)
2403 [/rhino/geometry/circle/getunset](https://compute.rhino3d.com/rhino/geometry/circle/getunset)
2404 [/rhino/geometry/circle/isinplane](https://compute.rhino3d.com/rhino/geometry/circle/isinplane)

but when I import compute_rhino3d.

I only get
-Curve
-Brep
-Util
-Extrusion
-NurbsCurve
-BezierCurve

How can I access all these methods?

My rhino3dm is in 0.0.7 and compute_rhino3d in 0.0.6
Running on Python 2.7 using Pycharm in virtualbox (ubuntu)

PS. I think rhino3dm and compute is a killer project!!

PS2.
@stevebaer
Your sample from

>>> from rhino3dm import *
>>> import compute_rhino3d.Util
>>> import compute_rhino3d.Mesh
>>>
>>> center = Point3d(250, 250, 0)
>>> sphere = Sphere(center, 100)
>>> brep = sphere.ToBrep()
>>> compute_rhino3d.Util.authToken = AUTH_TOKEN_FROM (rhino3d.com/compute/login)
>>> response = compute_rhino3d.Mesh.CreateFromBrep(brep)
>>> mesh = CommonObject.Decode(response[0])
>>> print("Computed mesh with {} faces".format(len(mesh.Faces))

Doesn’t work for me. I get…

Traceback (most recent call last):
  File "/home/lukasz/PycharmProjects/t2/q2.py", line 7, in <module>
    compute_rhino3d.Util.authToken = AUTH_TOKEN_FROM (rhino3d.com/compute/login)
NameError: name 'AUTH_TOKEN_FROM' is not defined

First off, thank you for creating a new post with your questions. This helps us have a better understanding that these are new issues and not somehow related to the previous posts in a thread.

I just updated both rhino3dm and compute-rhino3d last night. You should try getting the latest versions from PyPi since this may address some of the issues that you are seeing.

If the sample worked and just changing how the authToken is set breaks things, then there is something very strange happening in your script. Could you attach your adjusted script without your authToken to this thread so I can try and repeat the problem that you are seeing?


There are a few different things going on here. Currently compute.rhino3d is listing a ton of functions available in the Rhino.Geometry namespace of RhinoCommon. This was necessary when we first started working on the server because we didn’t have “fat clients” with the exception of Rhino3dmIO and we wanted to test calling a bunch of different functions on the server. Just in the last week this has changed and we now have javascript and python clients that are already somewhat significant in size and allow for performing many operations on the client without any required overhead for calling a server. The compute server really should only be used for performing tasks that you don’t already have available in your client library. We will be adjusting the compute sdk page to show only the functions that you should be using compute for and not every single function under the sun.

Now for the compute_rhino3d package. It is not complete yet, but there a already 290 functions available in that package for calling compute. The functions are separated out into each module. This package will also continue to grow in functionality.


This doesn’t exist. It is meant as a placeholder for you to place your individual authToken. Something like
compute_rhino3d.Util.authToken = "213asfkldsjwerewfelkjdsfewrweor......."
In other words, the auth token that you get when you visit Rhino Accounts

Hi Steve

Thank you for your help. Turns out I’ve been just silly so I’ll tell you what I did wrong.

No it wasn’t this sample, I’ve made a new script using authToken and I was getting plenty of JSON errors.
After further study of your samples I’ve noticed, that every object like Line, Circle, Sphere needs to be converted to either NurbsCurve format or Brep…this was missing bit in my script, now it’s working as expected.

I’m getting it and it does makes a lot of sense for me now. Fingers crossed for further rapid development of these libraries :slight_smile:
I can clearly see a potential for IoT devices operated by non-CAD users leveraging these libraries.