Erreur runtime (french)

Started by arnaudalp, March 23, 2017, 08:29:51 AM

Previous topic - Next topic

arnaudalp

Bonjour

Je suis français au mauvais anglais.

J'ai un problème de runtime avec opendcl et autocad 2017.

Voici mon code :

Code (autolisp) Select

(defun charge_opendcl (/ nomodcl)
  ;; modification 2010 pour choix arx 32 ou 64 bit
  (if (wcmatch (getvar "PLATFORM") "*64*")
    (progn ;; le cas 64 bit
   (setq nomodcl
  (strcat "Opendcl.x64." (substr (getvar "ACADVER") 1 2))
   )
   (if (not (member nomodcl (arx)))
     (arxload (findfile (strcat nomodcl ".arx"))
      "OpenDCL Introuvable"
     )
   )
    )
    (progn ;; le cas 32 bit
   (setq nomodcl (strcat "Opendcl." (substr (getvar "ACADVER") 1 2)))
   (if (not (member nomodcl (arx)))
     (arxload (findfile (strcat nomodcl ".arx"))
      "OpenDCL Introuvable"
     )
   )
    )
  )
)

;;lance la boite de dialogue
(defun c:aep (/)
  (charge_opendcl)
  (dcl-loadproject (findfile "choix_res_aep.odcl"))
  (dcl-form-show choix_res_aep/traceaep)
  )

(defun c:choix_res_aep/traceaep#OnInitialize (/)
(princ)
)

(defun c:choix_res_aep/traceaep/aepf60#OnClicked (/)
(aep_fonte60)
(dcl-form-close choix_res_aep/traceaep)
)

(defun aep_fonte60 (/)
(command "-calque" "e" "AE_1_AEP_FONTE" "co" "bleu" "" "")
(command "polylign")
)


Mon problème : je n'arrive pas à fermer la fenêtre, voici le message d'erreur que j'obtiens :

https://www.dropbox.com/s/muun7tmppfbvluy/2017-03-23%2016_19_26-Autodesk%20AutoCAD%20Map%203D%202017%20-%20%5BDessin1.dwg%5D.png?dl=0

Pouvez vous m'aider ?

En pièce jointe le fichier odcl

roy_043

#1
You are using command calls inside an event handler for a modal form. This is not possible.
Code (autolisp) Select
(defun c:aep ( / action)
  (command "_opendcl")
  (dcl-loadproject "choix_res_aep.odcl")
  (setq action (dcl-form-show choix_res_aep/traceaep))
  (cond
    ((= 1 action)
      ; Predefined meaning see Help.
    )
    ((= 2 action)
      ; Predefined meaning see Help.
    )
    ; ...
    ; ...
    ((= 11 action)
      (aep_fonte60)
    )
    ; ...
    ; ...
  )
  (princ)
)

(defun c:choix_res_aep/traceaep#OnInitialize (/)
  (princ)
)

(defun c:choix_res_aep/traceaep/aepf60#OnClicked (/)
  (dcl-form-close choix_res_aep/traceaep 11)
)

(defun aep_fonte60 (/)
  (command "_.-layer" "_make" "AE_1_AEP_FONTE" "_color" "5" "" "")
  (command "_.polyline")
  (while (/= (logand (getvar 'cmdactive) 3) 0)
    (command pause)
  )
)

arnaudalp

Thank you for your reply.
What amazes me is that I have taken over the structure of a program that I have already done and that works very well.
I do not understand the assignment of the "action" variable of dcl-from-show, nor the "cond"

roy_043

#3
You can find more information in the Help (look at both the dcl-from-show and dcl-form-close functions).

If you are not familiar with the cond function this may be useful:
http://www.afralisp.net/autolisp/tutorials/cond-vs-if.php