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
 Manipulating GraphObjects
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

MBIMO

Belgium
Posts

Posted - 09/01/2005 :  11:53:34 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5 SR5
Operating System: Win2k

Hello everybody,

currently I'm trying to manipulate the size and position of GraphObjects programmatically.
First I tried the Top/Left/Width/Height data fields. But this works only for Top/Left and not for Width/Height since the latter two are readonly.
So I switched to the X/Y/DX/DY data fields. However they are using scale units instead of pixels. Since I want to rescale a GraphObject depending of the size of some GraphObjects on another layer, I run into problems the very moment the scale of the layers differs.

Is there maybe a function that converts scale units of a specific layer in pixels or something similar?

Any help is much appreciated.

Best regards,

Martin

The problem that

Mike Buess

USA
3037 Posts

Posted - 09/01/2005 :  3:37:50 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Martin,
quote:
But this works only for Top/Left and not for Width/Height since the latter two are readonly.
I see that's correct but it's odd since the corresponding LabTalk properties are read/write. If the graph object is in the active layer you can do things like this (assuming a rectangle for illustration)...

using Rect = LabTalk.Rect;
Rect.Top = 10;
Rect.Left = 10;
Rect.Width = 1000;
Rect.Height = 500;

That should be equivalent to this...

GraphLayer gl = Project.ActiveLayer();
GraphObject grobj = gl.GraphObjects("Rect");
grobj.Top = 10;
grobj.Left = 10;
grobj.Width = 1000; // gives a ReadOnly error
grobj.Height = 500; // ditto

However, the LabTalk.Rect.Width= works but grobj.Width= doesn't.

Mike Buess
Origin WebRing Member
Go to Top of Page

MBIMO

Belgium
Posts

Posted - 09/01/2005 :  6:03:56 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Mike,

thanks for the posted code. It works perfect.

Interestingly the code behaves differently depending on whether it is run from a script window or from OriginC using LT_execute. In the latter case resizing the rectangle changes the position of the upper left corner.
However, setting first "Width" and "Height" and then "Top" and "Left" solves the problem.

Thanks again,

Martin

Edited by - MBIMO on 09/01/2005 6:04:26 PM
Go to Top of Page

MBIMO

Belgium
Posts

Posted - 09/02/2005 :  05:08:01 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

to make sure the target layer (gl in Mike's post) is really active, one can use this code:


gl.LT_execute("using Rect=LabTalk.Rect");
gl.LT_execute("Rect.Width=100");
.
.
.


Best regards,

Martin
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 09/02/2005 :  07:38:48 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Martin,

Yes, but leave out LT_execute("using Rect = LabTalk.Rect."). It's not needed and means nothing in LT.

Mike Buess
Origin WebRing Member
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