VS:GetOrigin

From Vectorworks Developer
Revision as of 08:22, 31 May 2015 by CBM-c- (talk | contribs) (tested: it works since VW 2010)
Jump to navigation Jump to search

.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix

Description

Procedure GetOrigin returns the current origin location relative to the center of the page.

PROCEDURE GetOrigin(
VAR x :REAL;
VAR y :REAL);
def vs.GetOrigin():
    return (x, y)

Parameters

x REAL Returns X coordinate of origin.
y REAL Returns Y coordinate of origin.

Remarks

(Orso, 2015.05.31):

Until VW 2009 this function failed to return the origin shift when used from within plug-in objects. Since VW 2010 it returns the origin shift both from within PIOs and from Commands. Below an example of reading the user origin shift from within a plug-in object. Save the code below as point Plug-in with Reset On Move and Rotation:

PROCEDURE HereAmI;
VAR
	pioHandle, pioRecHandle, wallHandle : HANDLE;
	pioName : STRING;
	o, s : VECTOR;

BEGIN
     IF GetCustomObjectInfo(pioName, pioHandle, pioRecHandle, wallHandle) THEN BEGIN
          GetOrigin(o.x, o.y); { on VW 2009 and before this will always be zero when used from within a plug-in object. }
          GetSymLoc(pioH, s.x, s.y);
          Locus(0, 0);
          CreateText(Concat(
               'GetOrigin: ', o, Chr(13), 
               'GetSymLoc: ', s	
          ));
     END;
END;
Run (HereAmI);

Objects inside Symbols use the reverse of the User Origin. I added a table of the values related to VectorScript origin in the article Absolute Origin, by Gerard Jonker, on VectorLab.

Example

VectorScript

PROCEDURE Example;
VAR
originPt : VECTOR;
BEGIN
GetOrigin(originPt.x, originPt.y);
Message(originPt);
END;
RUN(Example);

Python

def Example():
	originPtX, originPtY = vs.GetOrigin()
	vs.Message(originPtX, originPtY);
Example()

Version

Availability: from All Versions