Tere Posted May 31, 2021 Share Posted May 31, 2021 (edited) Hi everyone, I would like to start automating some tasks I am performing in VW using Vectorscript but am new to it. The first task I would like to automate is SELECTING ALL OBJECTS OF A CERTAIN FILL FORE COLOUR (rgb values, in this case specifically 255, 255, 204) AND CHANGING THE FILL FORE COLOUR TO DIFFERENT COLOUR (rgb values 187, 209, 96, ideally, but not necessarily also 40% opacity). It is important to perform all at once, since I want to be able to perform multiple such specific colour and line colour/weight changes all at one go. From studying tutorials and adjusting the script in 'Setting/Changing Object color' thread, this is what I have: PROCEDURE GreenUpdate; FUNCTION MakeItGreen(h :HANDLE) :BOOLEAN; VAR r, g, b :LONGINT; BEGIN GetFillBack(h,r,g,b); IF (r = 255) & (g = 255) & (b = 204) THEN SetFillBack(h,187,206,96); GetFillFore(h,r,g,b); IF (r = 255) & (g = 255) & (b = 204) THEN SetFillFore(h,187,206,96); END; BEGIN { Each object option here is set to affect all objects, on all layers, using a deep traversal} ForEachObjectInLayer(MakeItGreen,0,2,1); END; Run(GreenUpdate); The script compiles but does not do anything! I tried to delete as little from the original as possible not to mess it up.. Thanks so much for helping 🙂 Edited May 31, 2021 by Tere Quote Link to comment
JBenghiat Posted May 31, 2021 Share Posted May 31, 2021 Color is 16 bits, so the range is 0 to 65535 1 Quote Link to comment
Tere Posted May 31, 2021 Author Share Posted May 31, 2021 Thanks so much, that has now worked! Quote Link to comment
Pat Stanford Posted May 31, 2021 Share Posted May 31, 2021 On a sample file with just a few objects, add an AlrtDialog call after the GetFillBack and GetFillFore calls. AlrtDialog(Concat('Red:', r, ' Green:', g, ' Blue:', b); This will show you the values that are actually being returned for R G & B and you can then edit the IF lines to match. 1 Quote Link to comment
Tere Posted May 31, 2021 Author Share Posted May 31, 2021 Thanks a lot, will try that! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.