Dimensions returned as Sketchup::Drawingelement?
-
I noticed that linear dimensions and radial dimensions all returns objects of the type
Sketchup::Drawingelement
. While if I use.typename
I getDimensionLinear
andDimensionRadial
. How come they aren't returned asSketchup::DimensionLinear
andSketchup::DimensionRadial
objects like the rest of SU's entities?And what defines what the .typename returns? I thought it was controlled by the class. But since
DimensionLinear
andDimensionRadial
both areSketchup::Drawingelement
, where's the.typename
data coming from? -
Are you not confusing the name of an object and the object itself?
So foo.class returns the object which is of class Class.
foo.typename returns the name of the class of class String
So there will be a method in the class that gives the string representation of itself (a .to_s() kind of thing).
Adam
-
hmm..
model=Sketchup.active_model #<Sketchup;;Model;0x610ba90> sel=model.selection #<Sketchup;;Selection;0x6a611a8> sel[0].class Sketchup;;Drawingelement sel[0].to_s #<Sketchup;;Drawingelement;0x67e5e68> sel[0] #<Sketchup;;Drawingelement;0x67e5e68> sel[0].typename DimensionLinear
The only thing here giving an indication that it's a dimension is the typename. I thought that the dimension object would be based on the Drawingelement class. Something like DimensionLinear < Drawingelement. And then I'd expect
sel[0]
to return an object that identities itself as such. The default behaviour of classes'.to_s
are to return a string representing the class name. But maybe it isn't a subclass after all? Or maybe I'm just being really dense at the moment. (not unlikely...) -
Yea, I've noted that there isn't any exposed API for dimensions. Which is why I find it odd that we can identify dimensions elements using the
.typename
method. -
The, as yet, unstated downside of all of this is that there are virtually no methods in SUp Ruby to make or manipulate Dimensions anyway...
There has been some work over the years using a unit length dimension component that is imported and scaled in its length to suit, and then perhaps exploded. You could also do things by grouping pre-existing dims etc...
.
Advertisement