Jump to content

Editing Textstyles


koenr

Recommended Posts

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!

Link to comment

@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.

 

Link to comment

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);

 

  • Like 1
Link to comment
  • 8 months later...
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 😄 

Link to comment
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 by koenr
Link to comment
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.

 

image.thumb.png.6ed98d517717f10b58d228a796d18540.png

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? 

Link to comment

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.

×
×
  • Create New...