Python typing - Iterable


It is possible to complete Rhino3dm’s PYI, more exactly all iterable objects break type annotations.
Such as File3dmObjectTable or Iterable[...]

In fact, a lot of information is missing.

There must be an error or a lack in the stubs generator because no class is extended by the base class. The example of “PolylineCurve”

    class PolylineCurve:
        def PointCount(self) -> int: ...
        def Point(self, index: int) -> Point3d: ...
        def SetPoint(self, index: int, point: Point3d) -> None: ...
        def ToPolyline(self) -> Polyline: ...

But it is a subclass of “Curve”

    class PolylineCurve(Curve):

So if you don’t know the API things like:


are unknown to rhino3dm beginners and the linter.
All classes are like this. It would be nice for little guys like me to add the base class.

In addition, some of the more common structures are incomplete.
This is the case for example of the “Line” structure:

    class Line:
        def __init__(self, _from: Point3d, to: Point3d): ...
        def IsValid(self) -> bool: ...
        def Length(self) -> float: ...
        def Direction(self) -> Vector3d: ...
        def UnitTangent(self) -> Vector3d: ...
        def PointAt(self, t: float) -> Point3d: ...

There, if you don’t know, you might think that the starting or ending point is not available. However, the “From” and “To” properties exists.

Same for “Point3d” which does not contain “X”, “Y” and “Z”.

It seems that the structures do not contain the properties of the instances.

I wish I could do things with Python and Rhino, I’m not talking about becoming an expert but being able to write a few useful lines.
I am not criticizing, but there is too much lack for your work to be useful.
Currently the stubs are only on surface. I hope you will find the time.

Thanks, I created an issue for this at

Thank you. It would help me a lot.
I’m not really a programmer if the IDE doesn’t guide me and the Linter doesn’t think for me …)

Oh!!! But you have already fixed it !!
:+1: :+1: :+1:

I haven’t published new builds of rhino3dm to pypi yet. I’m working on this now.

1 Like

I don’t know if you’ve seen this but inside VScode (pylance) something like:

class ArcCurve(Curve):
    def Arc(self) -> Arc: ...

does not find the reference to class Arc but at its property ArcCurve.Arc

I did not find any other solution than to write:

from typing_extensions import TypeAlias
_Arc: TypeAlias = Arc
class ArcCurve(Curve):
    def Arc(self) -> _Arc: ...

I see this too. I’ve had some issues with pylance since it was released, but I’m not really sure if that is to blame. Even properties that return basic types like float are not recognized.

For example, why is pylance getting confused over basic types as shown here?

Oh, on my side everything is good for me and correctly find stdlib/buitins.pyi

my user settings

    "python.jediEnabled": false,
    "python.languageServer": "Pylance",
    "python.defaultInterpreterPath": "C:\\Program Files\\Python37\\python.exe",
    "python.analysis.extraPaths": [

I had an old path to typeshed files and it looks like this was messed up when VS Code updated to use pylance. I removed the path entry and am now getting better results. I still see the problem with ArcCurve.Arc

I think this is a special case where pylance is getting confused because the property name and the return type are the same word.

I retype the blender importer import_3dm. It’s a good exercise for testing types)

For now, apart from the Rhino tables, I changed
ArcCurve.Arc et LineCurve.Line

for converters/ work

Is pycharm free and working well?

I haven’t used pycharm for a while. VS Code just got too good at dealing with python.

Until today, I had never really succeeded with rhino3dm, even if there are still holes in the copy I have, that changes everything! I can understand Nathan’s script.
I’m starting to see the possibilities offered by, I am happy!

I quickly typed import_3dm, Do you want me to send you the copy?

1 Like

What is import_3dm ?

You should probably make a PR for that repository if you have something to contribute.