I have a question about Sketchup::ArcCurve

I think after the arc scaling, it should not be an arc, but a curve.

cirle = Sketchup.active_model.entities.add_circle ORIGIN, Z_AXIS, 10
tr = Geom::Transformation.scaling(ORIGIN, 0.5, 1, 1)
Sketchup.active_model.entities.transform_entities tr,cirle
puts cirle[0].curve.class
# => Sketchup::ArcCurve

My current solution is not to scale the arc, but to add the arc to the group and then scale the group

An object can’t dynamically change class in Ruby, which causes some oddities with the way arcs are implemented in the API.

Is this causing you any specific problems (other than just being a bit weird)?

Maybe we should clarify the docs, or possibly add a method to query if the arc curve is actually an arc. Not sure what would be needed.

From my ArcCurve refinement library:

    # Returns whether this arc has been distorted by a non-uniform scaling.
    #
    # @return [Boolean]
    def distorted?
      self.xaxis.length != self.radius ||
      self.yaxis.length != self.radius
    end

    # Returns whether this arc is still uniform in scale. Ie, has not been 
    # distorted by a non-uniform scaling.
    #
    # @return [Boolean]
    def uniform?
      self.xaxis.length == self.radius &&
      self.yaxis.length == self.radius
    end

Note also that I override ArcCurve#radius to return a Length object rather than a Float.

From my ArcCurve refinement library:

    # Returns the radius of the arc in inches.
    #
    # @return [Length] The radius of the arc.
    def radius
      super.to_l
    end

A bit of testing seems to indicate that the above works even if within an edit context that contains a distorted curve.

Ie, a component definition has a uniform curve in it’s entities collection.
The model has an instance of this component that has been non-uniformly scaled in the Y direction.

Outside the instance edit at the model level, checking the definition’s curve in it’s entities returns true for uniformity as it should.

Double clicking into the distorted instance entering it’s edit mode, and selecting the distorted curve object and testing it returns false for curve.yaxis.length == curve.radius as it should.
But (in edit mode) it also returns false if code directly checks the definition’s curve in it’s entities even though the definition’s entities are not scaled. (Exiting edit mode will return the uniform definition curve again.)

So coders need to be aware of this and check the active entities or the active edit path.

1 Like

The DanRathbun’s reply is ok.

Yes, It’s ok. Thank you.