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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Change properties of all instances of one element

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
marcx77 Posted - 10/03/2013 : 4:03:07 PM
Origin Ver. and Service Release (Select Help-->About Origin): 8.5.1 SR2
Operating System: Win7

Hello,

I'm currently wrapping up my MSc thesis report, which has a ton of Origin graphs. As I knew very little about Origin when I started, I'm stuck with a whole bunch of mismatched graphs.

I'm looking for a flexible way to change properties of all instances of a certain type of element in a graph, notably:

* symbol size
* plot line width

So I'd like to be able to run some code that says e.g. "change the size of every symbol in this graph (on multiple layers) to 7"

I tried copying format, but that doesn't work, since that also changes the symbol itself. The same would happen with themes I believe. So I'm turning to scripting now, hoping to find a workable solution that doesn't involve me clicking graphs for the next two days.

If anyone could point me in the right direction with perhaps some sample code... I have basic programming experience, but I don't know how to reference things like graphs, layers, plots, symbols etc. in Origin C. Many thanks in advance for any help given!




Edit: After playing around with some examples I've made some headway. I can change all the symbol sizes in one layer using:


void ss(int symsize)
{
	GraphLayer gl = Project.ActiveLayer();
	if(gl)
	{
		foreach(DataPlot dp in gl.DataPlots){
		
			if(dp)
			{
				Tree trFormat;	
				trFormat = dp.GetFormat(FPB_STYLE);
				trFormat.Root.Page.Layers.All.Curves.All.Symbol.Size.nVal = symsize; //set the size of symbol			
	
				
				if(dp.ApplyFormat(trFormat))
				{
					out_str("success");
					gl.GetPage().Refresh();
				}			
			}
		}
	}		
}


However, when I tried to adapt this to looping through all the layers in a page, it doesn't do anything. This is the code I used:


void ss(string grname,int symsize)
{
	GraphPage gp(grname);
	foreach(GraphLayer gl in gp.Layers)
	{
		if(gl)
		{
			foreach(DataPlot dp in gl.DataPlots)
			{
			
				if(dp)
				{
					Tree trFormat;	
					trFormat = dp.GetFormat(FPB_STYLE);
					trFormat.Root.Page.Layers.All.Curves.All.Symbol.Size.nVal = symsize; //set the size of symbol			
		
					
					if(dp.ApplyFormat(trFormat))
					{
						out_str("success");
						gl.GetPage().Refresh();
					}			
				}
			}
		}	
	}
}


This takes the graph name as an argument. Ideally, this would work for the currently selected graph.
4   L A T E S T    R E P L I E S    (Newest First)
marcx77 Posted - 10/04/2013 : 11:28:58 AM
Thanks again Castiel!

I'd already gotten the line width working, after I replaced FPB_STYLE_SIZE with FPB_ALL. Talk about trying and trying again... :D
Thanks for the axis width code. It makes very little sense to me that this would be referenced through the ticks node, but there you go.

I got a nice routine written now, and converting all my graphs to my specific setup works like a charm. Thanks again!
Castiel Posted - 10/04/2013 : 09:41:03 AM
Neither can I find such reference. Have to try again and again. That properties not defined do not show up, I think it's reasonable.

void ss(string grname,int symsize, double linesize, double yrsize)
{
    GraphPage gp(grname);
    foreach(GraphLayer gl in gp.Layers)
    {
        if(gl)
        {
            Tree trFormat;
            trFormat = gl.GetFormat(FPB_STYLE_SIZE|FPB_STYLE_LINE, FOB_ALL, TRUE, TRUE);
            
            foreach( TreeNode tnGroups in trFormat.Root.Groups.Children)
            {
                tnGroups.Symbol.Size.nVal = symsize;
                tnGroups.Line.Width.dVal = linesize;	// there must be a 'LINE', or nothing happens
            }
                
            foreach( TreeNode tnCurves in trFormat.Root.Curves.Children)
            {
                tnCurves.Symbol.Size.nVal = symsize;
                tnCurves.Line.Width.dVal = linesize;
            }
            
            trFormat.Root.Axes.Y.Ticks.RightTicks.Width.dVal = yrsize;	// there must be a 'RIGHT AXIS', or nothing happens
            
            gl.ApplyFormat(trFormat, TRUE, TRUE);
        }    
    }
}


