VS:SetPenFore: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
(the declaration should fit the explanation, but I won't change this, file a report)
m (Transfer Orso to _c_)
 
(2 intermediate revisions by the same user not shown)
Line 36: Line 36:
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<remark>
<remark>
([[User:Orso.b.schmid|Orso]] 2015.05.18): Color stays here for ColorIndex, which can be retrieved using [[VS:RGBToColorIndex]] passing the three colors Red, Green and Blue as LONGINT parameters. Historically this Vectorscript procedure responded to two types of notations:
([[User:CBM-c-|_c_]] 2015.05.18): This Vectorscript routine responds to multiple types of notations:


Vectorscript:
Vectorscript:
* with a singular [[VS:RGBToColorIndex| color index]]: <code>SetPenFore(FSActLayer, colorIndex);</code>
* Singular [[VS:RGBToColorIndex| color index]]:
* with three RGB longints: <code>SetPenFore(FSActLayer, 65535, 0, 0);</code>
*: <code>colorIndex := RGBToColorIndex(65535, 0, 0);</code>
 
*: <code>SetPenFore(FSActLayer, colorIndex);</code>
colorIndex := RGBToColorIndex(65535, 0, 0);
* Three RGB longints:
SetPenFore(FSActLayer, colorIndex); { longer using a variable }
*: <code>SetPenFore(FSActLayer, 65535, 0, 0);</code>
SetPenFore(FSActLayer, RGBToColorIndex(65535, 0, 0)); { the same as above but shorter }
   
   
Python:
Python:
* with a singular color index: <code>vs.SetPenFore(vs.FSActLayer(), vs.RGBToColorIndex(65535, 0, 0)) </code>
* Singular color index:
* with three longints in a tuple: <code>vs.SetPenFore(vs.FSActLayer(), (65535, 0, 0)) </code>
*: <code>vs.SetPenFore(vs.FSActLayer(), vs.RGBToColorIndex(65535, 0, 0)) </code>
* with three hex numbers in a tuple: <code>vs.SetPenFore(vs.FSActLayer(), (0xFFFF, 0, 0)) </code>
* Three longints in a tuple:
See similar comment for [[VS:SetFillBack]].
*: <code>vs.SetPenFore(vs.FSActLayer(), (65535, 0, 0)) </code>
* Three hex numbers in a tuple:
*: <code>vs.SetPenFore(vs.FSActLayer(), (0xFFFF, 0, 0)) </code>


SetPenBack, SetPenFore will remove the "ByClass" attribute of the FILL as well. Remember to parse for it and restore it (up to VW 13).
On Vectorlab there is a list of all color routines accepting multiple variable type, see: [http://www.vectorlab.info/index.php?title=Index_pitfalls#Colors Color Index].
; Warning: SetPenBack, SetPenFore will remove the "ByClass" attribute of the FILL as well. Remember to parse for it and restore it.





Latest revision as of 05:58, 30 December 2020

.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix

Description

Procedure SetPenFore sets the pen foreground color of the referenced object. RGB values are in the range of 0~65535.

PROCEDURE SetPenFore(
h :HANDLE;
color  : LONGINT);
def vs.SetPenFore(h, color):
    return None

Parameters

h HANDLE Handle to object.
color LONGINT RGB color value.

Remarks

(_c_ 2015.05.18): This Vectorscript routine responds to multiple types of notations:

Vectorscript:

  • Singular color index:
    colorIndex := RGBToColorIndex(65535, 0, 0);
    SetPenFore(FSActLayer, colorIndex);
  • Three RGB longints:
    SetPenFore(FSActLayer, 65535, 0, 0);

Python:

  • Singular color index:
    vs.SetPenFore(vs.FSActLayer(), vs.RGBToColorIndex(65535, 0, 0))
  • Three longints in a tuple:
    vs.SetPenFore(vs.FSActLayer(), (65535, 0, 0))
  • Three hex numbers in a tuple:
    vs.SetPenFore(vs.FSActLayer(), (0xFFFF, 0, 0))

On Vectorlab there is a list of all color routines accepting multiple variable type, see: Color Index.

Warning
SetPenBack, SetPenFore will remove the "ByClass" attribute of the FILL as well. Remember to parse for it and restore it.


(Joel Sciamma 2006.08.14): To have no pen drawn, use SetLW to set the line weight to zero.

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:

VS:RGBToColorIndex | VS:ColorIndexToRGB

VS Functions:

[[VS:RGBToColorIndex]]

| [[VS:ColorIndexToRGB]]