Add dimension to Grasshopper document using Python

Hi all,

I’m simply trying to add a dimension to my GHdoc by using either the commands rs.AddLinearDimension() or rs.AddAlignedDimension(). However, both are giving the error message as below:

Runtime error (NotSupportedException): This type of object is not supported in Grasshopper, so this Python script cannot create it. You might want to use ‘scriptcontext.doc = Rhino.RhinoDoc.ActiveDoc’ to use the Rhino doc, instead? If you do, remember to restore it: ‘scriptcontext.doc = ghdoc’.

line 45, in AddAlignedDimension, “C:\Users\matt.harwood\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\”
line 349, in script

I’ve tried the suggestion, but this creates a baked dimension in the Rhino space which I don’t want.

Any ideas how to simply add a GH dimension using Python?

Currently there is no way to add dimension in GH using Python. Added a request to the list:

1 Like

Hi @Matt_Harwood

As a workaround, you should be able to create your own dims through a custom display with ghpython.

Attached an example, which is based on this article. (11.8 KB)

Hope it helps.



This is not a GhPython request alone. Grasshopper does not handle dimensions in their own right, so the same applies to GhPython. I know David has some plans for GH2.

What is available, is adding dimensions to the Rhino document (“baking”), as you noticed. That is already possible, also from GhPython. It would be possible to pass the ID of the created item, and modifying it in downstream components. For a more comprehensive view, I’ll defer this topic and wait for @DavidRutten’s opinions.

1 Like

The AlignedDim component seems to allow this functionality? That is essentially what I’m trying to recreate.

That component, as you can see, has no output, so it’s not really a normal component.

So, in general, if you are recreating it, what doesn’t it have that you miss?

That component works fine, what I want to do though is write that functionality (or similar) into a Python script. I have a large script that creates some visual output that I’d like to add dimensions to. These only need to be visibly in the GH display and wont ever be baked into Rhino.

Hi @Matt_Harwood

so, if all you are after is recreate the AlignDimension component in Python, then David Leon’s script will work for you (in Rhino 6+).



Giulio Piacentino
for Robert McNeel & Associates

@piac I recently tried using the ghpythonlib.components module to use the AlignedDimesion component. However, despite the command running, no dimension seems to have been returned. What have I done wrong?

Dims = ghcomp.AlignedDimension(rs.coerceplane(rs.WorldXYPlane),rc.Geometry.Point3d(0,0,0),rc.Geometry.Point3d(150,0,0),1,"{0:0,00}",1)']



Hello! Unfortunately nothing is wrong. The component does not return anything, so the library is displaying correct behavior.

Ofcourse, the component has no outputs. In which case, how can I get the display that the component usually displays from that Python command? If it’s not possible, doesnt that render


pretty useless?

The ghcomp library simply runs any component and provides its results. It’s automatic, and does exactly that.

If that component doesn’t have outputs, there’s not much it can do. You are basically requesting that Grasshopper returns aligned dimensions geometry, really.