Origin Ver. and Service Release (Select Help-->About Origin): 2022
Operating System:win 10
Hi,
I'm facing a weird issue when trying to access axis tree.
void add_special_tick(double dTick, string strTick)
{
GraphLayer gl = Project.ActiveLayer();
if (gl)
{
Axis axesX = gl.XAxis;
Scale scX(gl.X);
Tree tr;
tr = axesX.GetFormat(FPB_ALL, FOB_ALL, true, true);
tr.Root.NewAxes.NewAxis2.Specials.SpecialCount.nVal = 1;
tr.Root.NewAxes.NewAxis2.Specials.Specials.Special1.Type.nVal = 35;
tr.Root.NewAxes.NewAxis2.Specials.Specials.Special1.Value.dVal = dTick;
tr.Root.NewAxes.NewAxis2.Specials.Specials.Special1.EnableLabel.nVal = 1;
tr.Root.NewAxes.NewAxis2.Specials.Specials.Special1.Label.strVal = strTick;
double dX1 = scX.From;
double dX2 = scX.To;
double dTol = (dX2 - dX1) / 20;
TreeNodeCollection tnc(tr.Root.NewAxes.NewAxis2.RefLines.RefLines, "RefLine");
foreach (TreeNode tn in tnc)
{
if (dTick + dTol > tn.Value.dVal && dTick - dTol < tn.Value.dVal)
tn.Labels.Label1.Show.nVal = 0;
}
if (0 == axesX.UpdateThemeIDs(tr.Root))
{
bool bRet = axesX.ApplyFormat(tr, true, true);
}
}
}
1st Issue:
If I want to get axis from and to, I need to use Scale object
If I try to read tr.Root.Scale.From.dVal or tr.Root.Scale.To.dVal, I get an error saying that those variables are not declared.
Why that ?
When debugging, I can see that they exist
Moreover, it's a treenode, so compiler shouldn't care whether that leaf exists or not
2nd issue:
The function will add a special tick with label in a graph that has a few reflines with labels.
If the special tick is near reflines labels, I will hide them
Here again, I have an error saying that tn.Labels.Label1.Show.nVal is not declared
Thanks for the help