The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Pasting parameters after curve fitting
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

grahamdog

UK
Posts

Posted - 04/27/2006 :  10:36:17 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7
Operating System:XP pro

Does any one know if there is a way of when you've done more then one fit to the data via a script (i e in succession) if it is possible to paste both fit parameters to the graph. At the moment the latest fit just wipes over the last one.

Mike Buess

USA
3037 Posts

Posted - 04/27/2006 :  11:22:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Add the following Origin C function to CodeBuilder's workspace as explained here and call the function at the end of each fit. The function renames the text label containing the parameters to something generic so it won't be overwitten by the next fit.

// Origin C function
void RenameFitLabel()
{
GraphLayer gl = Project.ActiveLayer();
GraphObject go = gl.GraphObjects("FIT.P");
if( go.IsValid() )
{
string sCmd = go.Text;
sCmd.Format("label -s -sa \"%s\"",sCmd);
gl.LT_execute(sCmd); // create generically named text label
gl.LT_execute("doc -e G {%B.background=1; break}"); // add border
gl.LT_execute("label -r fit.p"); // remove original text label
}
}

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 04/27/2006 11:39:46 AM
Go to Top of Page

grahamdog

UK
Posts

Posted - 04/27/2006 :  12:05:57 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Cheers for the response. It doesn't seem to work tho - it just won't compile. This is what i copied:
* *
* Modification Log: *
*------------------------------------------------------------------------------*/

////////////////////////////////////////////////////////////////////////////////////
// you can include just this typical header file for most Origin built-in functions and classes
// and it takes a reasonable amount of time to compile,
#include <origin.h>
// this file include most of the other header files except the NAG header, which takes longer to compile
// NAG routines
//#include <OC_nag.h> // this contains all the NAG headers,

////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////
// start your functions here

// Origin C function
void RenameFitLabel()
{
GraphLayer gl = Project.ActiveLayer();
GraphObject go = gl.GraphObjects("FIT.P");
if( go.IsValid() )
{
string sCmd = go.Text;
sCmd.Format("label -s -sa \"%s\"",sCmd);
gl.LT_execute(sCmd);
gl.LT_execute("label -r fit.p");
}
}

And this is the error message:

compiling...
PasteLikeARealMan.c
C:\Program Files\OriginLab\Origin7\OriginC\PasteLikeARealMan.c(29) :Error, Can't find matching constructor.
C:\Program Files\OriginLab\Origin7\OriginC\PasteLikeARealMan.c(29) :Error, Can't find matching constructor.
C:\Program Files\OriginLab\Origin7\OriginC\PasteLikeARealMan.c(29) :Error, general compile error
C:\Program Files\OriginLab\Origin7\OriginC\PasteLikeARealMan.c(26) :Error, error(s) found in compiling function RenameFitLabel
compiling...
sys_utils.c

Compiling errors found, linking cannot start!

My skills in Origin C are somewhat limited so i'm not sure what the problem is - can you help?

thanks
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 04/27/2006 :  12:23:05 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You probably just need to update your Origin 7. Run Help > Check for Updates and download/install whatever is found. Repeat until no further updates are found. (Latest patch is SR4.) Alternatively, you can download the patches from Origin's web page...
http://www.originlab.com/index.aspx?s=9&lm=76

Mike Buess
Origin WebRing Member
Go to Top of Page

grahamdog

UK
Posts

Posted - 04/27/2006 :  2:02:29 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I tried the update; didn't seem to help. Is using the origin C code builder the only way to solve the problem. Can the code be used as the run script after fit function in the advanced function fitter?

cheers
g
Go to Top of Page

easwar

USA
1965 Posts

Posted - 04/27/2006 :  2:18:17 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I tried Mike's code in 7.0SR4 and it compiled and worked fine.
Did you patch up to 7.0SR4?

You can call an Origin C function that has been compiled, from script, and so all you need to do in this case is to add one line
RenameFitLabel();
to the edit box in the Scripts->After Fit tab of the NLSF tool. Make sure the Enabled checkbox is checked and then you can save the function.

To make the Origin C function available in any future session of Origin (once you can get this working!), you can add the file in Code Builder to the System branch of the tree. You can simply drag the file out of User branch (if that is where it is now) and drop it on the system branch.

Easwar
OriginLab

Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 04/27/2006 :  2:31:59 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The code must be compiled by CodeBuilder before it can be used at all. Select Help > About Origin. If the dialog does not say Origin 7 SR4 at the top then you haven't updated far enough and you should run Check for Updates again. If it does say SR4 then you might try restarting Origin or even rebooting your computer.

Also, help files are updated separately from the program. Once you're at SR4 you should run Check for Updates again to download the latest help files. (No installation is necessary for help files.)

LabTalk actually has more control over text labels than does Origin C (at least in 7.0) so you deserve an explanation for why this Origin C approach is necessary. Text labels normally have simple names like Text1 or Text2. If you add a text label to a graph, select the label and then select Format -> Label Control the label's name is shown in Object Name box at the top of the dialog. LabTalk can access the properties of the label through it's name. For example, %Z=Text1.text$ assigns the text in the text label called Text1 to the string variable %Z. Unfortunately, the Advanced Fitter always prints its parameters to a text label with the non-standard name FIT.P which generates errors when you attempt to access its properties from LabTalk...

%Z=Fit.p.text$;
#Command Error!

Origin C has no problems with such non-standard names and can get the label's text like this...

GraphObject go = gl.GraphObjects("FIT.P");
string sCmd = go.Text;

However, Origin C cannot create a text label or destroy one (in 7.0) and LabTalk commands (LT_execute) must be used to create a new text label with a default name and with the text from FIT.P and then delete FIT.P. So Origin C gets the label text and LabTalk does the rest.

...That said, if you're fitting multiple datasets your graph window will likely get crowded with text labels. Are you sure need them or might it be better to rely on the Results log? Finally, you might take a look at the MultiFit addon at OriginLab's File Exchange.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 04/27/2006 2:46:04 PM

Edited by - Mike Buess on 04/27/2006 4:01:13 PM

Edited by - Mike Buess on 04/27/2006 4:24:22 PM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000