Model UVs crash when I create Dynamic component for Material change



Hey, Guys!
When I create UVs for my model using SketchUV plug-in, and apply to the model a texture with diffuse map, it workes fine.
But when create a Dynamic Component, changing materials with diffuse maps on my model, from the very first material change, UVs crash…

I’m facing this problem each time I create Material changing DC, with complex furniture models, and with simple boxes.
That’s a great roadblock for me now! Do you have any ideas how to fix it?
I use Sketchup 2017, Windows 10.


SketchUp shouldn’t crash from this. At exactly what step crashes it? Does it produce a bugsplat?


Thak you for your response! Sketchup doesn’t crash itself, but model UVs crash, I’ve created an explaining gif

My goal is to create a DC, that would change its materials with diffuse maps included.
And my problem is that Material DC UVs crash always…


Still no sign of any crash.


If you want to keep the texture positioning you can’t paint with the default material in Paint Tool as that also purges the texture positioning. The API doesn’t allow to set the texture positioning if there is no texture to the face, even though SketchUp internally allows it, which would explain why the plugin can’t load it. To remove the material without losing texture positioning you can run this in the Ruby console:

m=Sketchup.active_model;m.start_operation("Remove Materials"); m.active_entities.grep(Sketchup::Face) { |f| f.material = f.back_material = nil }; m.commit_operation


Thanks again!
Okay, so I have not to assign default material to my model. But, if I assign any other material from my scene, the Dynamic component doesn’t switch texture!
I have inserted your code to Ruby console, thanks for that a lot! it seems like the code works, but it doesn’t affect my model, here’s the gif

And here’s my file


You do need to have the default material on the faces but you cannot use the Paint Bucket tool to set the material as this also purges the texture positiong. The code snippet paints the faces with the default material without losing the texture positioning. However you need to be inside of the component for it to work.


Aha, got it.

When I insert your code into Ruby console being inside the component, my sketchup stucks and not responding anymore :((((

So, do you know, does Sketchup provide any way to make working material changing DC, when the materials include diffuse maps?

As the Dynamic Component Options window, and Interact with Dynamic Components button work outside the component only. At the same time, to be able to switch between materials they require the default material to be assigned inside the component… That default material purges UVs, and we have DC that works with a purged UVs only… It seems to be a controversion for Sketchup in this issue. But I need to create such a working DC, if it is possible…

Hope there is some way to solve it!


That is odd. I haven’t run into to any problems when using this approach. Maybe some other extension is interfering. What happens if you not use Dynamic Components but a normal component?


I have deleted DC and re-applied code. this is how it works outside the component (it used to work in the same way with my DC), but the texture hasn’t changed…

And if I apply it being inside the component, Sketchup Stops replying again…


It’s hard to tell by looking at your screenshots, but how complex is the surface of your object? If it has a large number of faces, you might have to wait quite a while for the operation to complete, especially if you don’t pass the disable_ui argument to the operation. Without this argument, the GUI attempts to redraw the screen after each change, which vastly slows down the Ruby.


Oops, my bad. Forgot the disable_ui argument. Without it it could take a minute or so to execute the code. It should however still generate the same result. Anyhow, here’s the corrected code.

m=Sketchup.active_model;m.start_operation("Remove Materials", true); m.active_entities.grep(Sketchup::Face) { |f| f.material = f.back_material = nil }; m.commit_operation


This mesh has got about 9 thousand faces. The file with it is being opened for the whole day, I only interact with it when you guys write me some suggestions. So, it is obvious for me now, that this is not a question of UI… Nothing has changed after 2 hours, for example. Besides, in render frame buffer DC materials don’t work correctly as well…

I work in a team, and we have this DC issue always when we have a task of creating material changing DC. On different machines, with different models, simple and complicated ones. This is probably the 7th model, and we still have no solution, as Sketchup always breaks UVs when we create a Material changing DC and start to switch the materials…

I think @eneroth3 has led us to the problem core:
Material changing Dynamic Component works only if the Default material is assigned inside the component. At the same time, Default material purges textures positioning and make our DC materials impossible to work correctly… That’s a big controverse.

Hum, how can we fix it… I believe there should be some solution for it.

Hahah, Thank you for the ruby code suggestion again! I’m not a programmer, and to be honest I haven’t understood what do you mean, but I interact with Ruby Console whole day today)))) Yet It hasn’t helped, Could you please explain your suggestion more detailed?

Maybe my the very first gif may show the problem in the best way


Wow, It works!!! Thank you so Much!!! The DC change materials in viewport correctly now :hugs::star_struck::slightly_smiling_face:!
But we still see the crashed texture positioning on render…


Ouch. Probably texture positioning can’t be read by the API for faces with no material (aka default material) similalry to have it cannot be set when there is no material.


you need to explode and re-group immediately to see the textures…robot0007

if you select the ‘surfaces’ you can switch to any library texture from ‘Entityl Info’…

quick example…



I didn’t know Entity Info could change material without also resetting the texture positioning. That is good to know! It can also be used to remove the material so no Ruby snippet is needed for this.

Regarding the component I would recommend to explode it right before rendering and then undo the explosion to keep the model clean and not lose data.


Thank you so much for your help!
Hope, Sketchup will fix it soon, and creating working Material changing DC will become an easy task, without tricky actions required!


Great! It works! Thanks a lot:slightly_smiling_face:!!! It is a nice partial solution for us!

Our task requires a creation of such working DC, working both in render and viewport, with no additional actions (like an explosion). It seems to be now Sketchup soft limitation doesn’t allow us to do that… So we’ll follow your advice for sure! And will search how to create such sort of DC fitting our requirements…


Btw, you really don’t need Dynamic Components for this. If you use normal components you can assign any material you want to at any time, not just those included in the Dynamic Component.