Code snippet : Différence entre versions

De Wiki-Cadlink
Sauter à la navigation Sauter à la recherche
(Page créée avec « == HOTSPOT == === 2D === ==== Boites englobantes ==== <pre> HOTSPOT2 0, 0 HOTSPOT2 a, 0 HOTSPOT2 0, b HOTSPOT2 a, b </pre> <pre> HOTSPOT2 -a/2, -b/2 HOTSPOT2 a/2, -b/2 HO... »)
 
(Script interface)
 
(12 révisions intermédiaires par 2 utilisateurs non affichées)
Ligne 1 : Ligne 1 :
 
== HOTSPOT ==
 
== HOTSPOT ==
 
=== 2D ===
 
=== 2D ===
==== Boites englobantes ====
+
==== Boite englobante ====
 
<pre>
 
<pre>
 
HOTSPOT2 0, 0
 
HOTSPOT2 0, 0
Ligne 15 : Ligne 15 :
 
HOTSPOT2 a/2, b/2
 
HOTSPOT2 a/2, b/2
 
</pre>
 
</pre>
 +
 
==== Déplacements ====
 
==== Déplacements ====
 
===== Sur l'axe X =====
 
===== Sur l'axe X =====
Ligne 27 : Ligne 28 :
 
HOTSPOT2 0, -1, unID, b, 3 : unID=unID+1
 
HOTSPOT2 0, -1, unID, b, 3 : unID=unID+1
 
HOTSPOT2 0,  b, unID, b, 2 : unID=unID+1
 
HOTSPOT2 0,  b, unID, b, 2 : unID=unID+1
 +
</pre>
 +
===== Sur les deux axes en même temps =====
 +
<pre>
 +
HOTSPOT2  0,  b, unID, a, 1+128 : unID=unID+1
 +
HOTSPOT2 -1,  b, unID, a, 3 : unID=unID+1
 +
HOTSPOT2  a,  b, unID, a, 2 : unID=unID+1
 +
HOTSPOT2  a,  0, unID, b, 1+128 : unID=unID+1
 +
HOTSPOT2  a, -1, unID, b, 3 : unID=unID+1
 +
HOTSPOT2  a,  b, unID, b, 2 : unID=unID+1
 
</pre>
 
</pre>
 
===== Rotation =====
 
===== Rotation =====
 
<pre>
 
<pre>
HOTSPOT2  0, 0, unID, angle, 6 : unID=unID+1
+
HOTSPOT2  0, 0, unID, angle, 6 : unID=unID+1
HOTSPOT2  A, 0, unID, angle, 4+128 : unID=unID+1
+
HOTSPOT2  A, 0, unID, angle, 4+128 : unID=unID+1
HOTSPOT2  A*COS(angle), A*SIN(angle), unID, angle, 5 : unID=unID+1
+
HOTSPOT2  A*COS(angle), A*SIN(angle), unID, angle, 5 : unID=unID+1
 
</pre>
 
</pre>
 +
 
===3D===
 
===3D===
 
==== Déplacements ====
 
==== Déplacements ====
Ligne 52 : Ligne 63 :
 
HOTSPOT 0, 0,  0, unID, ZZYZX, 1+128 : unID=unID+1
 
HOTSPOT 0, 0,  0, unID, ZZYZX, 1+128 : unID=unID+1
 
HOTSPOT 0, 0, -1, unID, ZZYZX, 3 : unID=unID+1
 
HOTSPOT 0, 0, -1, unID, ZZYZX, 3 : unID=unID+1
HOTSPOT 0, 0,  ZZYZX, unID, ZZYZX, 2 : unID=unID+1
+
HOTSPOT 0, 0,  ZZYZX, unID, ZZYZX, 2 : unID=unID+1
 
</pre>
 
</pre>
 +
 
== HOTLINE ==
 
== HOTLINE ==
=== Boites englobantes ===
+
=== Boite englobante ===
 
<pre>
 
<pre>
 
HOTLINE2 0, 0, a, 0
 
HOTLINE2 0, 0, a, 0
Ligne 62 : Ligne 74 :
 
HOTLINE2 0, 0, 0, b
 
HOTLINE2 0, 0, 0, b
 
</pre>
 
</pre>
 +
 
== Gestion de l'affichage ==
 
== Gestion de l'affichage ==
=== Affichage sur étage supérieur ===
+
=== Affichage différent en fonction de l'étage d'implantation ===
 +
* L'objet placé doit être paramétré en "Visible sur tous les étages"
 
<pre>
 
<pre>
zz = REQUEST ("Story", "", index1, story_name)
+
zz = REQUEST ("Story", "", index1, story_name) ! Étage affiché
zz = REQUEST ("Home_story", "", index2, home_story_name)
+
zz = REQUEST ("Home_story", "", index2, home_story_name) ! Étage d'implantation de l'objet
 +
 
 +
IF index1 > index2 THEN
 +
!Symbole 2D affiché au dessus de l'étage d'implantation
 +
ENDIF
 +
IF index1 = index2 THEN
 +
!Symbole 2D affiché sur l'étage d'implantation
 +
