VS:GetPolyPt: Difference between revisions
(add remark about vs python: this call clips the tuple) |
(fix example, improve comment) |
||
Line 41: | Line 41: | ||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
<remark> | <remark> | ||
([[User:CBM-c-|_c_]], 2022.01.18) In VS Python this routine | ([[User:CBM-c-|_c_]], 2022.01.18) In VS Python this routine returns a bidimensional tuple. If you need a 3 items tuple for usage in vs.Vec2Ang, for example, which returns gibberish on bidimensional values, you will need to set the third item. | ||
<code lang="py"> | <code lang="py"> | ||
# test GetPolyPt | # test GetPolyPt | ||
Line 55: | Line 55: | ||
(Charles Chandler, 2001 Jan. 25): Doesn't work on rectangles, unless you rotate them, which turns them into polygons. | (Charles Chandler, 2001 Jan. 25): Doesn't work on rectangles, unless you rotate them, which turns them into polygons. | ||
</remark> | </remark> | ||
Line 64: | Line 61: | ||
==== VectorScript ==== | ==== VectorScript ==== | ||
<code lang="pas"> | <code lang="pas"> | ||
FOR i := 1 to GetVertNum(thePoly) DO | |||
GetPolyPt(thePoly, i, vertX, vertY); | |||
GetPolyPt(thePoly, i, vertX, vertY) | |||
</code> | </code> | ||
Line 73: | Line 68: | ||
<code lang="py"> | <code lang="py"> | ||
def Example(): | def Example(): | ||
obj = vs.FSActLayer() | |||
for vertexNum in range(1, vs.GetVertNum(obj)): | |||
ptVt = vs.GetPolyPt(obj, vertexNum) | |||
vs.TextOrigin(ptVt[0], ptVt[1]) | |||
vs.CreateText(vs.Concat('vNum: ', vertexNum)) | |||
Example() | Example() | ||
</code> | </code> |
Revision as of 07:49, 22 January 2022
.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix
Description
Procedure GetPolyPt returns the coordinates of a specified vertex of the referenced object.
PROCEDURE GetPolyPt(
objectHd :HANDLE;
index :INTEGER;
VAR pX,pY :REAL);
def vs.GetPolyPt(objectHd, index): return p
Parameters
objectHd HANDLE Handle to polygon. index INTEGER Index of vertex (range of 1 to n). p REAL Returns coordinates of vertex.
Remarks
(_c_, 2022.01.18) In VS Python this routine returns a bidimensional tuple. If you need a 3 items tuple for usage in vs.Vec2Ang, for example, which returns gibberish on bidimensional values, you will need to set the third item.
# test GetPolyPt p = (0, 0, 0) vs.AlrtDialog( 'init tuple: ' + str(len(p)) ) # 3 items p = vs.GetPolyPt(vs.FSActLayer(), 1) # take care to have a polygon selected vs.AlrtDialog( 'after GetPolyPt: ' + str(len(p)) ) # 2 items?!?
Example()
(_c_, 2010.12.22) Since the introduction of rotated rectangles, it doesn't turn them into polygons any longer. The routine fails with warning, as expected.
(Charles Chandler, 2001 Jan. 25): Doesn't work on rectangles, unless you rotate them, which turns them into polygons.
Example
VectorScript
FOR i := 1 to GetVertNum(thePoly) DO GetPolyPt(thePoly, i, vertX, vertY);
Python
def Example(): obj = vs.FSActLayer() for vertexNum in range(1, vs.GetVertNum(obj)): ptVt = vs.GetPolyPt(obj, vertexNum) vs.TextOrigin(ptVt[0], ptVt[1]) vs.CreateText(vs.Concat('vNum: ', vertexNum)) Example()
Version
Availability: from All Versions
See Also
For polygons:
For polylines:
- [[VS:SetPolyPt| SetPolyPt]]
For polylines:
- [[VS:GetPolylineVertex| GetPolylineVertex]]
- [[VS:SetPolylineVertex| SetPolylineVertex]]