T O P I C R E V I E W |
OndrejMM |
Posted - 10/24/2010 : 10:40:03 PM hi guys, how can i modify the following script that in copies notes into a label on a graph page instead of layout? thanks, ondrej
//////////////////////////////////////////////////////////////////////////////////// // Start your functions here. void Notes2Label(string sNotes) { Note noteWin(sNotes); if( !noteWin ) return; Layout lay = Project.ActiveLayer(); if( !lay ) return; string str = noteWin.Text; GraphObject go = lay.GraphObjects("Notes"); if( !go ) { lay.LT_execute("label -s -sa -n Notes Text"); go = lay.GraphObjects("Notes"); } go.Text = str; } |
4 L A T E S T R E P L I E S (Newest First) |
OndrejMM |
Posted - 10/26/2010 : 02:08:19 AM yes, it works, sorry, i'm being stupid,... thanks, ondrej |
Penn |
Posted - 10/26/2010 : 01:35:24 AM Hi Ondrej,
It works fine on my computer. I just follow the steps below:
1. create a new project, and then add a new graph and a new note window to the project. 2. rename the note window with "note.txt" and type some words in this new note window. 3. rename the graph with "TTTCCTgraph1" and add a text label to this graph, then rename the text label as "xxx", and displayed text is "aaa". 4. open the Code Builder and create a new .c file, copy the function code to this new file and compile it. 5. in the Script Window, run your script.
Then I can see that the displayed text is replaced by the word in the note window.
I see that the note window name is "note.txt", so, I wonder if you want to read the text from a text document, but not from the note window. If so, you can refer to File IO functions to read text in a file.
Penn |
OndrejMM |
Posted - 10/25/2010 : 6:16:40 PM hi Penn, i've modified the script, but it still doesn't work,... here is my modification:
void NotesToLabel(string sNotes) { Note noteWin(sNotes); if( !noteWin ) return; GraphLayer lay = Project.ActiveLayer(); if( !lay ) return; string str = noteWin.Text; GraphObject go = lay.GraphObjects("xxx"); if( !go ) { lay.LT_execute("label -s -sa -n Notes Text"); go = lay.GraphObjects("xxx"); } go.Text = str; }
i then compiled the script and added to the project, then I've tried to run as follows (there is already label with name 'xxx':
win -o TTTCCTgraph1 { NotesToLabel(note.txt); //copy note text to label doc -uw; //refresh };
|
Penn |
Posted - 10/25/2010 : 02:34:57 AM Hi Ondrej,
You can just use the GraphLayer instead of Layout.
// Layout lay = Project.ActiveLayer();
GraphLayer lay = Project.ActiveLayer();
Penn |
|
|