VS:GetPolyPt: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
(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 will always return a 2-items tuple, clipping it if "necessary". If you need a 3 items tuple for usage in vs.Vec2Ang, for example, you will need to restore the third item.
([[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.
(Gerard Jonker, 2007 Jan. 8) Please have a look at my [http://www.vectorlab.info/index.php?title=Absolute_Origin comments on the VectorLab] regarding this function, concerning index and origin.
</remark>
</remark>


Line 64: Line 61:
==== VectorScript ====
==== VectorScript ====
<code lang="pas">
<code lang="pas">
for i := 1 to GetVertNum(thePoly) do
FOR i := 1 to GetVertNum(thePoly) DO
begin
    GetPolyPt(thePoly, i, vertX, vertY);
GetPolyPt(thePoly, i, vertX, vertY);
end;
</code>
</code>


Line 73: Line 68:
<code lang="py">
<code lang="py">
def Example():
def Example():
obj = vs.FSActLayer()
    obj = vs.FSActLayer()
for vertexNum in range(1, vs.GetVertNum(obj)):
    for vertexNum in range(1, vs.GetVertNum(obj)):
ptVt = vs.GetPolyPt(obj, vertexNum)
        ptVt = vs.GetPolyPt(obj, vertexNum)
vs.TextOrigin(ptVt[0], ptVt[1])
        vs.TextOrigin(ptVt[0], ptVt[1])
vs.CreateText(vs.Concat('vNum: ', vertexNum))
        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:

For polygons:
  • [[VS:SetPolyPt| SetPolyPt]]

For polylines:

  • [[VS:GetPolylineVertex| GetPolylineVertex]]
  • [[VS:SetPolylineVertex| SetPolylineVertex]]