Search code examples
sketchup

how to use add_dimension_linear


Since Sketchup 14 there is a new API function

add_dimension_linear see

In trying to understand and use it I have looked for some examples and discussions at:

the offeset_vector parameter is described in the API reference as:

the parallel offset vector from the reference line to the dimension line measured from the 'start' reference point.

In the example e.g.

 dim = entities.add_dimension_linear edge, mp, cp, [20, 0, 0]

the Vector is 20,0,0.

How is this Vector to be chosen?


Solution

  • This vector just indicates how far and in which direction you want to offset the dimension line so that it doesn't overlap with whatever entity you are dimensioning. So the exact choice of direction and offset amount depends on the situation.

    Try pasting this code into the Ruby Console, for instance:

    entities = Sketchup.active_model.entities
    dim = entities.add_dimension_linear [50, 10, 0], [100, 10, 0], [0, 20, 0]
    

    You'll see that the dimension leader lines are in y-direction, because the vector is specified as [0, 20, 0]