Print at Dec 19, 2025, 4:17:14 PM
Posted by digitaltrails at Jan 7, 2016, 9:46:06 AM
Change color plugin
I've been trying to experiment with wall, floor, and furniture colors for a renovation. I got into a bit of a muddle over the assignment of colors to various walls and furniture items. This motivated me to write a plugin that could find where a color had been used and change it.

The ChangeColor plugin provides a dialog with two standard Java Swing color choosers, one for selecting a from-color, and another for selecting a to-color. The standard Swing choosers have been enhanced to include an extra tab for "Colors in use." The Colors-in-use tab displays a swatch for each color used in the model. Each color in-use swatch includes a hover tooltip that lists where the color is used.

Here is a screen shot where the top chooser shows the "Colors in use" tab with an active hover showing where color #E2D3DF is bing used. The bottom chooser is on the RGB tab, where E2E7BE is selected to replace E2D3DF.



Note that undo has not yet been implemented and I only wrote the plugin today. You should back up a copy of your model before using this plugin to make any changes.

I find the plugin quite helpful for temporarily changing a color to some other quite different and unique color, it then becomes quite apparent which walls and items do or don't have the right colors applied.

The plugin has been uploaded to

https://sourceforge.net/p/sweethome3d/plug-ins/14/

Installation is as per normal.

Future work might including implementing undo, but I'm not sure when I'll find the time. If anyone else would like to have a go at enhancing the plugin, the code base is relatively small.

Please remember to backup a copy of your model before playing with this plugin.

Posted by hansmex at Jan 7, 2016, 3:36:56 PM
Re: Change color plugin
A few minutes ago, I installed your plug-in. Although it appears and seems to function, I'm not sure it actually does what you describe.

The tab Colors in use gives small rectangles where the borders have the colours in use (but which are not filled with that colour as in your image).

In the lower half the rectangles are present (without fill) and colours can be changed. However, the colours are not applied to the model(s), and there is no Apply button to execute the changes you make.

Maybe I'm doing something wrong? Maybe the plug-in is a bit too much in beta stage?

I'm using a computer with Windows 10 64 bits and SH3D v5.1 64 bits.

Hans
----------------------------------------
Hans

new website - under constuction
hansdirkse.info

Posted by digitaltrails at Jan 8, 2016, 4:18:39 AM
Re: Change color plugin
If you look at the screen shot in the original post, there is a very wide "Apply" button along the whole bottom of the panel labelled Replace from color with to color on matching items - I guess it's not obvious its a button. I need to put a bit more work into the interface, but I thought I'd release it now as I'm unsure of how much free time I will have in coming weeks).

I'm not sure why you aren't seeing the Colors in use filled swatches. It could be a paint/refresh issue, or it may be a Java version/platform issue. Perhaps try clicking on the tab twice - I did have a paint/refresh bug, but I thought I had fixed it, before the fix I had to click twice to get the swatches to appear, but what you are seeing is different, so there may be another bug/issue.

A few minutes ago, I installed your plug-in. Although it appears and seems to function, I'm not sure it actually does what you describe.

The tab Colors in use gives small rectangles where the borders have the colours in use (but which are not filled with that colour as in your image).

In the lower half the rectangles are present (without fill) and colours can be changed. However, the colours are not applied to the model(s), and there is no Apply button to execute the changes you make.

Maybe I'm doing something wrong? Maybe the plug-in is a bit too much in beta stage?

I'm using a computer with Windows 10 64 bits and SH3D v5.1 64 bits.

Hans


Posted by digitaltrails at Jan 8, 2016, 5:47:52 AM
Re: Change color plugin
I've found one bug. The plugin can't change a color if it is the color of a material and it's the default material color. If you have already changed the material's color to something other than the default, the plugin will work.

I have a fix for this bug and will release it in the next few hours once I have tested it a bit more. The fix is to compare colors without the alpha component (only comparing RGB values). I should probably copy the alpha (transparency) from the from as well.

I should add I'm using OpenSuse Linux 13.1 64 bit and SH3D v5.1 64 bit with the JRE it was shipped with.

I'm using Java JDK 1.7 for development but the compiler is set to 1.6 compliance.

Posted by hansmex at Jan 8, 2016, 6:25:11 AM
Re: Change color plugin
Michael,

1 - Oops. Indeed, there is a very large button at the bottom of the window. I hadn't recognized it as such. It works.
2 - Double-clicking doesn't change the swatches from outline to filled.
3 - Original colours can't be changed, just as you said.

Very nice plug-in. Thanks!

Hans
----------------------------------------
Hans

new website - under constuction
hansdirkse.info

