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’.

Traceback:
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\dimension.py”
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:
https://mcneel.myjetbrains.com/youtrack/issue/RH-59040

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.
custom_dim.gh (11.8 KB)

Hope it helps.

-David

1 Like

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?
@Matt_Harwood

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+).

Thanks,

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com