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
 Help: Selecting active layer
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

hschausb

18 Posts

Posted - 08/18/2020 :  06:26:33 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello there, (general Kenobi)

I need your help with a trivial problem.
I am trying to select the active layer of a specific worksheet in a project with multiple worksheets.

My code is as followed:
WorksheetPage inpMALDI = Project.WorksheetPages("Book1");			
WorksheetPage inpReak = Project.WorksheetPages("Book2");			
WorksheetPage calMZ = Project.WorksheetPages("Book3");		

Worksheet rawData = inpMALDI.Layers(0);					
Worksheet input = inpReak.Layers(0);						
Worksheet calculation = calMZ.Layers(0);	


I want to use the current active layer of the rawData worksheet to be used in my program.
I looked up several examples and looked up the building of a worksheet.

All examples in origin C use the
Project.ActiveLayer()
command, which does not work for me. I need the active layer of “Book1” and not a random woksheet.

The building process of “Worksheet” and “Layer” does not state a way to implement the active layer without using the command mentioned above. I cannot use string names due to dynamic name changes of the layers and this command
Worksheet( Layer & layer)
is the way I am using it now (I think). I cannot see a way to implement the active layer onto the Worksheet.


Does anybody know a way to do it?
I am sure I`m reading something wrong at the command description or I`m not thinking of the obvious, because I cannot imagine that it is impossible to implement the active layer of a specific worksheet.
Please tell me where I am reading it wrong as well, so I can learn from my mistakes.

Thank you very much.

Edited by - hschausb on 08/18/2020 06:30:35 AM

Castiel

343 Posts

Posted - 08/18/2020 :  06:39:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by hschausb

Hello there, (general Kenobi)

I need your help with a trivial problem.
I am trying to select the active layer of a specific worksheet in a project with multiple worksheets.

My code is as followed:
WorksheetPage inpMALDI = Project.WorksheetPages("Book1");			
WorksheetPage inpReak = Project.WorksheetPages("Book2");			
WorksheetPage calMZ = Project.WorksheetPages("Book3");		

Worksheet rawData = inpMALDI.Layers(0);					
Worksheet input = inpReak.Layers(0);						
Worksheet calculation = calMZ.Layers(0);	


I want to use the current active layer of the rawData worksheet to be used in my program.
I looked up several examples and looked up the building of a worksheet.

All examples in origin C use the
Project.ActiveLayer()
command, which does not work for me. I need the active layer of “Book1” and not a random woksheet.

The building process of “Worksheet” and “Layer” does not state a way to implement the active layer without using the command mentioned above. I cannot use string names due to dynamic name changes of the layers and this command
Worksheet( Layer & layer)
is the way I am using it now (I think). I cannot see a way to implement the active layer onto the Worksheet.


Does anybody know a way to do it?
I am sure I`m reading something wrong at the command description or I`m not thinking of the obvious, because I cannot imagine that it is impossible to implement the active layer of a specific worksheet.
Please tell me where I am reading it wrong as well, so I can learn from my mistakes.

Thank you very much.




To get the active layer of a page, you could check the methods of the page.

To get the active Worksheet of a WorksheetPage, have a try of this:


// wp is a WorksheetPage
Worksheet wksActive = wp.Layers(-1);



------------------------------------------
       Be The Change
             You Want To See
                   In The World
------------------------------------------
Go to Top of Page

hschausb

18 Posts

Posted - 08/18/2020 :  07:28:01 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you. This worked fine.

But would you mind elaborating what the count (-1) stands for?
And why would I check the methods of a page. I do not get that. Mainly because I do not know what a method of a page is. I thought a page only consists of objects (OriginObjects).
Go to Top of Page

Chris D

428 Posts

Posted - 08/18/2020 :  09:12:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

By "To get the active layer of a page, you could check the methods of the page", I think Castiel just means to read the docs.

The -1 in the call to

Worksheet wksActive = wp.Layers(-1);


Is just a flag to indicate the active Worksheet.

Thanks,
Chris Drozdowski
Originlab Technical Support
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