Adding an Arc via API

When I attempt to add a 12-segment Arc to my model using the following code, the result is 12 individual edges, rather than an Arc made up to those same 12 edges. In other words, when I try to select the Arc I just made, only a single edge is selected, not the entire Arc (as displayed in ‘Entity Info’. My global ‘@@gnum_segments’ is set to 12:

  model = Sketchup.active_model
  model.start_operation("Create Arc of radius #{@@gref_radius.to_l}", true)
  model.active_entities.add_arc(center_pt, xaxis, arc_norm, @@gref_radius, 0.degrees, -180.degrees + radius_angle, @@gnum_segments)
  model.commit_operation

I’ve tested it.
Using -ve angles causes the issue.
If the start/end angles >=0 it works OK.
You can draw the arc below the X_AXIS as you want by simply setting both of you angles to +ve values AND then reverse the vector used for the arc_norm…

I’ve never noticed this before - having always used +ve angles…

1 Like

I will try this by just negating my ‘arc_norm’ and making the ‘end angle’ positive…

That did it. :+1:

I was calculating ‘arc_norm’ as a cross product of two vectors, I just reversed them which gives me a vector of the same length but in the opposite direction.

Works great, thank you :grinning:

1 Like