rosebud5 Posted May 17, 2018 Share Posted May 17, 2018 Hi, Pat helped me with this script and it is working great! What about if I wanted to add a fill to the script with a specific color, for example rectangle with same red fill and black outline. < PROCEDURE LineWeightChange; { (c) twk based off of original code by Petri Sakkinen 2008 } CONST newWeight = 5; PROCEDURE ChangeIt (h : HANDLE); VAR oldLW : INTEGER; BEGIN oldLW := GetLW(h); IF (oldLW = 2) OR (oldLW = 5) OR (oldLW = 7) OR (oldLW = 10) OR (oldLW = 14) OR (oldLW = 20) THEN Begin SetLW(h, newWeight); SetPenFore(h, 65535,0,0); End; END; BEGIN FOREACHOBJECT(ChangeIt, ((SEL=TRUE))); END; RUN(LineWeightChange); Quote Link to comment
Miguel Barrera Posted May 20, 2018 Share Posted May 20, 2018 You will need to add the following 2 procedures after SetPenFore(h, 65535,0,0): SetFPat(h,1); SetFillBack(h, 65535, 0, 0); {Red fill color} If you need to find the RGB color value other than red, create a rectangle with the attributes that you want in a blank document. Export the file to Vectorscript and you will find in this text file that the attributes are listed prior to the creation of the rectangle. Quote Link to comment
Pat Stanford Posted May 21, 2018 Share Posted May 21, 2018 Alternatively, select an item in the drawing with the fill colors you want and run this script. Procedure GetRGB; {May 21, 2018} {© 2018 Patrick Stanford pat@coviana.com} {Licensed under the GNU Lesser General Public License} Var R1, G1, B1: Real; Begin GetFillBack(FSActLayer, R1,G1,B1); PtDialog3D('RGB Fill Values of selected object are:', Num2Str(0,R1),Num2Str(0,G1),Num2Str(0,B1),R1,G1,B1); End; Run(GetRGB); Quote Link to comment
rosebud5 Posted May 22, 2018 Author Share Posted May 22, 2018 Thank you both! what about it I want to do a transparent fill? Quote Link to comment
Pat Stanford Posted May 22, 2018 Share Posted May 22, 2018 I believe transparent is SetFPat(H1,0) [zero] For SetFPat, I believe (have to test every time, I can never completely remember) that positive values use the Patterns and negative values use the Hatches. Zero is No Fill and One is Solid fill. You need to be careful with Hatches as the index will change from file to file. Quote Link to comment
rosebud5 Posted May 22, 2018 Author Share Posted May 22, 2018 Thanks, so... If I want to get rid of the line weight and just have a transparent fill of black, can I get rid of the top part of the script? " { (c) twk based off of original code by Petri Sakkinen 2008 } CONST newWeight = 10; PROCEDURE ChangeIt (h : HANDLE); VAR oldLW : INTEGER; BEGIN oldLW := GetLW(h); IF (oldLW = 2) OR (oldLW = 5) OR (oldLW = 7) OR (oldLW = 10) OR (oldLW = 14) OR (oldLW = 20) THEN SetLW(h, newWeight); SetPenFore(h, 0,0,0); SetFPat(H1,0) [zero]; SetFillBack(h,0,0,0); END; BEGIN FOREACHOBJECT(ChangeIt, ((SEL=TRUE))); END; RUN(LineWeightChange); Quote Link to comment
MullinRJ Posted May 22, 2018 Share Posted May 22, 2018 1 hour ago, Pat Stanford said: Zero is No Fill and One is Solid fill. You must also be careful here, too. SetFPat { FILL Pattern } 0 = No Fill 1 = Solid Fill using the BACKGROUND color { VW uses this as the default for SOLID FILL } 2 = Solid Fill using the FOREGROUND color In contrast: SetLS { LINE STYLE, the equivalent of the Pen's Pattern } 0 = No Pen 1 = Solid PEN STYLE (pattern) using the BACKGROUND color 2 = Solid PEN STYLE (pattern) using the FOREGROUND color { VW uses this as the default for SOLID PEN } And then there is that negative value thing to contend with, too. Good luck with all of this, Raymond (Make it confusing once, and it stays confusing forever. I wish I knew who to thank for this 😉 ) 1 Quote Link to comment
Pat Stanford Posted May 22, 2018 Share Posted May 22, 2018 You have to match the variable name for the handle to what you are using so the line would actually be: SetFPat(h,0); the [zero] was just a make sure you realized it was a number and not a letter. BUT I don't think this will do what you want. You are now saying you want a "Transparent Fill of Black". What I have given you is a line to generate an object with No Fill which is what I think of as a "transparent" fill. It now sounds more like you want to set the opacity. This will let you be able to see through a filled object. SetFPat(h,2); SetFBack(h,65535,65535,65535); SetOpacity(h,50); This should give you an object with a a black fill 50% opacity. Quote Link to comment
Pat Stanford Posted May 22, 2018 Share Posted May 22, 2018 Thank you Raymond. Very clear and concise. I like it. I also try to make sure that these types of idiosyncrasies get documented here so we don't all have to relearn it every time. Quote Link to comment
rosebud5 Posted May 22, 2018 Author Share Posted May 22, 2018 outstanding, in the script, I had to use 'SetFillBack' rather than 'SetFBack', why is that Quote Link to comment
Miguel Barrera Posted May 22, 2018 Share Posted May 22, 2018 it should actually be SetFillBack(h,0,0,0) for black color. You also need to be careful with the scope of the IF statement. The IF statement should be formatted as: IF (oldLW = 2) OR (oldLW = 5) OR (oldLW = 7) OR (oldLW = 10) OR (oldLW = 14) OR (oldLW = 20) THEN BEGIN SetFPat(h,1); SetFillBack(h,0,0,0); SetOpacity(h,50); END; The BEGIN and END calls are required to mark the start and end of the IF statement. Otherwise if you omit it as shown in your previous script: IF (oldLW = 2) OR (oldLW = 5) OR (oldLW = 7) OR (oldLW = 10) OR (oldLW = 14) OR (oldLW = 20) THEN SetLW(h, newWeight); SetPenFore(h, 0,0,0); SetFPat(H1,0) [zero]; SetFillBack(h,0,0,0); Only the SetLW procedure will be executed under the IF statement. All the other procedures following will be executed for all objects. Quote Link to comment
MullinRJ Posted May 22, 2018 Share Posted May 22, 2018 (edited) Quote in the script, I had to use 'SetFillBack' rather than 'SetFBack', why is that SetFillBack() is the call to edit a single object's background color. There is no SetFBack call, it was a typo. These calls are all documented in the Script Function Reference. If this were still a book printed on paper, you'd carry it with you everywhere, Consider it the VW Programmer's Bible. HTH, Raymond PS - Pat, thank you for the compliment. Also, in your previous example you set the Fill BG color to WHITE. Shouldn't it be set to BLACK? SetFBack(h, 0, 0, 0); Edited May 22, 2018 by MullinRJ Answer the question asked, and not the one I mistakenly read. Quote Link to comment
Miguel Barrera Posted May 22, 2018 Share Posted May 22, 2018 You can also find the function reference at http://developer.vectorworks.net/index.php/VS:Function_Reference for the correct spelling if you have not memorized all of them. 😉 Quote Link to comment
Pat Stanford Posted May 23, 2018 Share Posted May 23, 2018 Both Raymond and Miguel are correct for Black you want the absence of all colors, so 0,0,0 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.