rrobert Posté(e) le 20 mai 2021 Posté(e) le 20 mai 2021 Bonjour, Est-il possible en diesel de détecter si une touche clavier (par exemple Ctrl) est appuyée? Merci, Rémi
Luna Posté(e) le 20 mai 2021 Posté(e) le 20 mai 2021 Coucou, Si on s'en tient à l'aide AutoCAD : DIESEL Functions Reference Status retrieval, computation, and display are performed by DIESEL functions. All functions have a limit of 10 parameters, including the function name itself. Function Description/Example + (addition) Returns the sum of the numbers val1 , val2 , …, val9 . $(+, val1 [, val2, …, val9]) If the current thickness is set to 5, the following DIESEL string returns 15. $(+, $(getvar, thickness), 10) - (subtraction) Returns the result of subtracting the numbers val2 through val9 from val1 . $(-, val1 [, val2 , …, val9]) * (multiplication) Returns the result of multiplying the numbers val1 , val2 , …, val9 . $(*, val1 [, val2, …, val9]) / (division) Returns the result of dividing the number val1 by val2 , …, val9 . $(/, val1 [, val2, …, val9]) = (equal to) If the numbers val1 and val2 are equal, the string returns 1; otherwise, it returns 0. $(=, val1, val2) < (less Than) If the number val1 is less than val2 , the string returns 1; otherwise, it returns 0. $(<, val1, val2) The following expression gets the current value of HPANG; if the value is less than the value stored in the system variable USERR1, it returns 1. If the value 10.0 is stored in USERR1 and the current setting of HPANG is 15.5, the following string returns 0. $(<, $(getvar, hpang), $(getvar, userr1)) > (greater Than) If the number val1 is greater than val2 , the string returns 1; otherwise, it returns 0. $(>, val1, val2) != (not Equal to) If the numbers val1 and val2 are not equal, the string returns 1; otherwise, it returns 0. $(!=, val1, val2) <= (less Than or Equal to) If the number val1 is less than or equal to val2 , the string returns 1; otherwise, it returns 0. $(<=, val1, val2) >= (greater Than or Equal to) If the number val1 is greater than or equal to val2 , the string returns 1; otherwise, it returns 0. $(>=, val1, val2) and Returns the bitwise logical AND of the integers val1 through val9 . $(and, val1 [, val2,…, val9]) angtos Returns the angular value in the format and precision specified. $(angtos, value [, mode, precision]) Edits the given value as an angle in the format specified by the mode and precision as defined for the analogous AutoLISP function. If mode and precisionare omitted, it uses the current values chosen by the UNITS command. Note: AutoLISP is not available in AutoCAD LT. The following mode values can be applied: 0, for Degrees 1, for Degrees/Minutes/Seconds 2, for Grads 3, for Radians 4, for Surveyor's Units Edtime Returns a formatted date and time based on a given picture. $(edtime, time, picture) Edits the Julian date given by time (obtained, for example, from $(getvar,date) according to the given picture ). The picture consists of format phrases replaced by specific representations of the date and time. Characters not interpretable as format phrases are copied literally into the result of $(edtime) . Format phrases are defined as shown in the following table. For example, assume that the date and time are Saturday, 5 September 1998 4:53:17.506 the corresponding format phrases and output examples for edtime are as follows: D - 5 DD - 05 DDD - Sat DDDD - Saturday M - 9 MO - 09 MON - Sep MONTH - September YY - 98 YYYY - 1998 H - 4 HH - 04 MM - 53 SS - 17 MSEC - 506 AM/PM - AM am/pm - am A/P - A a/p - a Enter the entire AM/PM phrase as shown in the preceding table; if AM is used alone, the A will be read literally and the M will return the current month. If any AM/PM phrases appear in the picture, the H and HH phrases edit the time according to the 12-hour civil clock (12:00-12:59 1:00-11:59) instead of the 24-hour clock (00:00-23:59). The following example uses the date and time from the preceding table. Notice that the comma must be enclosed in quotation marks because it is read as an argument separator. $(edtime, $(getvar,date), DDD"," DD MON YYYY - H:MMam/pm) It returns the following: Sat, 5 Sep 1998 - 4:53am If time is 0, the time and date at the moment that the outermost macro was executed is used. This avoids lengthy and time-consuming multiple calls on$(getvar,date) and guarantees that strings composed with multiple $(edtime) macros all use the same time. eq If the strings val1 and val2 are identical, the string returns 1; otherwise, it returns 0. $(eq, val1, val2) The following expression gets the name of the current layer; if the name matches the string value stored in the USERS1 (USERS1-5) system variable, it returns 1. Assume the string "PART12" is stored in USERS1 and the current layer is the same. Note: The USERS1-5 system variables are not available in AutoCAD LT. $(eq, $(getvar, users1), $(getvar, clayer)) It returns the following: 1 Eval Passes the string str to the DIESEL evaluator and returns the result of evaluating it. $(eval, str) fix Truncates the real number value to an integer by discarding any fractional part. $(fix, value) Getenv Returns the value of the environment variable varname . $(getenv, varname) If no variable with that name is defined, it returns the null string. Getvar Returns the value of the system variable with the given varname . $(getvar, varname) if Conditionally evaluates expressions. $(if, expr, dotrue [, dofalse]) If expr is nonzero, it evaluates and returns dotrue . Otherwise, it evaluates and returns dofalse . Note that the branch not chosen by expr is not evaluated. Index Returns the specified member of a comma-delimited string. $(index, which, string) Assumes that the string argument contains one or more values delimited by the macro argument separator character, the comma. The which argument selects one of these values to be extracted, with the first item numbered 0. This function is most frequently used to extract X, Y, or Z coordinate values from point coordinates returned by $(getvar). Applications can use this function to retrieve values stored as comma-delimited strings from the USERS1-5 system variables. Note: The USERS1-5 system variables are not available in AutoCAD LT. nth Evaluates and returns the argument selected by which . $(nth, which, arg0 [, arg1,…, arg7]) If which is 0, nth returns arg0 , and so on. Note the difference between $(nth) and $(index) ; $(nth) returns one of a series of arguments to the function, while $(index) extracts a value from a comma-delimited string passed as a single argument. Arguments not selected by which are not evaluated. or Returns the bitwise logical OR of the integers val1 through val9 . $(or, val1 [, val2,…, val9]) Rtos Returns the real value in the format and precision specified. $(rtos, value [, mode, precision]) Edits the given value as a real number in the format specified by mode and precision. If mode and precision are omitted, it uses the current values selected with the UNITS command. Strlen Returns the length of string in characters. $(strlen, string) Substr Returns the substring of string , starting at character start and extending for length characters. $(substr, string, start [, length]) Characters in the string are numbered from 1. If length is omitted, it returns the entire remaining length of the string. Upper Returns the string converted to uppercase according to the rules of the current locale. $(upper, string) xor Returns the bitwise logical XOR of the integers val1 through val9 . $(xor, val1 [, val2,…, val9]) Je ne vois rien qui puisse "lire" les saisies relatives au clavier, souris, etc... En LISP tu as bien entendu la fonction (grread) qui permet cela, mais c'est du LISP donc non fonctionnel sur les versions LT par exemple. grread (AutoLISP) Reads values from any of the AutoCAD input devices Supported Platforms: Windows and Mac OS Signature (grread [track] [allkeys [curtype]]) track Type: T or nil If supplied and not nil, this argument enables the return of coordinates from a pointing device as it is moved. allkeys Type: Integer Code that tells grread what functions to perform. The allkeys bit code values can be added together for combined functionality. The following values can be specified: 1(bit 0) -- Return drag mode coordinates. If this bit is set and the user moves the pointing device instead of selecting a button or pressing a key, grread returns a list where the first member is a type 5 and the second member is the (X,Y) coordinates of the current pointing device (mouse or digitizer) location. This is how AutoCAD implements dragging. 2 (bit 1) -- Return all key values, including function and cursor key codes, and do not move the cursor when the user presses a cursor key. 4 (bit 2) -- Use the value passed in the curtype argument to control the cursor display. 8 (bit 3) -- Do not display the error: console break message when the user presses Esc. curtype An integer indicating the type of cursor to be displayed. The allkeys value for bit 2 must be set for the curtype values to take effect. The curtype argument affects only the cursor type during the current grreadfunction call. You can specify one of the following values for curtype: 0 -- Display the normal crosshairs. 1 -- Do not display a cursor (no crosshairs). 2 -- Display the object-selection “target” cursor. Return Values Type: List The grread function returns a list whose first element is a code specifying the type of input. The second element of the list is either an integer or a point, depending on the type of input. The return values are listed in the following table: grread return values First element Second element Value Type of input Value Description 2 Keyboard input varies Character code 3 Selected point 3D point Point coordinates 4 Screen/pull-down menu item (from pointing device) 0 to 999 1001 to 1999 2001 to 2999 3001 to 3999 … and so on, to 16001 to 16999 Screen menu box no. POP1 menu box no. POP2 menu box no. POP3 menu box no. ... and so on, to POP16 menu box no. 5 Pointing device (returned only if tracking is enabled) 3D point Drag mode coordinate 6 BUTTONS menu item 0 to 999 1000 to 1999 2000 to 2999 3000 to 3999 BUTTONS1 menu button no. BUTTONS2 menu button no. BUTTONS3 menu button no. BUTTONS4 menu button no. 7 TABLET1 menu item 0 to 32767 Digitized box no. 8 TABLET2 menu item 0 to 32767 Digitized box no. 9 TABLET3 menu item 0 to 32767 Digitized box no. 10 TABLET4 menu item 0 to 32767 Digitized box no. 11 AUX menu item 0 to 999 1000 to 1999 2000 to 2999 3000 to 3999 AUX1 menu button no. AUX2 menu button no. AUX3 menu button no. AUX4 menu button no. Note: SHORTCUTMENU must be set to a value of 0. 12 Pointer button (follows a type 6 or type 11 return) 3D point Point coordinates 25 Pointer secondary button 0 or greater Screen coordinate value along the X axis Note: SHORTCUTMENU must be set to a value greater than 0. Remarks Only specialized AutoLISP routines need this function. Most input to AutoLISP should be obtained through the various getXXX functions. Entering Esc while a grread is active aborts the AutoLISP program with a keyboard break (unless the allkeys argument has disallowed this). Any other input is passed directly to grread, giving the application complete control over the input devices. If the user presses the pointer button within a screen menu or pull-down menu box, grread returns a type 6 or type 11 code, but in a subsequent call, it does not return a type 12 code: the type 12 code follows type 6 or type 11 only when the pointer button is pressed while it is in the drawing area. It is important to clear the code 12 data from the buffer before attempting another operation with a pointer button or an auxiliary button. To accomplish this, perform a nested grread like this: (setq code_12 (grread (setq code (grread)))) This sequence captures the value of the code 12 list as streaming input from the device. Donc pour répondre à ta question, je dirais que non, il faudrait forcément passer par du LISP (ou autre langage permettant d'accéder au device input). PS : Bon sang ce que j'aime cette mise à jour de CADxp, on peut copier/coller l'aide AutoCAD directement dans le message, avec le formatage qui suit ♥w♥. Bisous, Luna 1
rrobert Posté(e) le 20 mai 2021 Auteur Posté(e) le 20 mai 2021 J'avais effectivement pas mal potassé cette page d'aide au Diesel, sans rien trouver. Bon, encore un argument en faveur du lisp, décidément, faut vraiment que je m'y mette 😉 Merci Luna, Rémi
Messages recommandés
Créer un compte ou se connecter pour commenter
Vous devez être membre afin de pouvoir déposer un commentaire
Créer un compte
Créez un compte sur notre communauté. C’est facile !
Créer un nouveau compteSe connecter
Vous avez déjà un compte ? Connectez-vous ici.
Connectez-vous maintenant