[Info] Allowable Classes for "set_attribute"
-
yep, vectors work too. I wonder about the other Geom classes (although transformation doesn't work, I just tried it).
--
Karen -
reminder.. that keys should be unique, in the same way that hash keys need to be unique.
If you have two Point3d objects that are
eql?
(in the Ruby sense,) ie, the 3 elements, x, y, z have the same values, (but differingobject_id
,) can they be used as separate keys for 2 separate values ?.. or will one overwrite the other's value in the dictionary ?
-
Dan,
Good point. A quick check indicates that any point with the same x,y, and z values can access the attribute.
--
Karen -
@kwalkerman said:
Good point. A quick check indicates that any point with the same x,y, and z values can access the attribute.
Karen
.. thot so.
This could be bad,.. or good, depending on what your doing. If you wanted to store some explanitory text for ANY point with certain x,y,z co-ordinates like "at the hinge point" then this feature might work ok. (Of course, nil will be returned if no such "point-key" exists in the dictionary.)
-
Dan,
For applications I can think of, this is actually an advantage, especially if you are using attributes between sessions, as the 'entity' attached to your particular point3d would be lost. AND, it works just like any other key for attributes.
string1 = "My Attribute"
string2 = "My Attribute"entity.set_attribute "a", string1, "q"
entity.get_attribute "a", string2 ==> "q"string1 and string2 are different objects, but both can reference the same attribute dictionary.
--
Karen -
Shameless bump, it would be great to add this to the online docs. (TT, if you read this...)
-
Perhaps it's worth mentioning that Point3ds and vector3ds are transformed along with the geometry they belong to when using move tool or rotate tool on it.
-
Geom::Point3d
andGeom::Vector3d
are virtual classes. Instances of them do not actually exist in any entities collection.Sketchup::Vertex
however, does have instances "in the model."Can you be more specific? (Your statement seems vague.)
-
Christina is correct, any Point3d and Vector3d stored in an Entity's attribute will be transformed along with the entity itself.
I don't have a list of what classes can be stored, I'll look into it.
-
After some tests in SU2013 I found out that these classes are not transformed when using move!, transform! or transformation= on the entity, but they are when using the move, rotate or scale tool on it.
This might be quite useful for custom animations scripts since things like rotation axes etc can be saved as attributes to the entities being transformed without be changed by the animation. When creating the mechanic parts for my railroad plugin I turned these data into normal arrays to avoid them from being transformed but perhaps that wasn't required.
-
Poking into the source here.
set_attribute
converts Ruby values into C++ types. The functions that handles it deals with the following types:True/False
Length
Integer
Float
String
Array (Containing any of the other types)
Color
Time
Point3d
Vector3dAnd if its not any of those types it appear to silently ignore it. An empty setting is written. (It'll write the key, but value will be empty.)
-
Thanks for the list!
-
Does "allowable" also mean these types are converted back into their original object types by
get_attribute
?(I know it does, but didn't see that explicitly mentioned in the topic.)
-
Yes, they should. But there might be some quirks in the underlying implementation of storage, where Windows stores to the registry and OSX saves to a plist. I think I recall some escape character issues on one of the platforms - though I don't recall the details. Might have been fixed.
-
@tt_su said:
But there might be some quirks in the underlying implementation of storage, where Windows stores to the registry and OSX saves to a plist.
We were talking about attributes, not
read_default
,write_default
. Do they act similarly? -
@jim said:
We were talking about attributes, not
read_default
,write_default
. Do they act similarly?Duh! That's just my brain not coping with the jet-lag properly. You're correct - it was read/write_default that had that issue.
...gonna go and lie down for another nap...
-
@tt_su said:
Christina is correct, any Point3d and Vector3d stored in an Entity's attribute will be transformed along with the entity itself.
What a quirky thing. Is this a side-effect of some other code, or an explicitly designed behavior? If designed, for what purpose?
-
It's explicitly coded, though the code doesn't mention the historical reason..
-
@tt_su said:
It's explicitly coded, though the code doesn't mention the historical reason..
OK now I understand what Christina was saying.
I agree with Jim. I can think of a situation, whee I'd save some point in the model (which is relative to the world origin, and I would be rather ticked if SketchUp applied a transform to MY attribute without MY permission.
How would / should SketchUp know what the value of my attribute was for ?
-
If you want to ensure the data isn't transformed, convert the Point3d or Vector3d to an array.
Advertisement