Jump to content
Developer Wiki and Function Reference Links ×

Automatically selecting objects AND changing colour


Tere

Recommended Posts

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 by Tere
Link to comment

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.

  • Like 1
Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...