Have found a couple of calls that don’t return the geometry the docs say they will, they return dictionaries instead.
NurbsSurface.CreateNetworkSurface(…) and Curve.CreateFillet(…) are the two I’m aware of.
CreateFillet can be worked around by using Util.DecodeToPoint3d afterwards to recreate the arc, but I can’t find a way to do something similar for CreateNetworkSurface - does anyone have any ideas?
You need to post at least a relevant example of your code (and geometry)! How can anybody help you otherwise? At this point, it’s pretty much just guessing what your issue is, which - when I’m wrong - was a waste of my time and yours.
Have you already tried something like this?
import rhino3dm
import compute_rhino3d
compute_rhino3d.Util.authToken = ""
#compute_rhino2d.Util.url = ""
model = rhino3dm.File3dm()
# ...
# Your mysterious code
# ...
srf = compute_rhino3d.NurbsSurface.CreateNetworkSurface(…)
if srf is not None:
model.Objects.AddSurface(srf)
model.Write("test.3dm", 5)
I realise that, the issue is that CreateNetworkSurface1 doesn’t return a NurbsSurface, it returns the dictionary in the list shown in my post above. It can’t be added to the model, because it isn’t a rhino3dm.Surface, nor rhino3dm.GeometryBase.
CreateNetworkSurface1 returns the wrong type. I’m wondering if anyone has a workaround to use until this is fixed. There’s a similar situation with Curve.CreateFillet, and for that there is a workaround, which is using Util.DecodeToPoint with the coordinates that are returned in the dictionary there.
The return type should be NurbsSurface according to the docs. I had tried to deserialise this using compute_rhino3d.Util.DecodeToCommonObject before creating this thread but, somehow, I must have been doing it wrong, because just now when doing it again so I could post my results here - it works.
I can appreciate how this could be confusing given that the docs say that the function simply returns a NurbsSurface. The reason you get a list instead is that the RhinoCommon method, CreateNetworkSurface(), that is being called behind the scenes also has an out param – an integer representing the error “code”. Since out params are a .NET thing, the python client returns them along with the actual return value, as a list.
A good way to handle this clearly in your python code might be to use multiple assignment (a.k.a. destructuring assignment) to decompose the returned list into separate variables.
surf_obj, e = compute_rhino3d.NurbsSurface.CreateNetworkSurface1(crvs, 0, 1, 1, 1, False)
# TODO: check the value of e
surf = compute_rhino3d.Util.DecodeToCommonObject(surf_obj)
print(srf)