Adding dimension linear along 3D edge

I can add DimensionLinear objects along 2D edges by passing an offset vector like [cos(PI/2 + phi), sin(PI/2 + phi), 0], where phi is the angle that the edge makes with the x-axis, but I can’t figure out how to do the same thing in 3D.

I was thinking that something like

entities = Sketchup.active_model.entities

edge = entities.add_edges([0, 0, 0], [10, 10, 10])[0]
offset_vec = edge.line[1]

dim_linear = entities.add_dimension_linear(edge.start, edge.end, offset_vec)

would do the trick, but it doesn’t… When I checked the text attribute of dim_linear I got "0.00 m", which is clearly wrong.

What am I missing here?

Never mind, I am so stupid. The exact same thing works in 3D… All I had to do was to find the angle that the projection of the 3D edge makes with the x-axis.

1 Like