Aller au contenu

créer une super calculatrice


sechanbask

Messages recommandés

Bonjour

Je souhaiterais réaliser un objet type "calculatrice (CTRL+8)" sous autocad 2006 avec les mêmes propriétés à savoir la transparence, l'utilisation sans passer par une macro qui exlue les retours vers le dessin...etc et bien sur veuillez m'indiquer le langage que je vais devoir utiliser... merci par avance...

ATEGIE - Bureau d'Études Fluides

http://www.ategie.fr/uploads/ategie/ategie-at%C3%A9gie-bureau-%C3%A9tudes-etudes-fluides-logo-100x56.png

Exécution, Synthèse, Conception, Maîtrise d'Oeuvre, Audit, Chiffrage

www.ategie.fr

Lien vers le commentaire
Partager sur d’autres sites

  • 3 semaines après...

Voici un début d'idée

 

UNE CALCULATRICE à 4 TOUCHES

 

1 créer une nouvelle boite à outils

 

click touche gauche de la souris en pointant sur un boutton existant

puis personnaliser

puis onglet barre outils -> touche nouvelle ->nommer calc (par ex)

 

puis ajouter 1 bouton ->ongelet commandes ->défini par utilisateur ->saisir bouton défini par utilisateur et glisser dans la nouvelle boîte à outils

->positionner la souris dans le nouveau bouton et appuyer touche droite de la souris -> choisir propriétés

->dans la case macro associé au bouton -> taper ou coller ^C^CSETENV;NUMB1;\ $P=CALC.POP11 $P=*

->sous icone de bouton ->editer -> cocher grille et dessiner "par ex 1 clavier" enregister et fermer

 

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

SI L'ON N'A FAIT AUCUNE PERSONNALISATION ON PEUT EGALEMENT METTRE LA TOUCHE DE DEMARRAGE aclt.mnu pout LTet

AutoCAD.mnu pour la version full et Autodesk Architectural Desktop,mnu pour la version architectureal desktop etc...

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

//

// Begin System Pointing Device Menus

//

***AUX1

$M=$(if,$(eq,$(substr,$(getvar,cmdnames),1,5),GRIP_),$P0=ACLT.GRIPS $P0=*,$(if,$(and,$(and,$(and,$(=,$(getvar,rtclickmenu),1),$(=,$(getvar,cmdactive),0),$(eq,$(getvar,curcmdln),""))),$(=,$(getvar,pickfirst),1)),$P0=*));

$P0=SNAP $p0=*

^C^C

^B

^O

^G

^D

^E

^T

[--]

[CALCULATRICE]^C^CSETENV;NUMB1;\ $P=CALC.POP11 $P=*

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 

 

CE QUI PERMET D'ACCEDER A LA CALCULATRICE PAR LE MENU CONTEXTUEL DE LA SOURIS

CLICK à DROITE

 

MAIS ATTENTION IL FAUT DECHARGER ET RECHARGER LE MENU ACLT LES PERSONALISATIONS

DES BOITES A OUTILS SERONT DEFINITIVEMENT PERDUES !!!!!!!!!!!!!!!!!

 

EN TOUS LES CAS FAIRE UNE SAUVEGERDE DES FICHIERS ACLT*.* AVANT SURTOUT LE ACLT5.CFG POUR LT

ET PROBABLEMENT AutoCAD*.* POUR LA VERSION FULL

 

 

 

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

 

 

 

 

Puis ouvrir Blocnote ou Wordpad ;

 

***MENUGROUP=calc

***POP11

[Calculatrice]

[+]^CSETENV;NUMB2;\^CSETENV;NUMB1;$M=$(+,$(getenv,NUMB1),$(getenv,NUMB2)); $P=CALC.POP11 $P=*

[--]

[ - ]^CSETENV;NUMB2;\^CSETENV;NUMB1;$M=$(-,$(getenv,NUMB1),$(getenv,NUMB2)); $P=CALC.POP11 $P=*

[--]

[ * ]^CSETENV;NUMB2;\^CSETENV;NUMB1;$M=$(*,$(getenv,NUMB1),$(getenv,NUMB2)); $P=CALC.POP11 $P=*

[--]

[ / ]^CSETENV;NUMB2;\^CSETENV;NUMB1;$M=$(/,$(getenv,NUMB1),$(getenv,NUMB2)); $P=CALC.POP11 $P=*

 

 

enregister sous le nom calc.mnu dans le repertoire principal de autocad ou à l'emplacement ou se trouve les fichiers menu

pour autocdlt--> aclt.mnu

 

On peut également mettre ses marcros dans quatre bouttons de la boite à outils à mon avis

l'avantage du menu pop c'est qu'il vient prendre place à l'endrit du curseur

 

pour charger le menu calc(ulatrice)

 

Outils puis Personnalier puis menu --> parcourir chercher l'emplacement de calc.mnu ->charger

 

Fonctionnement de la calculatrice:

 

1) cliquer boutton calc.

 

2) taper le 1er chiffre puis enter

 

3) dans le menu qui apparait choisir l'opération ( +, -, /, *)

 

4)taper le 2e chiffre

 

5) le résultat apparaît sur la ligne de commande

 

6) on peut renouveler l'opération à partir de 3) pour faire du calcul en chaine

 

pour un nouveau calcul recommancer à 1)

 

ce qui est décrit si dessus est valable pour le versions ligth

 

pour les version Full la commande SETENV et la fonction getenv n'exsistent pas

et l'on ne peut pas choisir librement le nom d'une variable NUMB1, NUMB2 etc

 

de mémoire il faut remplacer SETENV par SETVAR et getenv par getvar

et le nom de de la variable par USERR1, USERR2, USERR3 mais jusqu'à USERR5

 

