The painted_entity()
method (created by the attr_reader
call,) will return the current object that @painted_entity
is pointing at.
Did you miss what I said ? Ie:
BUT, I found another silly mistake on line 69.
Drawingelement
needs to be Sketchup::Drawingelement
(I fixed the above file, and posted example.)
After fixing, it works fine for me:
This is the console output when painting a face with a transparent textured material:
onElementModified: #<Sketchup::Face:0x000000088f9690>
front material: #<Sketchup::Material:0x000000086bb6d0>
material name : [Translucent Glass Tinted]
back material : #<Sketchup::Material:0x000000086bb6d0>
material name : [Translucent Glass Tinted]
… and painting a front face with a non-transparent textured material:
onElementModified: #<Sketchup::Face:0x0000000ec14e50>
front material: #<Sketchup::Material:0x0000000e303de8>
material name : [Carpet Berber Multi]
back material : nil
… and painting a back face with a non-transparent material:
onElementModified: #<Sketchup::Face:0x0000000e18fa98>
front material: nil
back material : #<Sketchup::Material:0x0000000de8a168>
material name : [Roofing Tile Spanish]
… and painting a group with a non-transparent textured material:
onElementModified: #<Sketchup::Group:0x0000000e301188>
front material: #<Sketchup::Material:0x0000000df622e8>
material name : [Roofing Scalloped]
Now you see the line that says:
### Notify some other code object of paint action ?
… that is where you would call some method in your other code (class instance or other module,) to either pass the references to the new entity, and it’s materials, ie:
OtherModule::notify_material_change(
@painted_entity, @material_used, @back_material_used
)