Vertices and selection
-
I am sure someone else has this figured out already: How can I move a vertex with Ruby? The transform! method is not available with a vertex, otherwise this should work:
vertices[0].transform! transformation
Also, is it possible to select an object by its ID?
Cheers,
Alex -
Are you speaking in terms of selecting vertices rather than faces or edges? If so, you might note that ThomThom is working on a script with vertices as a selection set.
-
I saw thomthom's plugin but what he does is way beyond what I want to do. I just want to address an object (edge, face, vertex) by ID (not by clicking!) and then transform it.
Cheers,
Alex -
Alex,
You can transform vertices by using Entities.transform_entities method.
There is no built in way to get at something by id. You could populate a hash yourself, though. Something like...
entities_by_id = {} some_id = nil for ent in Sketchup.active_model.entities entities_by_id[ent.entityID.to_s] = ent some_id = ent.entityID.to_s end # And then get back to stuff like this my_last_ent = entities_by_id[some_id]
Cheers,
-
As Scott said,
Entities.transform_entities
, or byEntities.transform_by_vectors
.Entities.transform_entities
is good when you have one transformation you want to apply to all entities.Entities.transform_by_vectors
is good when you want to transform a set entities each differently.@alexschreyer said:
I am sure someone else has this figured out already: How can I move a vertex with Ruby? The transform! method is not available with a vertex, otherwise this should work:
For Vertices, Edges and Faces you tell the containing Entities collection to perform the transformation.
Only Groups and ComponentInstances has .transform! methods which can be used directly on the object.@alexschreyer said:
Also, is it possible to select an object by its ID?
You mean
entity.entityID
? Or some other form of identification?
Maybe this could be better answered if you described the scenario you want to solve? -
Thanks Thom and Scott for the suggestions. I'll try it out later today.
@thomthom said:
You mean
entity.entityID
? Or some other form of identification?
Maybe this could be better answered if you described the scenario you want to solve?The scenario would be to have a model with nothing selected. The script would then select an entity and apply a transformation based on me giving it some ID. This is easy if I select by type (e.g. "all faces") and apply the transformation on all of them but I am wondering if I can do it with an individual selection by ID.
Cheers,
Alex -
I'm still confused to exactly what this ID is.
How are you determining which entity to transform?
From a user perspective, what would you do?
-
What kind of "ID" do you mean Alex? Entities have ID's associated with them, but they are not kept from session to session. So if you make a hash of ID's and then save them to reuse, you will have to rebuild it to match your saved list of hashes each time. That is the only way ID's seem like they would really help you. And from what I hear, that adds a LOT of size to the skp file, because you have to tag each entity that you are tracking with your own ID to match back to your database.
Chris
-
Thanks for the replies. I'll have to get back to this later, so please don't think I am ignoring you...
Cheers,
Alex
Advertisement