3jalex Posted February 21, 2012 Share Posted February 21, 2012 (edited) Hi I am new to sctipt. I like to change all Letters form ? to ? form ? to ? form ? to ? How can a script to to that look like? Thanks Alex Edited February 21, 2012 by 3jalex Quote Link to comment
3jalex Posted February 21, 2012 Author Share Posted February 21, 2012 Hi Ok. Here a start. How do i find out the rest? ***************************** Procedure umlaut; {change letters to others} {? to ?} {? to ?} {? to ?} {? to ?} {? to ?} {February 21, 2012} Begin If ...=...(...); End; Begin If ...=...(...); End; Run(umlaut); ******************************* Thanks Alex Quote Link to comment
Pat Stanford Posted February 21, 2012 Share Posted February 21, 2012 I think we need more information about what you are actually trying to do. Do you want to select a text block and change the letters in the block? Do you want to change every block of text on a layer? In the entire drawing? Do you want to do just text blocks or do you need to handle other objects like call outs? What about text in records? This could get to be very complicated if you need all of the above. The following is very simply tested code. Use at your own risk. This will change all the occurences of a single character in a selected text block. Procedure ChangeChar; {Replaces every occurence of a character in a text block with a new} {character. Edit this file and change the characters in OldChar and NewChar} {to be the character to replace and the replacement character} {February 21, 2012} {? 2012, Coviana, Inc - Pat Stanford pat@coviana.com} {Licensed under the GNU Lesser General Public License} Var CharArray :DynArray of Char; TextBlock :Handle; OldChar :Char; NewChar :Char; CharOffset :Integer; Begin OldChar := '?'; NewChar := '?'; TextBlock := FSActLayer; CharArray := GetText(TextBlock); CharOffset:=Pos(OldChar,CharArray); While CharOffset <> 0 do Begin Delete(CharArray,CharOffset,1); Insert(NewChar,CharArray,CharOffset); CharOffset:=Pos(OldChar,CharArray); End; SetText(TextBlock,CharArray); End; Run(ChangeChar); Quote Link to comment
3jalex Posted February 22, 2012 Author Share Posted February 22, 2012 Dear Pat Stanford and community board Thank you for the script. It is almost wath I am looking for. Somehow it does not work on my pc. It may have to do how the Arial is definded on the pc?s. When I import a AutoCAD.dwg into Vectorworks.vwx some character will be changed. The script shall simply change them back without selecting anything. Like Text>Search and change>Text? Here you can only chane one character at the time. The script can do more character at the time. The character are: OldChar := '?? to NewChar := '?? OldChar := '?? to NewChar := '?? OldChar := '?? to NewChar := '?? OldChar := '?? to NewChar := '?? OldChar := '? to NewChar := '? OldChar := '?? to NewChar := '?? On any class or layer. Some character may not apear in the drawing. Thank you so much. Quote Link to comment
Pat Stanford Posted February 26, 2012 Share Posted February 26, 2012 OK, try this one. Change the characters in the Const section to be the ones you want. There must be a 1:1 match between the OldChars and NewChars strings. It will replace all of the characters in Text Blocks. It will not do anything to other types of objects. I recommend that you completely replace OldChars and NewChars. It is possible that the Mac I am on has different character codes than the PC you are on. Procedure ChangeAllChars; {Replaces every occurence of characters in the OldChars sring in all text block with} {the corresponding character from the NewChars string. Edit this file and change the} {characters in OldChar and NewChar to be the character to replace and the replacement character} {Change the OldChars and NewChars strings in the Const section to be the characters to} {be replaced. There must be a 1:1 match between the two strings.} {February 25, 2012} {? 2012, Coviana, Inc - Pat Stanford pat@coviana.com} {Licensed under the GNU Lesser General Public License} const OldChars = '?S'; NewChars ='?Z'; Var CharArray :DynArray of Char; TextBlock :Handle; OldChar :Char; NewChar :Char; CharOffset :Integer; OldCharsLength : Integer; Procedure ProcessTextBlock(H1:Handle); var CharCount : Integer; Begin TextBlock := H1; CharArray := GetText(TextBlock); For CharCount := 1 to OldCharsLength do Begin OldChar := Copy(OldChars,CharCount,1); NewChar := Copy(NewChars,CharCount,1); CharOffset:=Pos(OldChar,CharArray); While CharOffset <> 0 do Begin Delete(CharArray,CharOffset,1); Insert(NewChar,CharArray,CharOffset); CharOffset:=Pos(OldChar,CharArray); End; SetText(TextBlock,CharArray); End; End; Begin OldCharsLength := Len(OldChars); ForEachObject(ProcessTextBlock,((T=TEXT))); End; Run(ChangeAllChars); 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.