Posted by digitaltrails at Jan 8, 2016, 10:06:06 AM
Re: Change color plugin
Hans,
thanks for the quick feedback, most helpful.

I've uploaded a new version with two fixes:

  • The plugin now correct alters colors for items with materials where the material is set to its default color.
  • I've set the opacity of the Colors-in-use swatch buttons in an an item in an attempt to fix the lack off fill color in Windows 10.

Note that the version number changed on the jar, so you will need to removed the 0.1 jar and replace it with the 0.2 jar.

The fix for Windows 10 is a guess based on searching for the symptoms using Google (swing button color issues, as is usual for coding problems, I wound up at http://stackoverflow.com/ ). I don't have a Windows 10 system to test this on. It doesn't seem to cause any issues on my Linux system.

I've noticed that the color alpha values (transparency) seem to be ignored, I guess they're part of the model, not the color. I dropped alpha when making comparisons because the default colors didn't seem to have an alpha value. I was going to attempt to change/preserve alpha values, but this didn't seem to do anything useful - my glass doors stayed transparent and my opaque items stayed opaque no mater what the color alpha was set to.

Posted by hansmex at Jan 8, 2016, 10:39:22 AM
Re: Change color plugin
Michael,

Thanks for the update.
1 - The original colour is now changed. Good work!
2 - It seems the box that lists where the selected colour is used has disappeared. Or maybe I'm using it the wrong way? Selectively blind?
3 - The swatches are still outlines without fill.

Hans
----------------------------------------
Hans

new website - under constuction
hansdirkse.info

Posted by hobbyrv at Jan 8, 2016, 11:32:04 AM
Re: Change color plugin
When I download the attachment ChangeColorPlugin-0 or 1.1.jar I can't open it. Are there special requirements to do that? How can I open it?

Posted by hansmex at Jan 8, 2016, 11:56:35 AM
Re: Change color plugin
Please, read Adding plug-ins in the User's Guide.
----------------------------------------
Hans

new website - under constuction
hansdirkse.info

Posted by digitaltrails at Jan 9, 2016, 9:38:38 AM
Re: Change color plugin
Hans,

The box that lists where colors are used is a tooltip. The tooltips only pop up if you hover the mouse over a swatch. This was the quickest way I could think to implement this feature. Perhaps it would be good to also display a permanent panel to the right listing where the colors are used for the currently selected swatch (if any).

Hopefully hovering works for you, otherwise it could be that my opacity change is producing some new Windows 10 issue.

It seems Swing button fill is very platform dependent in behaviour. I will look into a more sure file way to create a swatch/button filled with color. Perhaps by embedding an rectangular colored icon. I will look into this when I have some spare time over the next few days.

Thanks again for the feedback.

Michael,

Thanks for the update.
1 - The original colour is now changed. Good work!
2 - It seems the box that lists where the selected colour is used has disappeared. Or maybe I'm using it the wrong way? Selectively blind?
3 - The swatches are still outlines without fill.

Hans


Posted by hansmex at Jan 9, 2016, 3:18:59 PM
Re: Change color plugin
Michael,

Maybe making the border of the swatch thicker might (partially) solve the problem. The coloured line is now rather thin, making it hard to see the colour.

Hovering is fine, I'll just have to get used to it.

H
----------------------------------------
Hans

new website - under constuction
hansdirkse.info

Posted by digitaltrails at Jan 11, 2016, 9:06:45 AM
Re: Change color plugin new version (v0.3)
I've revised the ChangeColor plugin UI (see the attached screen shot).

Undo is still unimplemented, I would still advise you to backup your models before using this plugin.

The version number has changed from 0.2 to 0.3, so you will need to remove the old jar and replace it with the new one. I've uploaded the jar to the normal place: https://sourceforge.net/p/sweethome3d/plug-ins/14/

Changes:

  • Swatch buttons on the Colors-in-use tab might now fill with color on all platforms (maybe).
  • A list of items using the selected color is displayed to the right of each chooser and updates when a color is selected (this is in addition to the hover tool tip)
  • A count of the matching items of each type is displayed in the list of items and in the tooltips.
  • On applying a change, the to-color becomes the new from-color.. This allows for repeated attempts to pick the right color.
  • I fixed a bug where if an a material had a texture, but the material also had a default color, then the plugin attempted to change the color.



Posted by hansmex at Jan 11, 2016, 2:13:53 PM
Re: Change color plugin new version (v0.3)
Michael,

Success!!
- Swatches now work perfectly.
- There are two new windows/lists that show where the selected color is used.
- Changing un unchanged colour also works.

Great work! Thank you very much for this nice plug-in.

Hans
----------------------------------------
Hans

new website - under constuction
hansdirkse.info

Posted by okh at Jan 11, 2016, 2:50:05 PM
Re: Change color plugin new version (v0.3)
Indeed, very nice. One to keep. And to help find those annoying different shades. Thanks! ok

Posted by Puybaret at Jan 11, 2016, 3:32:14 PM
Re: Change color plugin new version (v0.3)
Thanks for this plugin smile
It would be nice to program undo/redo. It's really not difficult to implement and you'll find plenty of examples in Sweet Home 3D source code, mainly in PlanController class. Once you retrieved the UndoableEditSupport instance with getUndoableEditSupport(), you just have to create an instance of AbstractUndoableEdit, overriding its undo, redo and getPresentationName methods, and finally call postEdit.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator

Posted by digitaltrails at Jan 11, 2016, 6:42:32 PM
Re: Change color plugin new version (v0.3)
I do intend to implement undo. I was going to spend some time looking for examples. Thanks for pointing me in the right direction.

Thanks for this plugin smile
It would be nice to program undo/redo. It's really not difficult to implement and you'll find plenty of examples in Sweet Home 3D source code, mainly in PlanController class. Once you retrieved the UndoableEditSupport instance with getUndoableEditSupport(), you just have to create an instance of AbstractUndoableEdit, overriding its undo, redo and getPresentationName methods, and finally call postEdit.


Posted by digitaltrails at Jan 12, 2016, 9:45:30 AM
Re: Change color plugin new version (v0.3)
I've implemented undo/redo and uploaded version 1.0 to https://sourceforge.net/p/sweethome3d/plug-ins/14/

I would still advise taking a backup copy of any model before making bulk changes (this code is very new and undetected bugs are always possible).

Thanks again for the info.

Thanks for this plugin smile
It would be nice to program undo/redo. It's really not difficult to implement and you'll find plenty of examples in Sweet Home 3D source code, mainly in PlanController class. Once you retrieved the UndoableEditSupport instance with getUndoableEditSupport(), you just have to create an instance of AbstractUndoableEdit, overriding its undo, redo and getPresentationName methods, and finally call postEdit.


Posted by hansmex at Jan 12, 2016, 10:25:42 AM
Re: Change color plugin new version (v0.3)
Thank you once again.
Undo works nicely, also 2-3 steps back.
I tested with v5.2 b1 under W10.

H
----------------------------------------
Hans

new website - under constuction
hansdirkse.info

Posted by digitaltrails at Mar 3, 2016, 8:04:12 PM
Re: Change color plugin - broken in v5.2
I've just upgraded to v5.2 and colours changed with the plugin in a model saved with v5.1 seem to be being converted to invisible. Using the plugin in v5.2 seems to incorrectly set the changed colour to invisible (tested on "kitchen island" "Cupboard-units"). The plugin must not be changing the colour in a way that is forward compatible with v5.2. I will try to find time to investigate further.

Posted by Puybaret at Mar 3, 2016, 9:53:16 PM
Re: Change color plugin - broken in v5.2
When the new Invisible radio button is selected, I set the alpha value of the color to 0, and I use this nul alpha to hide some parts in 3D. As all color values in Sweet Home 3D were set with an alpha equal to 0xFF, I didn't think this way of doing could cause any side effect, except you probably handled colors differently. sad
That could explain some reports I received about items becoming invisible when a white color is set. Would that wrong color come from a setting of your plugin?
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator

Posted by digitaltrails at Mar 4, 2016, 3:29:28 AM
Re: Change color plugin - broken in v5.2
The plugin code is removing the alpha when comparing colours, which isn't a problem. But its also removing the alpha when changing them - this is causing the issue I'm seeing.

Looking at the code, it seems I was originally concerned about preserving the destination's original alpha. Only if the new colour has a non 0xFF alpha, should the new alpha be used). I had disabled this as extraneous.

I've fixed the code, and re-enabled alpha preservation of the destinations original alpha. So far it looks good. Once I've done some more testing I'll put up a new version.

Posted by digitaltrails at Mar 4, 2016, 8:08:48 AM
Re: Change color plugin - broken in v5.2
I put up a fixed version 1.1 of the Change Color Plugin at sourceforge:

https://sourceforge.net/p/sweethome3d/plug-ins/14/#9ea3

The plugin now preserves the existing alpha (transparency) of an item's colour. This means that visible things should stay visible.

I also added a special case to restore the alpha of item's broken by the bug. If a colour is changed to itself, the alpha is set to the alpha of the new colour (which is always FF). So I made all my kitchen cabinets visible again by changing colour #E5E4DB to the same colour #E5E4DB. (Manually un-setting invisible causes the colour to be lost).

Lastly, I fixed a bug where the plugin was failing to detect when a texture was present (if a texture is present it overrides colour).