ENDIF
 +
IF index1 < index2 THEN
 +
!Symbole 2D affiché en dessous de l'étage d'implantation
 +
ENDIF
 +
</pre>
  
IF index1 = index2 OR (index1 > index2 AND aff_eta_sup) THEN
+
=== Orientation 2D ===
 +
<pre>
 +
MUL2 1 - 2 * SYMB_MIRRORED, 1
 +
</pre>
 +
<pre>
 +
r = request ("View_Rotangle", "", _angleViewRot)
  
!Symbole 2D
+
! Actual rotation of the 2D symbol:
 +
_totalRotate = (SYMB_ROTANGLE + _angleViewRot) MOD 360
  
ENDIF
+
! Count the number of transformations of the
 +
! coordinate system in different cases
 +
_nTrans = 0
 
</pre>
 
</pre>
=== Orientation 2D ===
 
 
==== Toujours horizontal ====
 
==== Toujours horizontal ====
 
<pre>
 
<pre>
rrr = request("View_Rotangle", "", viewRotation)
+
rot2 _totalRotate * (SYMB_MIRRORED - not(SYMB_MIRRORED))
MUL2 1 - 2 * SYMB_MIRRORED, 1
+
_nTrans = _nTrans + 1
ROT2 -SYMB_ROTANGLE * (SYMB_ROTANGLE <> 0) –viewRotation
 
 
</pre>
 
</pre>
 
==== Lisible ====
 
==== Lisible ====
 
<pre>
 
<pre>
MUL2 1 - 2 * SYMB_MIRRORED, 1
+
IF (_totalRotate > (90 + 90*SYMB_MIRRORED + EPS) & _totalRotate < (270 + 90*SYMB_MIRRORED + EPS)) THEN
IF SYMB_ROTANGLE >= 45 AND SYMB_ROTANGLE <= 180 THEN
+
    ROT2 180
ROT2 180
+
    _nTrans = _nTrans + 1
ELSE
 
ROT2 0
 
 
ENDIF
 
ENDIF
 
</pre>
 
</pre>
 +
 
== Script interface ==
 
== Script interface ==
 
<pre>
 
<pre>
Ligne 103 : Ligne 133 :
 
1, "Texte", 1
 
1, "Texte", 1
 
</pre>
 
</pre>
 +
=== Liste de polices ===
 +
<pre>
 +
dim fontnames[]
 +
n = REQUEST ("FONTNAMES_LIST", "", fontnames)
 +
ui_outfield `Police`, 10, 14, 100, 15
 +
ui_custom_popup_infield "sampleName", 115, 10, 150, 20,
 +
0, 0, 1, "", fontnames
 +
</pre>
 +
On peut aussi récupérer la liste directement en utilisant ces noms de paramètres (type texte) :
 +
* fontType
 +
* fontType2
 +
* fontType3
 +
=== Liste des images chargées en bibliothèques ===
 +
En utilisant ces noms de paramètres (type texte) :
 +
* gs_picture_name
 +
* gs_picture_name_2D
 +
=== Icones mise en forme de texte ===
 +
Pour avoir les icônes Gras, Italique, Souligné et Barré qui gère automatiquement la valeur du code pour mettre en forme un texte dans un style :
 +
<pre>ui_textstyle_infield "styleTexte", 1+2+4+128, x, y, buttonWidth, buttonHeight, buttonOffsetX</pre>
 +
("styleTexte" est un paramètre de type entier)
 +
<pre>define style name fontType, size, anchor, styleTexte</pre>
 +
 
== Macros ==
 
== Macros ==
 
=== Suis-je une macro ? ===
 
=== Suis-je une macro ? ===

Version actuelle datée du 22 janvier 2024 à 15:27

HOTSPOT

2D

Boite englobante

HOTSPOT2 0, 0
HOTSPOT2 a, 0
HOTSPOT2 0, b
HOTSPOT2 a, b
HOTSPOT2 -a/2, -b/2
HOTSPOT2 a/2, -b/2
HOTSPOT2 -a/2, b/2
HOTSPOT2 a/2, b/2

Déplacements

Sur l'axe X
HOTSPOT2  0, 0, unID, a, 1+128	: unID=unID+1
HOTSPOT2 -1, 0, unID, a, 3		: unID=unID+1
HOTSPOT2  a, 0, unID, a, 2		: unID=unID+1
Sur l'axe Y
HOTSPOT2 0,  0, unID, b, 1+128	: unID=unID+1
HOTSPOT2 0,	-1, unID, b, 3		: unID=unID+1
HOTSPOT2 0,  b, unID, b, 2		: unID=unID+1
Sur les deux axes en même temps
HOTSPOT2  0,  b, unID, a, 1+128	: unID=unID+1
HOTSPOT2 -1,  b, unID, a, 3		: unID=unID+1
HOTSPOT2  a,  b, unID, a, 2		: unID=unID+1
HOTSPOT2  a,  0, unID, b, 1+128	: unID=unID+1
HOTSPOT2  a, -1, unID, b, 3		: unID=unID+1
HOTSPOT2  a,  b, unID, b, 2		: unID=unID+1
Rotation
HOTSPOT2  0, 0, unID, angle, 6							: unID=unID+1
HOTSPOT2  A, 0, unID, angle, 4+128						: unID=unID+1
HOTSPOT2  A*COS(angle), A*SIN(angle), unID, angle, 5	: unID=unID+1

