Changing multiple colours at once

Typically: "How do I... ", "How can I... " questions
Post Reply
RobAtLab
Posts: 86
Joined: 10 Jan 2018, 17:49

Changing multiple colours at once

Post by RobAtLab »

When editing "appearance of compund shapes" one finds a compoiund shape as a collection of sub shapes, and sees the "Edition of Compund Shapes" dialog box with opotions such as "adjust colour". I have some compund shapes with about 40 shape components to them. I really do not want to have to edit a colour 40 times, going into "adjust colour" for each, then "ambient/diffuse component", then fiddling the RGB or HSL for each component. Is there a way to set all shape components in a compound shape to the same colour in one go?

Thanks

coppelia
Site Admin
Posts: 8206
Joined: 14 Dec 2012, 00:25

Re: Changing multiple colours at once

Post by coppelia »

Hello,

you can use the API function simSetShapeColor and set the second argument to nil.

Cheers

RobAtLab
Posts: 86
Joined: 10 Jan 2018, 17:49

Re: Changing multiple colours at once

Post by RobAtLab »

Could you please give an example of the syntax used for that command, I'm just not entirely sure how you specify the various elements of it. Also, where is that command run from? I've written basic lua controllers for robots in V-REP, non-threaded child scripts I think, but I'm not sure how to run commands to alter my setup rather than just have a effect during a simulation.
Thanks

coppelia
Site Admin
Posts: 8206
Joined: 14 Dec 2012, 00:25

Re: Changing multiple colours at once

Post by coppelia »

You can run the code in a child script. But then you need to start simulation.
Or you can put the code inside of a customization script, attached to a dummy object. If you then add some custom UI dialog, you can make a tool that changes the color as you wish, if you have to repeat that operation often.

Finally, since V-REP V3.5.0, you can execute something like following, in the new Lua commander window at the bottom of the screen:

Code: Select all

sim.setShapeColor(sim.getObjectHandle('objectname'),nil,sim.colorcomponent_ambient,{1,0,0})
Cheers

Post Reply