Purge Unused + Fix Problems

Hi all,
I want to “click” these two buttons with ruby. I found that for the “purge unused” I probably need the following commands but I can’t find the command(s) for the “fix problems”. In the “validity check”. What I want is not to just check, but also silently fix the problems.

layers = Sketchup.active_model.layers
status = layers.purge_unused
materials = Sketchup.active_model.materials
definitions = Sketchup.active_model.definitions
styles = Sketchup.active_model.styles


I don’t think there is a way to silently fix the errors. Would be useful though for plugins that cause errors when modifying geometry.

Regarding purging you need to purge definitions before layers and materials since definitions can contain the other two.

1 Like

is the only one I know…



I didn’t know of the Test module. Seems like you can do some strange stuff with it!

It is an undocumented module Trimble uses for testing. It is not intended for end users and not guaranteed safe. But ruby hackers found it a long time ago, so it is a sort of ill- kept secret.


Great, thanks @eneroth3. I’ll change the order then.
Thanks @john_drivenupthewall! Much appreciated!

A bit out of topic, but do you happen to know how I can also set the *.3ds filetype properties?
The documentation only shows PDF and DAE.

Alas, most of the exporters do not expose options through the Ruby API.

1 Like

thanks for the reply. :slight_smile:
pff that’s annoying… :confused:

Cross-Platform action strings:

Sketchup::send_action("fixNonPlanarFaces:") # may apply to selection set, so Test

PC ONLY numerical automation IDs:

Sketchup::send_action(21124) # launch the validity check tool
# ... will always display the modal results dialog needing to be dismissed by user

Please don’t use the Test module - nor recommend anyone to use it. It is very VERY internal!

1 Like

But playing with fire is exciting!



Actually Test is a Standard Ruby Library module and so public, but is really only a namespace wrapper for other submodules or classes.

Y’all should have created your own Sketchup::Test module (or nested Test::Sketchup sub-module,) which could have been undefined in the public API release.

… OR the module could be implemented as a licensed extension that only team members have a license to.

1 Like

@tt_su, expose :repair_model in the API and we won’t need to use it or a :send_action [ which you equally despise ]…



Test.time_display does an axis rotation animation, followed by a dialog box. On my computer the dialog box says 72 frames in 1.1963 seconds.

“Test.CorruptModel” and “Test.eat_mem” look scary and I will stay away from them.

Thanks @DanRathbun :slight_smile:

1 Like

Yea, that name wasn’t ideal. It was done before SketchUp shipped with StdLib.
Since it’s internal only - we should be good to rename it. I’ll log an issue.


Stop poking the Test module!


1 Like

Logged as SU-38058.

Logged as SU-38059


I first thought the GIF was a reference Test.time_display with the camera rotating around the actor.

1 Like