ce qui donnerait ceci

 

1) pour le bouton de démarrage

 

^C^CSETVAR;USERR1;\ $P=CALC.POP11 $P=*

 

2) POUR LE MENU POP

 

 

***MENUGROUP=calc

***POP11

[Calculatrice]

[+]^CSETVAR;USERR2;\^CSETVAR;USERR1;$M=$(+,$(getvar,USERR1),$(getvar,USERR2)); $P=CALC.POP11 $P=*

[--]

[ - ]^CSETVAR;USERR2;\^CSETVAR;USERR1;$M=$(-,$(getvar,USERR1),$(getvar,USERR2)); $P=CALC.POP11 $P=*

[--]

[ * ]^CSETVAR;USERR2;\^CSETVAR;USERR1;$M=$(*,$(getvar,USERR1),$(getvar,USERR2)); $P=CALC.POP11 $P=*

[--]

[ / ]^CSETVAR;USERR2;\^CSETVAR;USERR1;$M=$(/,$(getvar,USERR1),$(getvar,USERR2)); $P=CALC.POP11 $P=*

 

 

C'est peut être pas une supercalculatrice mais c'est un début......

 

 

 

 

Lien vers le commentaire
Partager sur d’autres sites

Voici un lisp + le dcl associé qui permettent d'émuler une une calculatrice transparente pour les commande standard d'autocad, ne peut être employé à la suite d'un appel d'un autre lisp: c'est à dire fournir un calcul pour une commande crée en lisp.

 

Ces fichiers devront être placés dans un dossier de recherche d'autocad. Puis créez un nouveau bouton contenant la syntaxe suivante: 'DDCAL (pas de ^C^C proposé par défault lors de la création du bouton)

 

Un inconvénient et que la saisie numérique ne peut être faite qu'au pointeur de la souris, et non au clavier.

Vous aurez l'usage d'une calcultrice scientifique avec la possibilité d'acquérir des valeurs graphiques (longueur ou angulaire)

 

Ce lisp se décline sous deux versions, celle proposé dans ce post est en notation polonaise (utilisant la mise en pile, comme les anciennes calculatrices HP) pas de paranthèses mais usage NOMBRE mise en pile par ENTER puis SECOND NOMBRE et OPERATION à effectuer.

C'est celle que je préfère pour faire du calcul enchainé

 

Je fais un second post pour une calculatrice scientifique standard : NOMBRE OPERATION NOMBRE "="

 

Le lisp DDCAL.LSP

 

