I am doing code like this…
def material_name comp
ents=comp[0].definition.entities
ents.each do |e|
if e.is_a? (Sketchup::ComponentInstance)
puts e.material.map{|x| x.name}
end
end
end
material_name Sketchup.active_model.selection
I am doing code like this…
def material_name comp
ents=comp[0].definition.entities
ents.each do |e|
if e.is_a? (Sketchup::ComponentInstance)
puts e.material.map{|x| x.name}
end
end
end
material_name Sketchup.active_model.selection
You need to write the code inside of triple backticks for it to be readable.
```
Code goes here…
```
To change the name of an instance’s material’s nam you can do something like this:
instance.material.name = "New Name"
thank you
When a method definition (def
) does not work, try to decompose it and run it in tiny small steps:
comp = Sketchup.active_model.selection
ents=comp[0].definition.entities
e = ents[0]
e = ents.find{ |entity| if entity.is_a?(Sketchup::ComponentInstance) }
puts e.material.map{|x| x.name}
puts e.material