VS:PointAlongPoly: Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
m (add see also) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
<desc> | <desc> | ||
Returns a point at the specified distance along the poly, and a vector tangent to the poly at that point. | Returns a point at the specified distance along the poly, and a vector tangent to the poly at that point.</desc> | ||
</desc> | |||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
<def> | <def> | ||
<funcDef lang="vs"> | <funcDef lang="vs"> | ||
FUNCTION PointAlongPoly(h :HANDLE; dist :REAL; VAR | FUNCTION PointAlongPoly(h:HANDLE; dist:REAL; VAR pt:VECTOR; VAR tangent:VECTOR) : BOOLEAN; | ||
</funcDef> | </funcDef> | ||
<funcDef lang="py"> | <funcDef lang="py"> | ||
Line 33: | Line 32: | ||
</line> | </line> | ||
<line> | <line> | ||
pt | |||
VECTOR | |||
</line> | </line> | ||
<line> | <line> | ||
tangent | |||
VECTOR | |||
</line> | </line> | ||
</lineList> | </lineList> | ||
</params> | </params> | ||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
<remark> | <remark> | ||
This | ([[User:CBM-c-| _c_]], 2022.01.18) In Vectorscript Python this returns a tuple with 3 items ( 0, 0, 0 ). This is relevant for usage in routines such as [[VS:Vec2Ang | Vec2Ang]], returning wrong values if the tuple is only bidimensional. | ||
</remark> | </remark> | ||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
<sample> | <sample> | ||
==== Pascal ==== | |||
<code lang="pas"> | <code lang="pas"> | ||
PROCEDURE | PROCEDURE Test; | ||
VAR | VAR | ||
polyObj : HANDLE; | |||
dist : REAL; | |||
p, tangentVec : VECTOR; | |||
BEGIN | BEGIN | ||
polyObj := FSActLayer; | |||
IF polyObj = NIL THEN | |||
AlrtDialog( 'Select a polygon' ) | |||
ELSE BEGIN | |||
dist := 1m; | |||
IF PointAlongPoly( polyObj, dist, p, tangentVec ) THEN | |||
Locus( p.x, p.y ); | |||
END; | |||
END; | END; | ||
Run(Test); | |||
</code> | |||
==== Python ==== | |||
<code lang="py"> | |||
def Str2Num( inStr ): | |||
ok, num = vs.ValidNumStr( inStr ) | |||
if ok: | |||
return num | |||
else: | |||
return 0 | |||
polyObj = vs.FSActLayer() | |||
if polyObj == vs.Handle(): | |||
vs.AlrtDialog( 'Select a polygon' ) | |||
else: | |||
dist = Str2Num( '1m' ) # convert string to dim | |||
ok, p, tangentVec = vs.PointAlongPoly( polyObj, dist ) | |||
if ok: | |||
vs.Locus( p ) | |||
vs.AlrtDialog( str( len(p)) ) # return a tuple with 3 items | |||
</code> | |||
</sample> | </sample> | ||
----------------------------------------------------------------------------------------------------------- | |||
<seeAlso> | |||
VS Functions: | |||
* [[VS:PointAlongPolyN]] | |||
</seeAlso> | |||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
<version> | <version> | ||
Availability: from | Availability: from Vectorworks 2014 | ||
</version> | </version> | ||
</vwDoc> | </vwDoc> |
Latest revision as of 06:23, 25 January 2022
.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix
Description
Returns a point at the specified distance along the poly, and a vector tangent to the poly at that point.
FUNCTION PointAlongPoly(
h :HANDLE;
dist :REAL;
VAR pt :VECTOR;
VAR tangent :VECTOR) : BOOLEAN;
def vs.PointAlongPoly(h, dist): return (BOOLEAN, pt, tangent)
Parameters
h HANDLE dist REAL pt VECTOR tangent VECTOR
Remarks
( _c_, 2022.01.18) In Vectorscript Python this returns a tuple with 3 items ( 0, 0, 0 ). This is relevant for usage in routines such as Vec2Ang, returning wrong values if the tuple is only bidimensional.
Example
Pascal
PROCEDURE Test; VAR polyObj : HANDLE; dist : REAL; p, tangentVec : VECTOR; BEGIN polyObj := FSActLayer; IF polyObj = NIL THEN AlrtDialog( 'Select a polygon' ) ELSE BEGIN dist := 1m; IF PointAlongPoly( polyObj, dist, p, tangentVec ) THEN Locus( p.x, p.y ); END; END; Run(Test);
Python
def Str2Num( inStr ): ok, num = vs.ValidNumStr( inStr ) if ok: return num else: return 0 polyObj = vs.FSActLayer() if polyObj == vs.Handle(): vs.AlrtDialog( 'Select a polygon' ) else: dist = Str2Num( '1m' ) # convert string to dim ok, p, tangentVec = vs.PointAlongPoly( polyObj, dist ) if ok: vs.Locus( p ) vs.AlrtDialog( str( len(p)) ) # return a tuple with 3 items
Version
Availability: from Vectorworks 2014
See Also
VS Functions:
VS Functions:
- [[VS:PointAlongPolyN]]