Selected entity question
-
Short question.
Is:Sketchup.active_model.active_entities[0]the selected entity?
-
No, these are the entities in the open group or component instance.
You want:
Sketchup.active_model.selection[0]Class: Sketchup::Selection
A set of the currently selected drawing elements.
SketchUp Ruby API Documentation (ruby.sketchup.com)
-
Thanks. That was what I suspected.
Now I need to find a way to do what I want to do from the selection.
A side question. What about getting the selected material?
Sketchup.active_model.materials[0] won’t do it then either I guess? -
That would be Sketchup.active_model.materials.current
-
That method gives you the current 'active' material in the model.
But... if you want to get a material from the currently selected entity, then you use:mat = Sketchup.active_model.selection[0].materialHowever, you might be better off filtering the selection, until you get an entity of the kind you want... e.g.
face = Sketchup.active_model.selection.grep(Sketchup;;Face)[0] mat = nil mat = face.material if faceWhere the first face in the selection returns its material, or nil...
-
Thanks, I read in a older post somewhere, and I think it was by Thomthom, that there was a bug that could Bugsplat SU when using materials.current if there wasn't any materials in SU. Do you know if that still is an issue or if it has been fixed?
-
Why do you need to get the
model.materials.current?
You could pre-set it usingmodel.materials.current = a_material
Having previously seta_material = model.materials["A_Name"]You haven't really explained the full context......
-
They are just for two small snippets that I will need some advise from Thomasz (Thea settings) to make them properly.
I'm just preparing for when he will have some time to look into it...
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register LoginAdvertisement