Jump to content
Tere

Changing pen thickness to object of a specific colour

Recommended Posts

Hi everyone, I need to write a script that finds all objects with a specific RGB fill, and for these objects sets a specific pen thickness (like an outline).

 

Below is my first attempt and attached what it says the errors are. Thanks a lot for helping!

 

PROCEDURE LWUpdate;


FUNCTION ChangeThickness(h :HANDLE) :BOOLEAN;

    CONST { substitute these with the required values }
    ToLW = 0.35; {mm}
    
    VAR
    r, g, b :LONGINT;
    VToLW:REAL;

    BEGIN

        GetFillBack(h,r,g,b);

        IF (r = 34952) & (g = 34952) & (b = 34952) THEN

            SETLW(h, VToLW);
                    
        GetFillFore(h,r,g,b);

        IF (r = 34952) & (g = 34952) & (b = 34952) THEN

            SETLW(h, VToLW);

        
    END;


BEGIN

    { Each object option here is set to affect all objects, on all layers, using a deep traversal}
    VToLW := ToLW / 25.4 * 1000;
    ForEachObjectInLayer(ChangeThickness,0,2,1);

END;


Run(LWUpdate);

Screenshot 2021-06-10 at 20.12.09.png

Share this post


Link to post

Your errors are because of the scope of the declaration of the constant ToLW and the variable VToLW.

They are declared within the function ChangeThickness and are therefore not visible in the main procedure of LWUpdate. Try the following which moves those outside the ChangeThickness function.

ROCEDURE LWUpdate;

CONST { substitute these with the required values }
    ToLW = 0.35; {mm}

VAR 
	VToLW:REAL;

FUNCTION ChangeThickness(h :HANDLE) :BOOLEAN;
   
    
    VAR
    r, g, b :LONGINT;
    
    BEGIN
        GetFillBack(h,r,g,b);
        IF (r = 34952) & (g = 34952) & (b = 34952) THEN
            SETLW(h, VToLW);
                    
        GetFillFore(h,r,g,b);
        IF (r = 34952) & (g = 34952) & (b = 34952) THEN
            SETLW(h, VToLW);
        
    END;

BEGIN
    { Each object option here is set to affect all objects, on all layers, using a deep traversal}
    VToLW := ToLW / 25.4 * 1000;
    ForEachObjectInLayer(ChangeThickness,0,2,1);
END;

Run(LWUpdate);

 

  • Like 1

Share this post


Link to post

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.


 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...