Tere Posted June 10, 2021 Share Posted June 10, 2021 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); Quote Link to comment
Vectorworks, Inc Employee Judah Warshaw Posted June 10, 2021 Vectorworks, Inc Employee Share Posted June 10, 2021 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); 1 Quote Link to comment
Tere Posted June 10, 2021 Author Share Posted June 10, 2021 Thanks a lot, that now works!! 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.