Code snippet

De Wiki-Cadlink
Sauter à la navigation Sauter à la recherche

HOTSPOT

2D

Boites englobantes

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
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

Boites englobantes

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 sur étage supérieur

zz = REQUEST ("Story", "", index1, story_name)
zz = REQUEST ("Home_story", "", index2, home_story_name)

IF index1 = index2 OR (index1 > index2 AND aff_eta_sup) THEN

	!Symbole 2D

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 + EPS) & _totalRotate < (270 + 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

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,