3D

Déplacements

Sur l'axe X
HOTSPOT  0, 0, 0, unID, a, 1+128	: unID=unID+1
HOTSPOT -1, 0, 0, unID, a, 3		: unID=unID+1
HOTSPOT  a, 0, 0, unID, a, 2		: unID=unID+1
Sur l'axe Y
HOTSPOT 0,  0,	0, unID, b, 1+128	: unID=unID+1
HOTSPOT 0,	-1,	0, unID, b, 3		: unID=unID+1
HOTSPOT 0,  b,	0, unID, b, 2		: unID=unID+1
Sur l'axe Z
HOTSPOT 0, 0,  0, unID, ZZYZX, 1+128	: unID=unID+1
HOTSPOT 0, 0,	-1, unID, ZZYZX, 3		: unID=unID+1
HOTSPOT 0, 0,  ZZYZX, unID, ZZYZX, 2	: unID=unID+1

HOTLINE

Boite englobante

HOTLINE2 0, 0, a, 0
HOTLINE2 a, 0, a, b
HOTLINE2 0, b, a, b
HOTLINE2 0, 0, 0, b

Gestion de l'affichage

Affichage différent en fonction de l'étage d'implantation

  • L'objet placé doit être paramétré en "Visible sur tous les étages"
zz = REQUEST ("Story", "", index1, story_name) ! Étage affiché
zz = REQUEST ("Home_story", "", index2, home_story_name) ! Étage d'implantation de l'objet

IF index1 > index2 THEN
	!Symbole 2D affiché au dessus de l'étage d'implantation
ENDIF
IF index1 = index2 THEN
	!Symbole 2D affiché sur l'étage d'implantation
ENDIF
IF index1 < index2 THEN
	!Symbole 2D affiché en dessous de l'étage d'implantation
ENDIF

Orientation 2D

MUL2 1 - 2 * SYMB_MIRRORED, 1
r = request ("View_Rotangle", "", _angleViewRot)

! Actual rotation of the 2D symbol:	
_totalRotate	= (SYMB_ROTANGLE + _angleViewRot) MOD 360

! Count the number of transformations of the 
! coordinate system in different cases
_nTrans = 0

Toujours horizontal

rot2 _totalRotate * (SYMB_MIRRORED - not(SYMB_MIRRORED))
_nTrans = _nTrans + 1

Lisible

IF (_totalRotate > (90 + 90*SYMB_MIRRORED + EPS) & _totalRotate < (270 + 90*SYMB_MIRRORED + EPS)) THEN
    ROT2 180
    _nTrans = _nTrans + 1
ENDIF

Script interface

ui_dialog `Paramètres personnalisés`,444,266

Checkbox (texte cliquable)

ui_infield{3} "bool-parameter", 240, 30, 110, 15,
7, "",
2,
1, 20, 20, 20, 20,
0, "Texte", 0,
1, "Texte", 1

Liste de polices

dim fontnames[]
n = REQUEST ("FONTNAMES_LIST", "", fontnames)
ui_outfield `Police`,		10, 14, 100, 15 
ui_custom_popup_infield "sampleName", 	115, 10, 150, 20,
	0, 0, 1, "", fontnames

On peut aussi récupérer la liste directement en utilisant ces noms de paramètres (type texte) :

  • fontType
  • fontType2
  • fontType3

Liste des images chargées en bibliothèques

En utilisant ces noms de paramètres (type texte) :

  • gs_picture_name
  • gs_picture_name_2D

Icones mise en forme de texte

Pour avoir les icônes Gras, Italique, Souligné et Barré qui gère automatiquement la valeur du code pour mettre en forme un texte dans un style :

ui_textstyle_infield "styleTexte", 1+2+4+128, x, y, buttonWidth, buttonHeight, buttonOffsetX

("styleTexte" est un paramètre de type entier)

define style name fontType, size, anchor, styleTexte

Macros

Suis-je une macro ?

nameM=""
sts=REQUEST("name_of_main","",nameM)
IF NOT(nameM="") THEN
  PRINT nameM+" is CALLing me!"
ELSE
  PRINT "I am free!"
ENDIF

Mathématiques

Comparaisons

ABS( A - B )>EPS   ! A<>B
ABS( A - B )<EPS   ! A=B
A - B < EPS        ! A<=B
A - B < -EPS       ! A<B
B - A > EPS        ! A<B
B - A < EPS        ! A>=B
B - A < -EPS       ! A>B
A - B > EPS        ! A>B

Trucs & astuces divers

Transformer POLY_B{5} en PRISM_ à l'aide d'une recherche REGEX

Dans un éditeur de texte supportant les recherches REGEX (Regular Expression) :

Chercher : (?-s)^\t*poly2_b\{5\} *([0-9]+),(?s).*? 0, $

Remplacer par : PRISM_ \1, b,