VS:PenLoc: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
mNo edit summary
(add examples, clarify behaviour)
Line 29: Line 29:
</lineList>
</lineList>
</params>
</params>
-----------------------------------------------------------------------------------------------------------
<remark>
([[User:CBM-c-|_c_]], 2022.01.22) : To clarify, PenLoc doesn't return the current user defined mouse position, it returns the pen position during the script. Actions such as creating lines, polys etc. will cause the graphical pen internally to move. Is 2D only, In Python it returns a bidimensional tuple.
</remark>


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<sample>
<sample>
==== VectorScript ====
==== VectorScript ====
<code lang="pas">
<code lang="pas">
PenLoc(theXCoord,theYCoord);
PROCEDURE Example;
VAR
    pt : VECTOR;
BEGIN
    MoveTo(1, 234); { penLoc = 1, 234 }
    Line(100, 0); { pen position moved by 100 }
    PenLoc(pt.x, pt.y); { penLoc = 101, 234 }
    Message( pt );
END;
Run(Example);
</code>
</code>
==== Python ====
==== Python ====
<code lang="py">
<code lang="py">
penLocation = vs.PenLoc()
vs.MoveTo(1, 234, 0) # penLoc = (1, 234)
vs.Message(str(penLocation))
vs.Line(100, 0) # pen position moved by 100
pt = vs.PenLoc() # penLoc = (101, 234)
vs.Message( str(pt) )
</code>
</code>
</sample>
</sample>

Revision as of 05:59, 22 January 2022

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

Description

Returns the current coordinate location of the graphics pen.

PROCEDURE PenLoc(
VAR pX,pY :REAL);
def vs.PenLoc():
    return p

Parameters

p REAL The current location of the graphics pen.

Remarks

(_c_, 2022.01.22) : To clarify, PenLoc doesn't return the current user defined mouse position, it returns the pen position during the script. Actions such as creating lines, polys etc. will cause the graphical pen internally to move. Is 2D only, In Python it returns a bidimensional tuple.

Example

VectorScript

PROCEDURE Example;
VAR
    pt : VECTOR;
BEGIN
    MoveTo(1, 234); { penLoc = 1, 234 }
    Line(100, 0); { pen position moved by 100 }
    PenLoc(pt.x, pt.y); { penLoc = 101, 234 }
    Message( pt );
END;
Run(Example);

Python

vs.MoveTo(1, 234, 0) # penLoc = (1, 234)
vs.Line(100, 0) # pen position moved by 100
pt = vs.PenLoc() # penLoc = (101, 234)
vs.Message( str(pt) )

Version

Availability: from All Versions