koenr Posted January 11, 2023 Share Posted January 11, 2023 Hey I was wondering if there is a definition in vectorworks that allows you to edit a textstyle. I want to make a script that can chance the color of a specific textstyle. in a previous version (vw2021) i just had a textstyle attached to a class and when i changed the classcolors (with a script) my textobjects would chanche aswell but this isn't the case anymore sadly.. i could change it all manualy but we all know that a script is much better right 😄 i hope this can be done cause i realy liked the visual control it gave me and the company. Thanks in advanced! Quote Link to comment
Pat Stanford Posted January 11, 2023 Share Posted January 11, 2023 Check out GetTextStyleRef in the VS Function Reference. That then has links to all the other functions that you can use to set the parameters of the Style. Quote Link to comment
koenr Posted January 12, 2023 Author Share Posted January 12, 2023 @Pat Stanford thanks for the reply but i can't realy find it there. Just to be clear i want to change the textstyle itself and not the style of a textobject. with gettextstyleref or settextstyleref i can change the textstyle of an textobject but i want to keep the style and just change the color of that style. is this possible? Otherwhise i need to write a bigger script that selects all textobject with that specific style and change it to the new one with another color. Quote Link to comment
Pat Stanford Posted January 12, 2023 Share Posted January 12, 2023 Here is the Vectorscript version. The codes needed for the SetObjectVariable calls are in the Vectorscirpt Appendix. There may be other ways, but what I tried and worked to get the changes to the text style to show was to reattach the text style to every object that has that style already. But then I found that some of the text blocks ended up being to short when I went to a larger font size, so I had to reset all the text blocks also. 1361 is the code for the font size. It takes a real that (I think) is in document units. If you want to be able to specify by Points or mils you will need to do the conversion. HTH. Procedure ChangeTextStyle; VAR H1,H2 :Handle; L1 :LongInt; S1 :String; Procedure Execute (Hd1:Handle); BEGIN SetTextStyleRef(Hd1, L1); End; BEGIN H1:=FSActLayer; {Get First Selected Object} If GetTypeN(H1)=10 THEN {Check if that object is a text block} BEGIN L1:=GetTextStyleRef(H1); {L1 has the internal reference number of the TextStyle} S1:=Index2Name(L1); {Get the Name of the Text Style} H2:=GetObject(S1); {Get a handle to the TextSyle} { AlrtDialog(Concat(L1,' Text Style:',Index2Name(L1))); } {This was for debugging} IF H2 <> Nil THEN {If H2 = Nil then the text object is Unstyled} BEGIN {otherwsie H2 is a handle to the TextStyle} SetObjectVariableInt(H2,1364,4); {Set TextStyle to Underline} SetObjectVariableReal(H2, 1361,0.5"); {Set TextStyle to 1/4"} ForEachObject(Execute,((TSTY='TextStyle-1'))); {attach style again to every object using the text style to show changes} ForEachObject(ResetObject, ((TSTY='TextStyle-1'))); {Reset text blocks to account for modified text size} End; End; End; Run(ChangeTextStyle); 1 Quote Link to comment
koenr Posted January 18, 2023 Author Share Posted January 18, 2023 @Pat StanfordThanks a lot i think this is indeed the way to go! Quote Link to comment
koenr Posted October 10, 2023 Author Share Posted October 10, 2023 On 1/12/2023 at 10:47 PM, Pat Stanford said: Here is the Vectorscript version. The codes needed for the SetObjectVariable calls are in the Vectorscirpt Appendix. There may be other ways, but what I tried and worked to get the changes to the text style to show was to reattach the text style to every object that has that style already. But then I found that some of the text blocks ended up being to short when I went to a larger font size, so I had to reset all the text blocks also. 1361 is the code for the font size. It takes a real that (I think) is in document units. If you want to be able to specify by Points or mils you will need to do the conversion. HTH. Procedure ChangeTextStyle; VAR H1,H2 :Handle; L1 :LongInt; S1 :String; Procedure Execute (Hd1:Handle); BEGIN SetTextStyleRef(Hd1, L1); End; BEGIN H1:=FSActLayer; {Get First Selected Object} If GetTypeN(H1)=10 THEN {Check if that object is a text block} BEGIN L1:=GetTextStyleRef(H1); {L1 has the internal reference number of the TextStyle} S1:=Index2Name(L1); {Get the Name of the Text Style} H2:=GetObject(S1); {Get a handle to the TextSyle} { AlrtDialog(Concat(L1,' Text Style:',Index2Name(L1))); } {This was for debugging} IF H2 <> Nil THEN {If H2 = Nil then the text object is Unstyled} BEGIN {otherwsie H2 is a handle to the TextStyle} SetObjectVariableInt(H2,1364,4); {Set TextStyle to Underline} SetObjectVariableReal(H2, 1361,0.5"); {Set TextStyle to 1/4"} ForEachObject(Execute,((TSTY='TextStyle-1'))); {attach style again to every object using the text style to show changes} ForEachObject(ResetObject, ((TSTY='TextStyle-1'))); {Reset text blocks to account for modified text size} End; End; End; Run(ChangeTextStyle); @Pat Stanford It took me a while to get into the details of this but it works fine and i got my right textstyle and i can change the underline just like in your example but i want to change the color of the style. Do you know the index for thesetobjectvariable() function? I can't find it anywhere.. I you have a list of all thes indexes that would be verry helpfull in the future 😄 Quote Link to comment
koenr Posted October 10, 2023 Author Share Posted October 10, 2023 (edited) 15 minutes ago, koenr said: @Pat Stanford It took me a while to get into the details of this but it works fine and i got my right textstyle and i can change the underline just like in your example but i want to change the color of the style. Do you know the index for thesetobjectvariable() function? I can't find it anywhere.. I you have a list of all thes indexes that would be verry helpfull in the future 😄 Never mind! I tried a lot of indexes and i found it!! The color of a textstyle is index 1367 used inside the SetObjectVariableInt(). Thanks for all your help anyways!! 😄 Edited October 10, 2023 by koenr Quote Link to comment
Pat Stanford Posted October 10, 2023 Share Posted October 10, 2023 Glad you found it. But it appears to be pretty clear in the Text Styles section of the Vectorscript Appendix. Quote Link to comment
spettitt Posted October 10, 2023 Share Posted October 10, 2023 3 hours ago, Pat Stanford said: Glad you found it. But it appears to be pretty clear in the Text Styles section of the Vectorscript Appendix. As an aside, Pat, I believe there is an offline version of the VS function ref and appendices, but I've never known how to find it. I use the online version, but the above looks nicer, which is presumably the offline. How could we find it please? Quote Link to comment
Pat Stanford Posted October 10, 2023 Share Posted October 10, 2023 Applications:Vectorworks XXX:VW Help:Script Reference This will get you to the top level of the Function Reference. To get to the Appendix, click on the Additional Resources and then on the Script Appendix that shows up in the second box on the left. HTH 1 Quote Link to comment
koenr Posted October 11, 2023 Author Share Posted October 11, 2023 I realy can't find it anywhere @Pat Stanford. These are the only appendixes i can find and there is no table like yours above 😞 Do u have an url or can you send the offline version to my email? Quote Link to comment
Tom W. Posted October 11, 2023 Share Posted October 11, 2023 6 minutes ago, koenr said: I realy can't find it anywhere @Pat Stanford. These are the only appendixes i can find and there is no table like yours above 😞 Do u have an url or can you send the offline version to my email? You need to look in your Applications folder e.g. for me on a Mac: Quote Link to comment
koenr Posted October 11, 2023 Author Share Posted October 11, 2023 40 minutes ago, Tom W. said: You need to look in your Applications folder e.g. for me on a Mac: Ow god.. Thanks a lot i found it! This is gonna help me so much! ❤️ 2 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.