©c¡Ï   ¤È¥¹  ©f¨u©c  ©c¥ì    ¥Î¤³  ©c/     ©¦£¯
 ©c¨Ê¥Î ¤´¥¨  ¥ó ¨×   ¥ó¤á' ¥Ì©¦¥­   /¤í  ¥Õ©¦©f
   ¨Ö             ¦á          ©¦£þ  ©` ¥Õ   ©¦
                              ©¦
marcx77 Posted - 10/04/2013 : 04:36:32 AM
Thanks Castiel! That seems to work and faster than what I had.
I see that you're defining a node at some point in the tree and referencing from there. That makes sense.

Do I understand correctly that you define two nodes to change symbols in both individual curves and grouped ones (where you can have e.g. incremental symbol shapes)?

I managed to change the tick size for all axes using:


void ss(int symsize, int ticksize)
{
	GraphPage gp=Project.Pages(-1);
    foreach(GraphLayer gl in gp.Layers)
    {
        if(gl)
        {
            Tree trFormat;
            trFormat = gl.GetFormat(FPB_STYLE_SIZE, FOB_ALL, TRUE, TRUE);
            
            foreach(TreeNode tnGroups in trFormat.Root.Groups.Children)
                tnGroups.Symbol.Size.nVal = symsize;
                
            foreach(TreeNode tnCurves in trFormat.Root.Curves.Children)
                tnCurves.Symbol.Size.nVal = symsize;
                
            foreach(TreeNode tnAxes in trFormat.Root.Axes.Children)
                foreach(TreeNode tnTicks in tnAxes.Ticks.Children)
                	tnTicks.Length.dVal=ticksize;
                
            gl.ApplyFormat(trFormat, TRUE, TRUE);
            out_tree(trFormat);
        }    
    }

}


This works fine, so I think I have this tree node thing down.

One more question: is there a full tree reference somewhere? I couldn't find it. I've explored the tree of my current graphs using out_tree(trFormat), but properties that aren't defined in my graph don't show up in the output.

Edit: and another: how to access the line width? tnCurves.Line.Width.dVal=linesize doesn't seem to work (in a combined Line + Symbol plot).

Edit: and another: I can't figure out how to reference the axis line width. If I look in the theme explorer, it's in 'Global', under 'root', but it would seem to me that if I set this, other things would also change. Any way to get more fine grained control over the axis line width (and e.g. color; I'd like to be able to change the color of e.g. only the right axis and not the other 3)?

Thanks again for helping!
Castiel Posted - 10/04/2013 : 01:26:28 AM
void ss(string grname,int symsize)
{
    GraphPage gp(grname);
    foreach(GraphLayer gl in gp.Layers)
    {
        if(gl)
        {
            Tree trFormat;
            trFormat = gl.GetFormat(FPB_STYLE_SIZE, FOB_ALL, TRUE, TRUE);
            
            foreach(TreeNode tnGroups in trFormat.Root.Groups.Children)
                tnGroups.Symbol.Size.nVal = symsize;
                
            foreach(TreeNode tnCurves in trFormat.Root.Curves.Children)
                tnCurves.Symbol.Size.nVal = symsize;
            
            gl.ApplyFormat(trFormat, TRUE, TRUE);
        }    
    }
}


©c¡Ï   ¤È¥¹  ©f¨u©c  ©c¥ì    ¥Î¤³  ©c/     ©¦£¯
 ©c¨Ê¥Î ¤´¥¨  ¥ó ¨×   ¥ó¤á' ¥Ì©¦¥­   /¤í  ¥Õ©¦©f
   ¨Ö             ¦á          ©¦£þ  ©` ¥Õ   ©¦
                              ©¦

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000