VS:Get2DPt: Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
(add example and see also) |
||
Line 29: | Line 29: | ||
index | index | ||
INTEGER | INTEGER | ||
Index of vertex to be queried | Index of vertex to be queried (range of 1 to n) | ||
</line> | </line> | ||
<line> | <line> | ||
Line 42: | Line 42: | ||
<remark> | <remark> | ||
Used with bounding box objects without vertexes (groups...), the routine doesn't throw error and always returns the coordinates of the center, independently of the passed vertex index. | ([[User:CBM-c-|_c_]], 2007.05.27): Used with bounding box objects without vertexes (groups...), the routine doesn't throw error and always returns the coordinates of the center, independently of the passed vertex index. | ||
(RGM Feb 2006): This will generally return the center of an object. Use [[VS:GetSymLoc| GetSymLoc]] if you want eg. the 'point' of a Point PIO. | (RGM Feb 2006): This will generally return the center of an object. Use [[VS:GetSymLoc| GetSymLoc]] if you want eg. the 'point' of a Point PIO. | ||
</remark> | </remark> | ||
----------------------------------------------------------------------------------------------------------- | |||
<sample> | |||
==== VectorScript ==== | |||
<code lang="pas"> | |||
PROCEDURE Example; | |||
VAR | |||
p : VECTOR; | |||
BEGIN | |||
IF FSActLayer = NIL THEN | |||
AlrtDialog( 'Select a polygon or a polyline' ) | |||
ELSE BEGIN { here you might want to check if it's a valid object type } | |||
Get2DPt( FSActLayer, 2, p.x, p.y ); { stores in p the coordinates of vtx 2 } | |||
Locus( p.x, p.y ); | |||
END; | |||
END; | |||
Run(Example); | |||
</code> | |||
==== Python ==== | |||
<code lang="py"> | |||
if vs.FSActLayer() == None: | |||
vs.AlrtDialog( 'Select a polygon or a polyline' ) | |||
else: | |||
p = vs.Get2DPt( vs.FSActLayer(), 2 ) # stores in p the coordinates of vtx 2 | |||
vs.Locus( p[0], p[1] ) | |||
</code> | |||
</sample> | |||
----------------------------------------------------------------------------------------------------------- | |||
<seeAlso> | |||
VS Functions: | |||
* [[VS:GetPolyPt]] | |||
* [[VS:GetPolyPt3D]] | |||
* [[VS:GetPolylineVertex]] | |||
</seeAlso> | |||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
Latest revision as of 07:27, 22 January 2022
.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix
Description
Returns the location of the specified vertex of a referenced object.
PROCEDURE Get2DPt(
obj :HANDLE;
index :INTEGER;
VAR locX,locY :REAL);
def vs.Get2DPt(obj, index): return loc
Parameters
obj HANDLE Handle to object. index INTEGER Index of vertex to be queried (range of 1 to n) loc REAL Coordinates of 2D vertex location.
Remarks
(_c_, 2007.05.27): Used with bounding box objects without vertexes (groups...), the routine doesn't throw error and always returns the coordinates of the center, independently of the passed vertex index.
(RGM Feb 2006): This will generally return the center of an object. Use GetSymLoc if you want eg. the 'point' of a Point PIO.
Example
VectorScript
PROCEDURE Example; VAR p : VECTOR; BEGIN IF FSActLayer = NIL THEN AlrtDialog( 'Select a polygon or a polyline' ) ELSE BEGIN { here you might want to check if it's a valid object type } Get2DPt( FSActLayer, 2, p.x, p.y ); { stores in p the coordinates of vtx 2 } Locus( p.x, p.y ); END; END; Run(Example);
Python
if vs.FSActLayer() == None: vs.AlrtDialog( 'Select a polygon or a polyline' ) else: p = vs.Get2DPt( vs.FSActLayer(), 2 ) # stores in p the coordinates of vtx 2 vs.Locus( p[0], p[1] )
Version
Availability: from VectorWorks 8.5
See Also
VS Functions:
VS Functions:
- [[VS:GetPolyPt]]
- [[VS:GetPolyPt3D]]
- [[VS:GetPolylineVertex]]