VS:Rect: Difference between revisions
(this function accepts no iterables, changed params in the Python desciption: (p1x, p1y, p2x, p2y)) |
m (Transfer Orso to _c_) |
||
Line 1: | Line 1: | ||
{{LocationMain|category=LocationVS|specific=}} | {{LocationMain|category=LocationVS|specific=}} | ||
__TOC__ | |||
<vwDoc> | |||
----------------------------------------------------------------------------------------------------------- | |||
<desc> | |||
Function GetFontName converts a system font ID to a font name. | |||
An integer ID with a value representing a font in the current operating system.</desc> | |||
----------------------------------------------------------------------------------------------------------- | |||
<def> | |||
<funcDef lang="vs"> | |||
FUNCTION GetFontName(fontID:INTEGER) : STRING; | |||
</funcDef>{{LocationMain|category=LocationVS|specific=}} | |||
__TOC__ | __TOC__ | ||
<vwDoc> | <vwDoc> | ||
Line 52: | Line 67: | ||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
<remark> | <remark> [[User:CBM-c-|_c_]] (2016.03.28): An example using distance-angle. Don't forget to use the pound notation (#): | ||
<code lang="vs"> | <code lang="vs"> | ||
MoveTo(10m, 20m); { set pen position at x, y: 10m, 20m } | MoveTo(10m, 20m); { set pen position at x, y: 10m, 20m } | ||
Line 82: | Line 97: | ||
[[Category:VS Function Reference|Rect]] | [[Category:VS Function Reference|Rect]] | ||
[[Category:VS Function Reference:Objects - 2D|Rect]] | [[Category:VS Function Reference:Objects - 2D|Rect]] | ||
<funcDef lang="py"> | |||
def vs.GetFontName(fontID): | |||
return STRING | |||
</funcDef> | |||
</def> | |||
----------------------------------------------------------------------------------------------------------- | |||
<params> | |||
<lineList ident=1> | |||
<line> | |||
fontID | |||
INTEGER | |||
Font ID value. | |||
</line> | |||
</lineList> | |||
</params> | |||
----------------------------------------------------------------------------------------------------------- | |||
<remark> [[User:CBM-c-|_c_]] (2016.03.05): Upon passing an illegal font index it returns: | |||
* before VW 2015: an empty string | |||
* after VW 2015: the string "System font regular". | |||
After VW 2015 you can use [[VS:GetFontListSize]] to fetch the count of installed fonts. Before that you had to check in both negative and positive direction the whole integer limit: from -32767 to +32767. | |||
</remark> | |||
----------------------------------------------------------------------------------------------------------- | |||
<sample> | |||
==== VectorScript ==== | |||
<code lang="pas"> | |||
PROCEDURE Example; | |||
VAR | |||
str :STRING; | |||
cnt :INTEGER; | |||
BEGIN | |||
FOR cnt := 0 to 10 DO str := Concat(str, Chr(13), GetFontName(cnt)); | |||
AlrtDialog(str); | |||
END; | |||
RUN(Example); | |||
</code> | |||
==== Python ==== | |||
<code lang="py"> | |||
def Example(): | |||
str = '' | |||
for cnt in range(0,10): | |||
str = vs.Concat(str, vs.Chr(13), vs.GetFontName(cnt)) | |||
vs.AlrtDialog(str) | |||
Example() | |||
</code> | |||
</sample> | |||
----------------------------------------------------------------------------------------------------------- | |||
<version> | |||
Availability: from VectorWorks 8.0 | |||
</version> | |||
</vwDoc> | |||
[[Category:VS Function Reference|GetFontName]] | |||
[[Category:VS Function Reference:Objects - Text|GetFontName]] |
Revision as of 07:04, 30 December 2020
.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix
Description
Function GetFontName converts a system font ID to a font name.
An integer ID with a value representing a font in the current operating system.
FUNCTION GetFontName(
fontID :INTEGER) : STRING;
.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix
<vwDoc>
<desc> Procedure Rect creates a rectangle object in a VectorWorks document.
The procedure will accept coordinate definitions by either of two methods : coordinate values or distance angle values. Coordinate values are the absolute coordinate locations(in the documents' coordinate system) and are expressed as x and y values.
Distance-angle values are expressed as a distance and angle from the current pen position. For Rect, two distance angle pairs are required to specify the top left and bottom right of the rectangle object.
</desc>
<def>
PROCEDURE Rect(
p1x :REAL;
p1y :REAL;
p2x :REAL;
p2y :REAL);
def vs.Rect(p1x, p1y, p2x, p2y): return None
Parameters
p1x REAL Top left X coordinate of rectangle. p1y REAL Top left Y coordinate of rectangle. p2x REAL Bottom right X coordinate of rectangle. p2y REAL Bottom right Y coordinate of rectangle.
Remarks
_c_ (2016.03.28): An example using distance-angle. Don't forget to use the pound notation (#):
MoveTo(10m, 20m); { set pen position at x, y: 10m, 20m } Rect(1m, #0, 2m, #90); { draws from the current pen position an unrotated rectangle with width = 1m and height = 2m }
Example
VectorScript
PROCEDURE Example; VAR red, green, blue, color :LONGINT; criteria :STRING; BEGIN red := 65535; green := 0; blue := 0; RGBToColorIndex(red, green, blue, color); Rect(0, 0, 1, 1); SetPenFore(LNewObj, color); DSelectAll; criteria := Concat('(INSYMBOL & INVIEWPORT & (PF=', color, '))'); SelectObj(criteria); Message(criteria); DeleteObjs; END; RUN(Example);
Python
def Example(): red = 65535 green = 0 blue = 0 color = vs.RGBToColorIndex(red, green, blue) vs.Rect(0, 0, 1, 1) vs.SetPenFore(vs.LNewObj(), color) vs.DSelectAll() criteria = vs.Concat('(INSYMBOL & INVIEWPORT & (PF=', color, '))') vs.SelectObj(criteria) vs.Message(criteria) vs.DeleteObjs() Example()
Version
Availability: from All Versions
See Also
VS Functions:
def vs.GetFontName(fontID): return STRING
</def>
<params>
fontID INTEGER Font ID value.
</params>
<remark> _c_ (2016.03.05): Upon passing an illegal font index it returns:
- before VW 2015: an empty string
- after VW 2015: the string "System font regular".
After VW 2015 you can use VS:GetFontListSize to fetch the count of installed fonts. Before that you had to check in both negative and positive direction the whole integer limit: from -32767 to +32767. </remark>
<sample>
VectorScript
PROCEDURE Example; VAR str :STRING; cnt :INTEGER; BEGIN FOR cnt := 0 to 10 DO str := Concat(str, Chr(13), GetFontName(cnt)); AlrtDialog(str); END; RUN(Example);
Python
def Example(): str = '' for cnt in range(0,10): str = vs.Concat(str, vs.Chr(13), vs.GetFontName(cnt)) vs.AlrtDialog(str) Example()
</sample>
<version> Availability: from VectorWorks 8.0
</version>
</vwDoc>