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
 Forum for Origin C
 Change properties of all instances of one element
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

marcx77

Netherlands
3 Posts

Posted - 10/03/2013 :  4:03:07 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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.

Edited by - marcx77 on 10/03/2013 4:57:25 PM

Castiel

343 Posts

Posted - 10/04/2013 :  01:26:28 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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);
        }    
    }
}


妾+   午旦  妹罕妾  妾伊    用仇  妾/     岫ㄞ
 妾京用 仍巨  件 侈   件戶' 甘岫平   /欠  白岫妹
   併             艮          岫  奈 白   岫
                              岫
Go to Top of Page

marcx77

Netherlands
3 Posts

Posted - 10/04/2013 :  04:36:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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!

Edited by - marcx77 on 10/04/2013 05:21:45 AM
Go to Top of Page

Castiel

343 Posts

Posted - 10/04/2013 :  09:41:03 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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);
        }    
    }
}


妾+   午旦  妹罕妾  妾伊    用仇  妾/     岫ㄞ
 妾京用 仍巨  件 侈   件戶' 甘岫平   /欠  白岫妹
   併             艮          岫  奈 白   岫
                              岫
Go to Top of Page

marcx77

Netherlands
3 Posts

Posted - 10/04/2013 :  11:28:58 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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!
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