Creating/Baking angular dimensions from Python

tl;dr: I am creating/baking angular dimensions from Python, but negative angles never show a minus sign. How can I change the Dimension style to respect the sign? Or alternatively, how do I parse the result of ghpythonlib.components.AngularDimension(…) so I can bake it?

More detail:

I need to create/bake angular dimensions from Python code. I see 2 ways to do it:

  1. Use Rhino directly, like this: How to make Angular dimension by Python Rhino

  2. Use ghpythonlib.components to call the Grasshopper AngularDimension component directly.

I’ve gotten (1) to work correctly EXCEPT that the baked dimension never has a minus sign when I think it should: I’m passing in positive or negative numbers for the angle, as appropriate for different cases, but the dimension always shows as positive. For instance, here is my baked dimension (black) and a preview of the dimension produced by the Grasshopper component (red). the angle is specified at -144.9:

(Note I’m always referencing off the x axis, and I want clockwise positive and ccw negative.)

I would actually love to use (2), calling the component directly from Python with ghpythonlib.components, but I can’t for the life of me figure out how to parse the result. This code:

import ghpythonlib.components as ghcomp

res = ghcomp.AngularDimension(C,A,B,False,T,S)
print(res)

gives me this:

Array[object](())

But the array is zero length, and what do the nested parens mean?

In summary, I either need to figure out how to make the dimension style respect the sign of the angle I give it OR figure out how to parse the result of ghpythonlib.components.AngularDimension(…) so I can bake it.

Any help or insight deeply appreciated.

A related question: Using Rhinocommon directly, it appears that only one of the AngularDimension() constructors is supported? The code below fails with the error message “AngularDimension() takes at most 2 arguments (6 given)” despite this being one of the documented constructors:

image

# Add angular dimensions
sc.doc = Rhino.RhinoDoc.ActiveDoc
dimStyle = rs.CurrentDimStyle()
rs.DimStyleTextHeight(dimStyle, 25)
ang_dim = Rhino.Geometry.AngularDimension(Rhino.Geometry.Plane.WorldXY,X,C,A,B,A)
dim = sc.doc.Objects.AddAngularDimension(ang_dim)
sc.doc = ghdoc

Hi @dogrocket, i can repeat your results using either

ghcomp.AngularDimension

or

Rhino.NodeInCode.Components.NodeInCodeFunctions.AngularDimension

in both cases the returned result is an empty Array of type object. Maybe this is a bug. For your second post using RhinoCommon, note that the constructor with the 6 arguments requires Rhino 8.

Btw. i’ve not been able to create an angular dimension with a negative angle either using code or Rhino command. It might be possible to add the dimension with a modified dimension text “-<>” which includes the sign…

_
c.