avictorgm Posted November 13, 2018 Share Posted November 13, 2018 (edited) import vs X1 = -3000 Y1 = -1500 vs.DSelectAll() vs.MoveTo(X1,Y1+18.5) #Move the pointer to vs.PenSize(10) #outside line of the box def Texto(): vs.TextRotate(271) vs.TextSize(12) vs.TextJust(1) #Left 1, Center 2, Right 3 vs.TextVerticalAlign(3) #Leading / space, Constant Single space 2 ,1 1/2 3 , Double space 4 #colorIndex = vs.RGBToColorIndex(1, 45, 23) #vs.TextBack(colorIndex) # using Color Index values #vs.OpacityN(100, 100) #vs.OpacityN(fillOpacity symbol include, penOpacity) #vs.PenSize(24) # DEFINIR GROSOR DE LINEA EXTERIOR DE RECTANGULO # 1 = 0,03 # X = 0,025 * X # 8 = 0,20 # 24 = 0,6 #vs.SetStaticTextStyle(3) vs.TextFont(vs.GetFontID('Times')) #vs.TextStyle(3) #vs.FillPat(1) #vs.FillBack(126) vs.PenPat(1) # Change for the document vs.FillBack(7) # Change background color for the document but not of the text vs.PenFore(120,0,0) #Change text color of fixed text to Purple vs.FillPat(53) vs.PenBack(0,255,0) #vs.FillPat(1) #vs.FillFore(0,0,255) # Blue Texto() h = vs.CreateText(str("Motor ") + str(X1) + str(", ") + str(Y1)) # -1 = linienart # 0 = linea invisible o vacia / Leer # 1 = solid # 2 = ? # 3 = muster / estampado # 4 = ? # 5 = ? #vs.PenFore(123) #vs.FillPat(53) # 0 = empty # 1 = solid # 2 = # x = count number in the table of examples # 21 = small squares #vs.Rect(X1+150,Y1+200,400,500) Hello I have tried many options to change the attributes of the static text to purple text and back color red. I got half, the text color. I can even change the color of the background of the document. But somehow the pattern of the background stays in empty option for the text. What small line of text am I missing? Edited November 15, 2018 by avictorgm Quote Link to comment
MullinRJ Posted November 15, 2018 Share Posted November 15, 2018 @avictorgm , After a light investigation, it appears that "vs.CreateText()" does not use the document FILL PATTERN, nor does, "vs.CreateText()" return a handle. You will have to set the FILL attribute after you create the text. So, change: h = vs.CreateText(str("Motor ") + str(X1) + str(", ") + str(Y1)) to: vs.CreateText(str("Motor ") + str(X1) + str(", ") + str(Y1)) Then use: h = vs.LNewObj() # if you want to save the handle to the text object vs.SetFPat(h, 1) Or use: vs.SetFPat(vs.LNewObj(), 1) # if you don't need to save the handle to the text object Also, all calls using color values use LONGINTS and need to be in the 0-65535. Multiply color values in the 0-255 range by 257 to convert them to the LONGINT range. Lastly, you need to pass the color values as a TUPLE, and not three Longint values. Eg. vs.PenBack((0, 65535, 0)) # GREEN HTH, Raymond Quote Link to comment
avictorgm Posted November 15, 2018 Author Share Posted November 15, 2018 @MullinRJ ⬅️ GENIUS Thank you so much. You just save my day! vs.CreateText(str("Motor ") + str(X1) + str(", ") + str(Y1)) h = vs.LNewObj() # if you want to save the handle to the text object vs.SetFPat(h, 1) vs.PenBack((0, 36535, 0)) #RED Quote Link to comment
avictorgm Posted November 15, 2018 Author Share Posted November 15, 2018 If I use --> vs.FillBack(4) #number of color on the list of vectorworks = Blue before this vs.CreateText(... works perfect Thank you again @MullinRJ Quote Link to comment
MullinRJ Posted November 15, 2018 Share Posted November 15, 2018 You're very welcome. A word of caution; using color calls like "vs.FillBack(4)" with a single argument that represents a palette position may produce unexpected results: in different files, on different systems, or after VW software updates, as palette definitions may vary under these conditions. Using these calls with three explicit color values should always produce the repeatable results. All the best, Raymond 1 Quote Link to comment
MullinRJ Posted November 23, 2018 Share Posted November 23, 2018 On 11/15/2018 at 2:13 AM, MullinRJ said: ... it appears that "vs.CreateText()" does not use the document FILL PATTERN, ... Hi @avictorgm , when I wrote my earlier replies, I was not at my best. I completely forgot about the VW Preference "Create text without fill". The Python call "vs.CreateText()" will create text with the document fill color and pattern IF the "Create text without fill" PREF is disabled, but if the preference is set, then the text background fill color and pattern are ignored, as if the document fill pattern were set to NONE. So, you could do as I suggested above, and force the fill after creating the text, OR, you could toggle the preference OFF before creating your text, and restore its setting after your text is created. Something like this: CreateTextWOFillPref = vs.GetPref(8) # save pref setting (boolean) vs.SetPref(8, False) # disable pref setting vs.CreateText(str("Motor ") + str(X1) + str(", ") + str(Y1)) vs.SetPref(8, CreateTextWOFillPref) # restore pref setting This code snippet will create TEXT using the document fill color and pattern and ignore the VW preference to "Create text without fill". If your code is working as you like it, there is absolutely no need to change anything. I am just trying to provide a more comprehensive answer. All the best, Raymond 1 Quote Link to comment
avictorgm Posted November 23, 2018 Author Share Posted November 23, 2018 That is pretty cool!! @MullinRJ So, whatever I do with the script, there´s no difference in the settings. This kind of details make the difference. Thank you Quote Link to comment
MullinRJ Posted November 23, 2018 Share Posted November 23, 2018 8 hours ago, avictorgm said: So, whatever I do with the script, there´s no difference in the settings Correct. The first approach we discussed ignores the VW Preference entirely and forces a Fill Color and Pattern after the text is created. The second approach changes the preference to allow the current document Fill attribute to be applied when the text is created, then restores the preference to its original state. So either way you go, that VW Preference remains unchanged after the script has run. Raymond 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.