I suggest that you overlooked the explanation in the Sketchup::ArcCurve
class’ YARD docstring.
And more, it’s superclass Sketchup::Curve
also makes it clear …
The Curve class is used by SketchUp to unite a series of Edge objects into one conceptual entity. Since SketchUp is a surface modeler, all circles, arcs, and arbitrary curves are really just edges that are bound together in sequence.
What I’m trying to get at is that SketchUp’ API uses the inheritance model, which means that much of the shared functionality is defined in superclasses and passed down to the subclasses.
As you noticed, the layer/tag assignment method is defined in Sketchup::Drawingelement
so cannot be passed down to curves because their classes do not have Sketchup::Drawingelement
in their ancestral lineage.
If you look at the API classes and study them a bit, you’ll notice that only sublcass objects of Sketchup::Drawingelement
can be direct members of any Sketchup::Entities
collection.
Other classes deriving from Sketchup::Entity
are either collection classes or helper classes (ie, things that don’t exist by themselves, and can only be used via accessing a property of something else. The loop objects for a face, for example.)
There are also classes derived directly from Object
that are not (generally) things that are saved into the .skp
file’s data, but are used by the application or used upon the model and it’s data (ie, the various abstract observer class objects.)
Anyway … back to inheritance. So since the curve classes are helper classes they cannot inherit the assignment for a tag/layer. But you can use a refinement if you wish and refine only your use of the two curve classes, like so …
module JoNoS
module RefinedCurves
refine Sketchup::Curve do
def layer=(layer)
self.edges.each {|edge| edge.layer= layer }
end
end
end
end
… and then in your plugin file(s), you can do …
require File.join(__dir__,"refined_curves.rb")
module JoNoS
module SomePlugin
using RefinedCurves
# Example method ...
def set_curve_layer(curve,new_layer)
curve.layer= new_layer
end
end
end
For more examples and explanation of Ruby refinements see the primer …
However, as Thomas explained recently in another topic, curves are just made up of individual edges, that each can have their own layer/tag assignment. They could be assigned to look like a rainbow.
You should likely use AttributeDictionary
objects instead to add information (if possible.)
They can be attached to the model, any subclass of SkecthUp::Entity
, even layer objects themselves or the Layers
collection instead of individual layers. (Attaching to the collection does not run risk that a user would delete the data if they delete a layer/tag.)