[Feature request] random color for parts/bodies

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
pablogil
Posts: 729
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

[Feature request] random color for parts/bodies

Postby pablogil » Thu Aug 03, 2017 11:35 pm

I wonder if you like the idea of a setting that, instead the default part/body color, mark a "random color" option so that each new part/body you create as a different random color which will make pretty easy to differ between different parts/bodies...

what do you think?
Thanks
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
jouke
Posts: 16
Joined: Mon May 08, 2017 10:52 am

Re: [Feature request] random color for parts/bodies

Postby jouke » Mon Oct 30, 2017 10:24 am

I'd like this !
User avatar
Kunda1
Posts: 4755
Joined: Thu Jan 05, 2017 9:03 pm

Re: [Feature request] random color for parts/bodies

Postby Kunda1 » Tue Oct 31, 2017 7:41 pm

Like what is mentioned in issue #2725 ?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
pablogil
Posts: 729
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: [Feature request] random color for parts/bodies

Postby pablogil » Tue Oct 31, 2017 9:34 pm

Kunda1 wrote:
Tue Oct 31, 2017 7:41 pm
Like what is mentioned in issue #2725 ?
Yes and no:
Yes because it that feature is broken in 0.17 I would like to have it solved.
No because what I meant was to have that feature but in "auto mode", that is, if you have ON that Preference parameter whenever you create a new shape/volume element it won't take the default Colorado but a random one. That way it won't be necessary to run sometimes the "random colours"...
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
User avatar
dulouie
Posts: 71
Joined: Tue Oct 03, 2017 4:14 pm

Re: [Feature request] random color for parts/bodies

Postby dulouie » Thu Nov 02, 2017 6:08 pm

thumbs up! i had the same idea..
User avatar
Kunda1
Posts: 4755
Joined: Thu Jan 05, 2017 9:03 pm

Re: [Feature request] random color for parts/bodies

Postby Kunda1 » Fri Nov 03, 2017 1:17 pm

probably open a ticket to track this an then and link #issue #2725 to it
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
dulouie
Posts: 71
Joined: Tue Oct 03, 2017 4:14 pm

Re: [Feature request] random color for parts/bodies

Postby dulouie » Mon Nov 27, 2017 9:06 pm

I have done some coding and finally it works.
Basically i want to edit the constructor in ViewProviderBody.cpp with a method like:

Code: Select all

ShapeColor.setValue ( 50.f/255, 150.f/255, 250.f/255 );
But it dosen't work, the programm terminated with segmentation fault.
This annoying me because ShapeColor.getValue() works well. Can someone explain me why?

So i edited the CommandBody.cpp with an python cmd:

Code: Select all

// random shapecolor
    float fMax = (float)RAND_MAX;
    float fRed = (float)rand()/fMax;
    float fGrn = (float)rand()/fMax;
    float fBlu = (float)rand()/fMax;
    doCommand(Gui, "Gui.activeDocument().getObject(\"%s\").ShapeColor=(%.2f,%.2f,%.2f)",bodyName.c_str() , fRed, fGrn, fBlu);
And this works fine:)
Are there any suggestions or any chance for a PR?
https://github.com/dulouie/FreeCAD/tree/randombodycolor
User avatar
Kunda1
Posts: 4755
Joined: Thu Jan 05, 2017 9:03 pm

Re: [Feature request] random color for parts/bodies

Postby Kunda1 » Mon Feb 05, 2018 4:44 pm

dulouie wrote:
Mon Nov 27, 2017 9:06 pm
Are there any suggestions or any chance for a PR?
https://github.com/dulouie/FreeCAD/tree/randombodycolor
Could you please rebase? Could you also show it working with a screencast or animated gif ?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
dulouie
Posts: 71
Joined: Tue Oct 03, 2017 4:14 pm

Re: [Feature request] random color for parts/bodies

Postby dulouie » Tue Feb 06, 2018 4:22 pm

the branch is up to date.

phpBB [video]
User avatar
Kunda1
Posts: 4755
Joined: Thu Jan 05, 2017 9:03 pm

Re: [Feature request] random color for parts/bodies

Postby Kunda1 » Tue Feb 06, 2018 6:07 pm

This is cool. It would be nice if there was an option in the settings to activate/deactivate this feature per preference.
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features