(defun fc_cal (op val)
(setq l_stk (append (cdr l_stk) '(0.0)))
(cal (strcat op " (val)"))
)
(defun ms_pil (val / )
(cons val (reverse (cdr (reverse l_stk))))
)
(defun cvs (val com? / mod)
(cond
	((eq md_aun 0)
		(setq mod 180.0)
	)
	((eq md_aun 2)
		(setq mod 200.0)
	)
	((eq md_aun 3)
		(setq mod pi)
	)
)
(if com?
	(/ (* val 180) mod)
	(/ (* val mod) 180)
)
)
(defun fcprss (fonc / tmp r1 r2)
(setq first T)
(setq entier "0" decima "." dec_? nil md_stk nil)
(cond
	(md_mem
		(setvar "userr1" (eval (read (strcat "(" fonc "(getvar " "\"USERR1" "\") (car l_stk))"))))
		(foreach
			n
			'("PICK" "STO" "RCL" "MOP" "SIG" "^" "ASI" "ACO" "ATA" "PI" "SIN" "COS" "TAN" "PU2" "SQR" "INV" "CLR" "ST_UP" "ST_DW" "CLX" "7" "8" "9" "6" "5" "4" "3" "2" "1" "0" "." "DSP" "accept")
			(mode_tile n 0)
		)
		(setq md_mem nil)
	)
	(T
(cond
	((eq fonc "DSP")
		(foreach
			n
			'("PICK" "STO" "RCL" "MOP" "SIG" "^" "ASI" "ACO" "ATA" "PI" "SIN" "COS" "TAN" "PU2" "SQR" "INV" "CLR" "ST_UP" "ST_DW" "CLX" "-"  "+"  "*" "/" "." "DSP" "accept")
			(mode_tile n 1)
		)
		(setq md_dsp T)
	)
	((eq fonc "STO")
		(foreach
			n
			'("PICK" "STO" "RCL" "MOP" "SIG" "^" "ASI" "ACO" "ATA" "PI" "SIN" "COS" "TAN" "PU2" "SQR" "INV" "CLR" "ST_UP" "ST_DW" "CLX" "-" "7" "8" "9" "+" "6" "*" "/" "0" "." "DSP" "accept")
			(mode_tile n 1)
		)
		(setq md_stk T)
	)
	((eq fonc "RCL")
		(foreach
			n
			'("PICK" "STO" "RCL" "MOP" "SIG" "^" "ASI" "ACO" "ATA" "PI" "SIN" "COS" "TAN" "PU2" "SQR" "INV" "CLR" "ST_UP" "ST_DW" "CLX" "-" "7" "8" "9" "+" "6" "*" "/" "0" "." "DSP" "accept")
			(mode_tile n 1)
		)
		(setq md_rcl T)
	)
	((eq fonc "MOP")
		(foreach
			n
			'("PICK" "STO" "RCL" "MOP" "SIG" "^" "ASI" "ACO" "ATA" "PI" "SIN" "COS" "TAN" "PU2" "SQR" "INV" "CLR" "ST_UP" "ST_DW" "CLX" "7" "8" "9" "6" "5" "4" "3" "2" "1" "0" "." "DSP" "accept")
			(mode_tile n 1)
		)
		(setq md_mem T)
	)
	((eq fonc "SIG")
		(setq l_stk (ms_pil (fc_cal "-" (car l_stk))))
	)
	((eq fonc "ASI")
		(if (or (> (car l_stk) 1.0) (< (car l_stk) -1.0))
			(alert "La valeur doit être comprise entre -1 et 1")
			(setq l_stk (ms_pil (cvs (fc_cal "asin" (car l_stk)) nil)))
		)
	)
	((eq fonc "ACO")
		(if (or (> (car l_stk) 1.0) (< (car l_stk) -1.0))
			(alert "La valeur doit être comprise entre -1 et 1")
			(setq l_stk (ms_pil (cvs (fc_cal "acos" (car l_stk)) nil)))
		)
	)
	((eq fonc "ATA")
		(setq l_stk (ms_pil (cvs (fc_cal "atan" (car l_stk)) nil)))
	)
	((eq fonc "PI")
		(setq l_stk (ms_pil (cal "pi")))
	)
	((eq fonc "SIN")
		(setq l_stk (ms_pil (fc_cal "sin" (cvs (car l_stk) T))))
	)
	((eq fonc "COS")
		(setq l_stk (ms_pil (fc_cal "cos" (cvs (car l_stk) T))))
	)
	((eq fonc "TAN")
		(setq tmp (cvs (car l_stk) T))
		(if (eq (abs (cal "sin (tmp)")) 1.0)
			(alert "Valeur de la tangente ne peut tendre vers l'infini")
			(setq l_stk (ms_pil (fc_cal "tang" (cvs (car l_stk) T))))
		)
	)
	((eq fonc "PU2")
		(setq l_stk (ms_pil (fc_cal "sqr" (car l_stk))))
	)
	((eq fonc "SQR")
		(if (< (car l_stk) 0.0)
			(alert "Racine carré d'un nombre négatif impossible")
			(setq l_stk (ms_pil (fc_cal "sqrt" (car l_stk))))
		)
	)
	((eq fonc "INV")
		(if (zerop (car l_stk))
			(alert "Inverse de zéro impossible")
			(setq l_stk (ms_pil (fc_cal "1.0 /" (car l_stk))))
		)
	)
	((eq fonc "CLR")
		(setq l_stk '(0.0 0.0 0.0 0.0))
	)
	((eq fonc "CLX")
		(setq l_stk (append (cdr l_stk) '(0.0)))
	)
	((eq fonc "ST_UP")
		(setq l_stk (ms_pil (car l_stk)) first nil)
	)
	((eq fonc "ST_DW")
		(setq l_stk (append (cdr l_stk) (list (car l_stk))))
	)
	((or (eq fonc "+") (eq fonc "-") (eq fonc "*") (eq fonc "/") (eq fonc "^"))
		(setq r1 (car l_stk) r2 (cadr l_stk) l_stk (append (cddr l_stk) '(0.0 0.0)))
		(setq l_stk (ms_pil (cal (strcat "r2" fonc "r1"))))
	)
)
(set_tile "DISPLAY" (rtos (car l_stk) 2 nbdec))
	)
)
)
(defun nbprss (numb / )
(if (eq numb ".")
	(setq numb "0.0")
)
(cond
	(md_dsp
		(setq nbdec (atoi numb) md_dsp nil)
		(foreach
			n
			'("PICK" "STO" "RCL" "MOP" "SIG" "^" "ASI" "ACO" "ATA" "PI" "SIN" "COS" "TAN" "PU2" "SQR" "INV" "CLR" "ST_UP" "ST_DW" "CLX" "-" "7" "8" "9" "+" "6" "*" "/" "0" "." "DSP" "accept")
			(mode_tile n 0)
		)
		(set_tile "DISPLAY" (rtos (car l_stk) 2 nbdec))
	)
	(md_stk
		(setvar (strcat "USERR" numb) (car l_stk))
		(setq entier "0" decima "." dec_? nil md_stk nil)
		(foreach
			n
			'("PICK" "STO" "RCL" "MOP" "SIG" "^" "ASI" "ACO" "ATA" "PI" "SIN" "COS" "TAN" "PU2" "SQR" "INV" "CLR" "ST_UP" "ST_DW" "CLX" "-" "7" "8" "9" "+" "6" "*" "/" "0" "." "DSP" "accept")
			(mode_tile n 0)
		)
	)
	(md_rcl
		(if (not (getvar (strcat "USERR" numb)))
			(setq l_stk (ms_pil 0.0))
			(setq l_stk (ms_pil (getvar (strcat "USERR" numb))))
		)
		(setq entier "0" decima "." dec_? nil md_rcl nil)
		(foreach
			n
			'("PICK" "STO" "RCL" "MOP" "SIG" "^" "ASI" "ACO" "ATA" "PI" "SIN" "COS" "TAN" "PU2" "SQR" "INV" "CLR" "ST_UP" "ST_DW" "CLX" "-" "7" "8" "9" "+" "6" "*" "/" "0" "." "DSP" "accept")
			(mode_tile n 0)
		)
	)
	(T
		(cond
			((eq (type (read numb)) 'REAL)
				(setq dec_? T)
			)
			(T
				(if dec_?
					(setq decima (strcat decima numb))
					(setq entier (itoa (atoi (strcat entier numb))))
				)
				(if first
					(setq l_stk (ms_pil (atof (strcat entier decima))) first nil)
					(setq l_stk (cons (atof (strcat entier decima)) (cdr l_stk)))
				)
			)
		)
	)
)
(set_tile "DISPLAY" (rtos (car l_stk) 2 nbdec))
)
(defun c:DDCAL ( / old_zin md_aun nbdec entier decima dec_? first l_stk dcl_id what_next pt1 pt2 md_dsp md_stk md_rcl md_mem)
(if (not (member T (mapcar '(lambda (x) (wcmatch (strcase x) "GEOMCAL.ARX")) (arx))))
	(arxload "geomcal")
)
(setq
	old_zin (getvar "dimzin")
	md_aun 0
	nbdec (getvar "luprec")
	entier "0"
	decima "."
	dec_? nil
	first T
	l_stk '(0.0 0.0 0.0 0.0)
	dcl_id (load_dialog "ddcal")
	what_next 2
)
(setvar "dimzin" 0)
(while (> what_next 1)
	(if (not (new_dialog "ddcal" dcl_id)) (exit))
	(cond
		((eq md_aun 0)
			(set_tile "DG" "1")
			(mode_tile "DG" 2)
		)
		((eq md_aun 3)
			(set_tile "RD" "1")
			(mode_tile "RD" 2)
		)
		((eq md_aun 2)
			(set_tile "GR" "1")
			(mode_tile "GR" 2)
		)
	)
	(set_tile "DISPLAY" (rtos (car l_stk) 2 nbdec))
	(action_tile "PICK" "(done_dialog 2)")
	(action_tile "STO" "(fcprss $key)")
	(action_tile "RCL" "(fcprss $key)")
	(action_tile "MOP" "(fcprss $key)")
	(action_tile "SIG" "(fcprss $key)")
	(action_tile "DG" "(setq md_aun 0)")
	(action_tile "RD" "(setq md_aun 3)")
	(action_tile "GR" "(setq md_aun 2)")
	(action_tile "^" "(fcprss $key)")
	(action_tile "ASI" "(fcprss $key)")
	(action_tile "ACO" "(fcprss $key)")
	(action_tile "ATA" "(fcprss $key)")
	(action_tile "PI" "(fcprss $key)")
	(action_tile "SIN" "(fcprss $key)")
	(action_tile "COS" "(fcprss $key)")
	(action_tile "TAN" "(fcprss $key)")
	(action_tile "PU2" "(fcprss $key)")
	(action_tile "SQR" "(fcprss $key)")
	(action_tile "INV" "(fcprss $key)")
	(action_tile "CLR" "(fcprss $key)")
	(action_tile "ST_UP" "(fcprss $key)")
	(action_tile "ST_DW" "(fcprss $key)")
	(action_tile "CLX" "(fcprss $key)")
	(action_tile "-" "(fcprss $key)")
	(action_tile "7" "(nbprss $key)")
	(action_tile "8" "(nbprss $key)")
	(action_tile "9" "(nbprss $key)")
	(action_tile "+" "(fcprss $key)")
	(action_tile "4" "(nbprss $key)")
	(action_tile "5" "(nbprss $key)")
	(action_tile "6" "(nbprss $key)")
	(action_tile "*" "(fcprss $key)")
	(action_tile "1" "(nbprss $key)")
	(action_tile "2" "(nbprss $key)")
	(action_tile "3" "(nbprss $key)")
	(action_tile "/" "(fcprss $key)")
	(action_tile "0" "(nbprss $key)")
	(action_tile "." "(nbprss $key)")
	(action_tile "DSP" "(fcprss $key)")
	(action_tile "accept" "(done_dialog 1)")
	(action_tile "cancel" "(done_dialog 0)")
	(setq what_next (start_dialog))
	(cond
		((= what_next 2)
			(initget 41)
			(setq pt1 (getpoint "\nPremier point: "))
			(initget 41)
			(setq pt2 (getpoint "\nSecond point: "))
			(initget "Distance Angle")
			(if (eq (getkword "\n[Distance/Angle] : ") "Angle")
				(setq l_stk (ms_pil (cvs (cal "ang (pt1,pt2)") nil)))
				(setq l_stk (ms_pil (cal "dist (pt1,pt2)")))
			)
		)
	)
)
(unload_dialog dcl_id)
(setvar "dimzin" old_zin)
(if (not (zerop what_next))
	(if (< nbdec 9)
		(read (rtos (car l_stk) 2 nbdec))
		(car l_stk)
	)
)
)

 

le dcl DDCAL.DCL

ddcal : dialog {
label = "Calculette";
:row {
	:text {
		label = "Hewlett Packard";
	}
}
:boxed_row {
	:text {
		key = "DISPLAY";
		width = 15;
	}
}
:row {
	:button {
		label    = ">> Saisie graphique";
		key      = "PICK";
	}
}
:row {
	:radio_button {
		label = "Dg";
		key = "DG";
	}
	:radio_button {
		label = "Rd";
		key = "RD";
	}
	:radio_button {
		label = "Gr";
		key = "GR";
	}
}
:row {
:column {
	width = 10;
	:button {
		label    = "M1f";
		key      = "MOP";
	}
	:button {
		label    = "Y^x";
		key      = "^";
	}
	:button {
		label    = "¶";
		key      = "PI";
	}
	:button {
		label    = "x²";
		key      = "PU2";
	}
}
:column {
	width = 10;
	:button {
		label    = "±";
		key      = "SIG";
	}
	:button {
		label    = "aSI";
		key      = "ASI";
	}
	:button {
		label    = "Sin";
		key      = "SIN";
	}
	:button {
		label    = "V¯";
		key      = "SQR";
	}
}
:column {
	width = 10;
	:button {
		label    = "STO";
		key      = "STO";
	}
	:button {
		label    = "aCO";
		key      = "ACO";
	}
	:button {
		label    = "Cos";
		key      = "COS";
	}
	:button {
		label    = "1/x";
		key      = "INV";
	}
}
:column {
	width = 10;
	:button {
		label    = "RCL";
		key      = "RCL";
	}
	:button {
		label    = "aTA";
		key      = "ATA";
	}
	:button {
		label    = "Tan";
		key      = "TAN";
	}
	:button {
		label    = "CLR";
		key      = "CLR";
	}
}
}
:row {
:column {
	width = 20;
	:button {
		label    = "  ->  ENTER ";
		key      = "ST_UP";
	}
}
:column {
	width = 10;
	:button {
		label    = "<-R";
		key      = "ST_DW";
	}
}
:column {
	width = 10;
	:button {
		label    = "CLx";
		key      = "CLX";
	}
}
}
:row {
:column {
	width = 10;
	:button {
		label    = "-";
		key      = "-";
	}
	:button {
		label    = "+";
		key      = "+";
	}
	:button {
		label    = "X";
		key      = "*";
	}
	:button {
		label    = "÷";
		key      = "/";
	}
}
:column {
	width = 10;
	:button {
		label    = "7";
		key      = "7";
	}
	:button {
		label    = "4";
		key      = "4";
	}
	:button {
		label    = "1";
		key      = "1";
	}
	:button {
		label    = "0";
		key      = "0";
	}
}
:column {
	width = 10;
	:button {
		label    = "8";
		key      = "8";
	}
	:button {
		label    = "5";
		key      = "5";
	}
	:button {
		label    = "2";
		key      = "2";
	}
	:button {
		label    = ".";
		key      = ".";
	}
}
:column {
	width = 10;
	:button {
		label    = "9";
		key      = "9";
	}
	:button {
		label    = "6";
		key      = "6";
	}
	:button {
		label    = "3";
		key      = "3";
	}
	:button {
		label    = "DSP";
		key      = "DSP";
	}
}
}
ok_cancel;
}

 

NB Ces fichiers devront être chargés au démarrage d'autocad pour fonctionner.

 

C'est quand même un peu pour le "fun" car l'usage de la commande calc d'autocad fait très bien l'affaire.

Choisissez un travail que vous aimez et vous n'aurez pas à travailler un seul jour de votre vie. - Confucius

Lien vers le commentaire
Partager sur d’autres sites

Et les fichiers pour une calculatrice scientifique utilisée en majorité par un grand nombre de personnes.

(En notation polonaise, les gens cherchent toujours le signe = )

 

le lisp DDCAL.LSP

(defun cvs (val com? / mod)
(cond
	((eq md_aun 0)
		(setq mod 180.0)
	)
	((eq md_aun 2)
		(setq mod 200.0)
	)
	((eq md_aun 3)
		(setq mod pi)
	)
)
(if com?
	(/ (* val 180) mod)
	(/ (* val mod) 180)
)
)
(defun entry (numb / )
(if (eq numb ".")
	(setq numb "0.0")
)
(cond
	((eq (type (read numb)) 'REAL)
		(setq dec_? T)
	)
	((eq (type (read numb)) 'INT)
		(cond
			(md_arr
				(setq nbdec (atoi numb) md_arr nil rslt ms_pil)
				(foreach
					n
					'("PICK" "STO" "RCL" "ABS" "ARR" "SIG" "ASI" "ACO" "ATA" "PI" "SIN" "COS" "TAN" "PUI" "SQR" "INV" "CLS" "." "+" "-" "*" "/" "=" "accept")
					(mode_tile n 0)
					)
			)
			(md_stk
				(setvar (strcat "USERR" numb) rslt)
				(setq entier "0" decima "." dec_? nil md_stk nil)
				(foreach
					n
					'("PICK" "STO" "RCL" "ABS" "ARR" "SIG" "ASI" "ACO" "ATA" "PI" "SIN" "COS" "TAN" "PUI" "SQR" "INV" "CLS" "0" "6" "7" "8" "9" "." "+" "-" "*" "/" "=" "accept")
					(mode_tile n 0)
					)
			)
			(md_rcl
				(if (not (getvar (strcat "USERR" numb)))
					(setq rslt 0.0)
					(setq rslt (getvar (strcat "USERR" numb)))
				)
				(setq entier "0" decima "." dec_? nil md_rcl nil)
				(foreach
					n
					'("PICK" "STO" "RCL" "ABS" "ARR" "SIG" "ASI" "ACO" "ATA" "PI" "SIN" "COS" "TAN" "PUI" "SQR" "INV" "CLS" "0" "6" "7" "8" "9" "." "+" "-" "*" "/" "=" "accept")
					(mode_tile n 0)
					)
			)
			(T
				(if dec_?
					(setq decima (strcat decima numb))
					(setq entier (itoa (atoi (strcat entier numb))))
				)
				(setq rslt (atof (strcat entier decima)))
			)
		)
	)
	((eq (type (read numb)) 'SYM)
		(cond
			((eq numb "STO")
				(foreach
					n
					'("PICK" "STO" "RCL" "ABS" "ARR" "SIG" "ASI" "ACO" "ATA" "PI" "SIN" "COS" "TAN" "PUI" "SQR" "INV" "CLS" "0" "6" "7" "8" "9" "." "+" "-" "*" "/" "=" "accept")
					(mode_tile n 1)
					)
				(setq md_stk T)
			)
			((eq numb "RCL")
				(foreach
					n
					'("PICK" "STO" "RCL" "ABS" "ARR" "SIG" "ASI" "ACO" "ATA" "PI" "SIN" "COS" "TAN" "PUI" "SQR" "INV" "CLS" "0" "6" "7" "8" "9" "." "+" "-" "*" "/" "=" "accept")
					(mode_tile n 1)
					)
				(setq md_rcl T)
			)
			((eq numb "ABS")
				(setq rslt (cal "abs (rslt)") entier "0" decima "." dec_? nil)
			)
			((eq numb "ARR")
				(foreach
					n
					'("PICK" "STO" "RCL" "ABS" "ARR" "SIG" "ASI" "ACO" "ATA" "PI" "SIN" "COS" "TAN" "PUI" "SQR" "INV" "CLS" "." "+" "-" "*" "/" "=" "accept")
					(mode_tile n 1)
					)
				(setq ms_pil rslt md_arr T)
			)
			((eq numb "SIG")
				(setq rslt (cal "- rslt"))
			)
			((eq numb "ASI")
				(if (or (> rslt 1.0) (< rslt -1.0))
					(alert "La valeur doit être comprise entre -1 et 1")
					(setq rslt (cvs (cal "asin (rslt)") nil) entier "0" decima "." dec_? nil)
				)
			)
			((eq numb "ACO")
				(if (or (> rslt 1.0) (< rslt -1.0))
					(alert "La valeur doit être comprise entre -1 et 1")
					(setq rslt (cvs (cal "acos (rslt)") nil) entier "0" decima "." dec_? nil)
				)
			)
			((eq numb "ATA")
				(setq rslt (cvs (cal "atan (rslt)") nil) entier "0" decima "." dec_? nil)
			)
			((eq numb "PI")
				(setq rslt (cal "pi") entier "0" decima "." dec_? nil)
			)
			((eq numb "SIN")
				(setq rslt (cvs rslt T) rslt (cal "sin (rslt)") entier "0" decima "." dec_? nil)
			)
			((eq numb "COS")
				(setq rslt (cvs rslt T) rslt (cal "cos (rslt)") entier "0" decima "." dec_? nil)
			)
			((eq numb "TAN")
				(setq tmp (cvs rslt T))
				(if (eq (abs (cal "sin (tmp)")) 1.0)
					(alert "Valeur de la tangente ne peut tendre vers l'infini")
					(setq rslt (cvs rslt T) rslt (cal "tang (rslt)") entier "0" decima "." dec_? nil)
				)
			)
			((eq numb "PUI")
				(setq rslt (cal "sqr (rslt)") entier "0" decima "." dec_? nil)
			)
			((eq numb "SQR")
				(if (< rslt 0.0)
					(alert "Racine carré d'un nombre négatif impossible")
					(setq rslt (cal "sqrt (rslt)") entier "0" decima "." dec_? nil)
				)
			)
			((eq numb "INV")
				(if (zerop rslt)
					(alert "Inverse de zéro impossible")
					(setq rslt (cal "1.0 / rslt") entier "0" decima "." dec_? nil)
				)
			)
			((eq numb "CLS")
				(setq rslt 0.0 entier "0" decima "." dec_? nil)
			)
			((or (eq numb "+") (eq numb "-") (eq numb "*") (eq numb "/"))
				(setq ms_pil rslt rslt 0.0 entier "0" decima "." dec_? nil oper numb)
			)
			((eq numb "=")
				(setq rslt (cal (strcat "ms_pil" oper "rslt")) entier "0" decima "." dec_? nil)
			)
		)
	)
)
(set_tile "dsp" (rtos rslt 2 nbdec))
)
(defun c:DDCAL ( / old_zin md_aun rslt nbdec entier decima dec_? dcl_id what_next pt1 pt2 ms_pil oper md_arr md_stk md_rcl)
(if (not (member T (mapcar '(lambda (x) (wcmatch (strcase x) "GEOMCAL.ARX")) (arx))))
	(arxload "geomcal")
)
(setq old_zin (getvar "dimzin"))
(setvar "dimzin" 0)
(setq rslt 0.0 nbdec (getvar "luprec"))
(setq entier "0" decima "." dec_? nil md_aun 0)
(setq dcl_id (load_dialog "ddcal"))
(setq what_next 2)
(while (> what_next 1)
	(if (not (new_dialog "ddcal" dcl_id)) (exit))
	(cond
		((eq md_aun 0)
			(set_tile "DG" "1")
			(mode_tile "DG" 2)
		)
		((eq md_aun 3)
			(set_tile "RD" "1")
			(mode_tile "RD" 2)
		)
		((eq md_aun 2)
			(set_tile "GR" "1")
			(mode_tile "GR" 2)
		)
	)
	(set_tile "dsp" (rtos rslt 2 nbdec))
	(action_tile "PICK" "(done_dialog 2)")
	(action_tile "STO" "(entry $key)")
	(action_tile "RCL" "(entry $key)")
	(action_tile "ABS" "(entry $key)")
	(action_tile "ARR" "(entry $key)")
	(action_tile "DG" "(setq md_aun 0)")
	(action_tile "RD" "(setq md_aun 3)")
	(action_tile "GR" "(setq md_aun 2)")
	(action_tile "SIG" "(entry $key)")
	(action_tile "ASI" "(entry $key)")
	(action_tile "ACO" "(entry $key)")
	(action_tile "ATA" "(entry $key)")
	(action_tile "PI" "(entry $key)")
	(action_tile "SIN" "(entry $key)")
	(action_tile "COS" "(entry $key)")
	(action_tile "TAN" "(entry $key)")
	(action_tile "PUI" "(entry $key)")
	(action_tile "SQR" "(entry $key)")
	(action_tile "INV" "(entry $key)")
	(action_tile "CLS" "(entry $key)")
	(action_tile "7" "(entry $key)")
	(action_tile "8" "(entry $key)")
	(action_tile "9" "(entry $key)")
	(action_tile "-" "(entry $key)")
	(action_tile "4" "(entry $key)")
	(action_tile "5" "(entry $key)")
	(action_tile "6" "(entry $key)")
	(action_tile "+" "(entry $key)")
	(action_tile "1" "(entry $key)")
	(action_tile "2" "(entry $key)")
	(action_tile "3" "(entry $key)")
	(action_tile "*" "(entry $key)")
	(action_tile "0" "(entry $key)")
	(action_tile "." "(entry $key)")
	(action_tile "=" "(entry $key)")
	(action_tile "/" "(entry $key)")
	(action_tile "accept" "(done_dialog 1)")
	(action_tile "cancel" "(done_dialog 0)")
	(setq what_next (start_dialog))
	(cond
		((= what_next 2)
			(initget 41)
			(setq pt1 (getpoint "\nPremier point: "))
			(initget 41)
			(setq pt2 (getpoint "\nSecond point: "))
			(initget "Distance Angle")
			(if (eq (getkword "\n[Distance/Angle] : ") "Angle")
				(setq rslt (cvs (cal "ang (pt1,pt2)") nil))
				(setq rslt (cal "dist (pt1,pt2)"))
			)
		)
	)
)
(unload_dialog dcl_id)
(setvar "dimzin" old_zin)
(if (not (zerop what_next))
	(if (< nbdec 9)
		(read (rtos rslt 2 nbdec))
		rslt
	)
)
)

 

le dcl DDCAL.DCL

ddcal : dialog {
label = "Calculette";
:boxed_row {
	:text {
		key = "dsp";
		width = 15;
	}
}
:row {
	:button {
		label    = ">> Saisie graphique";
		key      = "PICK";
	}
}
:row {
	:radio_button {
		label = "Dg";
		key = "DG";
	}
	:radio_button {
		label = "Rd";
		key = "RD";
	}
	:radio_button {
		label = "Gr";
		key = "GR";
	}
}
:row {
:column {
	width = 10;
	:button {
		label    = "Abs";
		key      = "ABS";
	}
	:button {
		label    = "±";
		key      = "SIG";
	}
	:button {
		label    = "¶";
		key      = "PI";
	}
	:button {
		label    = "x²";
		key      = "PUI";
	}
	:button {
		label    = "7";
		key      = "7";
	}
	:button {
		label    = "4";
		key      = "4";
	}
	:button {
		label    = "1";
		key      = "1";
	}
	:button {
		label    = "0";
		key      = "0";
	}
}
:column {
	width = 10;
	:button {
		label    = "Arr";
		key      = "ARR";
	}
	:button {
		label    = "aSi";
		key      = "ASI";
	}
	:button {
		label    = "Sin";
		key      = "SIN";
	}
	:button {
		label    = "V¯";
		key      = "SQR";
	}
	:button {
		label    = "8";
		key      = "8";
	}
	:button {
		label    = "5";
		key      = "5";
	}
	:button {
		label    = "2";
		key      = "2";
	}
	:button {
		label    = ".";
		key      = ".";
	}
}
:column {
	width = 10;
	:button {
		label    = "Sto";
		key      = "STO";
	}
	:button {
		label    = "aCo";
		key      = "ACO";
	}
	:button {
		label    = "Cos";
		key      = "COS";
	}
	:button {
		label    = "1/x";
		key      = "INV";
	}
	:button {
		label    = "9";
		key      = "9";
	}
	:button {
		label    = "6";
		key      = "6";
	}
	:button {
		label    = "3";
		key      = "3";
	}
	:button {
		label    = "=";
		key      = "=";
	}
}
:column {
	width = 10;
	:button {
		label    = "Rcl";
		key      = "RCL";
	}
	:button {
		label    = "aTa";
		key      = "ATA";
	}
	:button {
		label    = "Tan";
		key      = "TAN";
	}
	:button {
		label    = "CLS";
		key      = "CLS";
	}
	:button {
		label    = "-";
		key      = "-";
	}
	:button {
		label    = "+";
		key      = "+";
	}
	:button {
		label    = "X";
		key      = "*";
	}
	:button {
		label    = "÷";
		key      = "/";
	}
}
}
ok_cancel;
}

Choisissez un travail que vous aimez et vous n'aurez pas à travailler un seul jour de votre vie. - Confucius

Lien vers le commentaire
Partager sur d’autres sites

UNE CALCULATRICE 4 TOUCHE AVEC OPTION MESURER

---------------------------------------------------------------------------------

SEULEMENT POUR UTILISATEUR DE LT

Sous autocad faire un calcul et lire résultat du calcul ne présente pas de grand intérêt

S’il est possible de saisir des lignes, arcs, polylignes (tout entité de dessin générant un périmètre) et par ex additionner cette valeur avec celle d’une autre entité présente dans un dessin donné est me semble-t-il nettement plus intéressant et si de surcroît on peut envoyer la valeur obtenue sur la ligne de commande cela peut même éventuellement s’avérer utile….(suppression d’erreurs de transcription, frappes fastidieuses s’il s’agit de chiffres complexes etc.) dans l’exemple suivant dans le bouton de démarrage (calculatrice) il faut placer les éléments suivants :

 

$P=CALC4T_2.POP11 $P=*

 

et le sous-menu calc4t_2.mnu (qu’il faudra charger outils ->personnaliser

-> menu ->parcourir et charger !!! faire attention que la coche tout remplacer ne soit pas actvée !!!)

 

***MENUGROUP=calc4t_2

***POP11

[Calc_4t_saisir]

[ENVOYER RESULTAT]$M=$(getenv,NUMB1)\

[--]

[ -->SAISIR 1ER]^C^CSETENV;NUMB1;\ $P=CALC4T_2.POP11 $P=*

[--]

[ + ]^CSETENV;NUMB2;\^CSETENV;NUMB1;$M=$(+,$(getenv,NUMB1),$(getenv,NUMB2)); $P=CALC4T_2.POP13 $P=*

[--]

[ - ]^CSETENV;NUMB2;\^CSETENV;NUMB1;$M=$(-,$(getenv,NUMB1),$(getenv,NUMB2)); $P=CALC4T_2.POP13 $P=*

[--]

[ * ]^CSETENV;NUMB2;\^CSETENV;NUMB1;$M=$(*,$(getenv,NUMB1),$(getenv,NUMB2)); $P=CALC4T_2.POP13 $P=*

[--]

[ / ]^CSETENV;NUMB2;\^CSETENV;NUMB1;$M=$(/,$(getenv,NUMB1),$(getenv,NUMB2)); $P=CALC4T_2.POP13 $P=*

[--]

[ <--MESURER 1ER]^C^CPICKADD;0;AIRE;PRO;\;^CMODIFLONG;@;;^C^CPICKADD;1;^CSETENV;NUMB1;$M=$(getvar,perimeter); $P=CALC4T_2.POP12 $P=*

***POP12

[Calc_4t_mesurer]

[ENVOYER RESULTAT]$M=$(getenv,NUMB1)\

[--]

[ <--RETOUR VERS SAISIE]$P=CALC4T_2.POP11 $P=*

[--]

[ -->+]^C^CPICKADD;0;AIRE;PRO;\;^CMODIFLONG;@;;^C^CPICKADD;1;^CSETENV;NUMB1;$M=$(+,$(getenv,NUMB1),$(getvar,perimeter)); $P=CALC4T_2.POP12 $P=*

[--]

[ -->- ]^C^CPICKADD;0;AIRE;PRO;\;^CMODIFLONG;@;;^C^CPICKADD;1;^CSETENV;NUMB1;$M=$(-,$(getenv,NUMB1),$(getvar,perimeter)); $P=CALC4T_2.POP12 $P=*

[--]

[ -->* ]^C^CPICKADD;0;AIRE;PRO;\;^CMODIFLONG;@;;^C^CPICKADD;1;^CSETENV;NUMB1;$M=$(*,$(getenv,NUMB1),$(getenv,perimeter)); $P=CALC4T_2.POP12 $P=*

[--]

[ -->/ ]^C^CPICKADD;0;AIRE;PRO;\;^CMODIFLONG;@;;^C^CPICKADD;1;^CSETENV;NUMB1;$M=$(/,$(getenv,NUMB1),$(getenv,perimeter)); $P=CALC4T_2.POP12 $P=*

[--]

[ -->RECOMMENCER MESURE]^C^CPICKADD;0;AIRE;PRO;\;^CMODIFLONG;@;;^C^CPICKADD;1;^CSETENV;NUMB1;$M=$(getvar,perimeter); $P=CALC4T_2.POP12 $P=*

***POP13

[Calc_4t_saisir]

[ENVOYER RESULTAT]$M=$(getenv,NUMB1)\

[--]

[ -->SAISIR 1ER]^C^CSETENV;NUMB1;\ $P=CALC4T_2.POP11 $P=*

[--]

[ + ]^CSETENV;NUMB2;\^CSETENV;NUMB1;$M=$(+,$(getenv,NUMB1),$(getenv,NUMB2)); $P=CALC4T_2.POP13 $P=*

[--]

[ - ]^CSETENV;NUMB2;\^CSETENV;NUMB1;$M=$(-,$(getenv,NUMB1),$(getenv,NUMB2)); $P=CALC4T_2.POP13 $P=*

[--]

[ * ]^CSETENV;NUMB2;\^CSETENV;NUMB1;$M=$(*,$(getenv,NUMB1),$(getenv,NUMB2)); $P=CALC4T_2.POP13 $P=*

[--]

[ / ]^CSETENV;NUMB2;\^CSETENV;NUMB1;$M=$(/,$(getenv,NUMB1),$(getenv,NUMB2)); $P=CALC4T_2.POP13 $P=*

[--]

[ <--RETOUR VERS MESURER]$P=CALC4T_2.POP12 $P=*

 

 

 

Fonctionnement :

1)click sur bouton calculatrice

 

2)choix 1ère saisie ou 1ère mesure ( pour mesurer sélectionner l’entité)

 

apparition du menu suivant pour la saisie comme précédemment :

[-->SAISIR 1ER

[ + ]

[ - ]

[ * ]

[ / ]

[ <--MESURER 1ER]

 

apparition du menu suivant pour mesurer

 

[ <--RETOUR VERS SAISIE]

[ -->+] = additionner la deuxième entité (sélection)

[ -->-] = soustraire la deuxième entité (sélection)

[ -->*] = multiplier la deuxième entité (sélection)

[ -->/] = diviser la deuxième entité (sélection)

[ -->RECOMMENCER MESURE]

 

pour mettre fin au processus appuyer sur la touche

 

la dernière valeur calculée restera enregistrée jusqu’à une nouvelle série de calculs…

 

petit exemple :

 

mesurer la longueur d’une ligne la diviser en trois et envoyer le résultat à la commande décaler

 

1) bouton calculatrice

2) [ <--MESURER 1ER]

3) sélectionner un ligne ( otion proche)

4) [ <--RETOUR VERS SAISIE]

5) [ / ] et taper 3 enter

6) commande autocad DECALER enter

7) bouton calculatrice

8) [ENVOYER RESULTAT] enter

 

résultat le décalage des lignes correspondra à la valeur calculée.

 

Lien vers le commentaire
Partager sur d’autres sites

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 compte

Se connecter

Vous avez déjà un compte ? Connectez-vous ici.

Connectez-vous maintenant
×
×
  • Créer...

Information importante

Nous avons placé des cookies sur votre appareil pour aider à améliorer ce site. Vous pouvez choisir d’ajuster vos paramètres de cookie, sinon nous supposerons que vous êtes d’accord pour continuer. Politique de confidentialité