veval-str+ ARX command

veval-str+ ARX command

CSM_MAI
Advocate Advocate
3,805 Views
7 Replies
Message 1 of 8

veval-str+ ARX command

CSM_MAI
Advocate
Advocate

I'm running a defun based on a user selection. After the user selection it calls up a separate defun, and It works fine when all I do is (princ (strcat "\n You chose " usersselection" from the first popup list box.")), but when I replace the (princ.. with something else like (command "line") it freezes and then gives the an error message saying Exception in "VEVAL-STR+ ARX command" with the text saying "Unhandled Exception E06D7363 (e06d7363h) at address 685C8A5Ch". I found some posts about this, but didn't have any luck on a solution. Has anyone had this issue before? Any info would be helpful. Thanks. 

0 Likes
Accepted solutions (1)
3,806 Views
7 Replies
Replies (7)
Message 2 of 8

DannyNL
Advisor
Advisor

 

Doesn't sound like an error in LISP if your description is accurate.

Problem could maybe be .NET related or some missing or damaged file in the AutoCAD installation. But hard to tell from this side.

 

What OS and AutoCAD version are you using? Did you try to run it on another PC if possible?

Can you post the LISP so we can see and test?

0 Likes
Message 3 of 8

martti.halminen
Collaborator
Collaborator

 

We've seen plenty of this on AutoCAD Mechanical 2014. Looks like an addressing bug somewhere in the Visual Lisp runtime system error handling code (written in C++).

- haven't encountered this yet on AcadM 2017.

 

The only way to handle this we found is first killing that AutoCAD session, it is unstable after this, and then repairing whatever Lisp error caused the entry to the error handler in the first place.

- finding that may be difficult as this crash prevents using the debugger after the error.

 

-- 

 

0 Likes
Message 4 of 8

CSM_MAI
Advocate
Advocate

I'm using AutoCAD 2015. I've tried using this with the unnamed profile, but I still have the issue. Below is the DCL and lsp. I apologize if this isn't the formal way to post code in here. I've found help from some of lee mac's code and other Users on this forum. The idea is to eventually run a script on the list of files built off a user selection. I was in the testing phase to ensure a command would run when the user chose a script. I can't get a command to run because of the error, but I can get it to display the script name with the (princ... part. The first item in the list "0" is blank to ensure the user has chosen a script to run. Any info would be helpful. Thanks.

 

;;; DCL key information
;;;
;;; key = udir (edit box)
;;; key = browse (browse button)
;;; key = subdirs (list box left)
;;; key = dwgs (list box right)
;;; key = afiles (add files button)
;;; key = rfiles (remove files button)
;;; key = script (popup list)
;;; key = run (run button)
;;; key = cancel (cancel button)
;;;
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
;;; ;;;
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(defun c:batchtest ()
(vl-load-com)
(setq selectionlist nil)
(setq dfiles nil)
(setq scr nil)
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(setq dcl_id (load_dialog "batchtest.dcl")) ; Load the DCL File
(if (not (new_dialog "batchtest" dcl_id)) ; Load the dialogue box
(exit) ; If not loaded exit
);end if
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(setq dfiles nil)
(setq sname (list "" "scriptname1" "scriptname2" "scriptname3" "scriptname4" "scriptname5" "scriptname6"))
(start_list "script" 3)
(mapcar 'add_list sname)
(end_list)
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(setq userfilepath nil)
(setq userfilepath (getvar "dwgprefix"))
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(set_tile "udir" userfilepath)
(mode_tile "udir" 1)
(setq dfiles nil)
(setq dfiles (vl-sort (vl-directory-files userfilepath "*.dwg")'<))
(start_list "subdirs")
(mapcar 'add_list dfiles)
(end_list)
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(action_tile "afiles"
(strcat
"(setq selectionlist (AddRemoveItems dfiles(getSelctedIndexList (get_tile \"subdirs\")) T))"
"(start_list \"dwgs\")"
"(mapcar 'add_list selectionlist)"
"(end_list)"
);strcat
);action_tile
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(action_tile "rfiles"
(strcat
"(setq selectionlist (AddRemoveItems selectionlist(getSelctedIndexList (get_tile \"dwgs\")) F))"
"(start_list \"dwgs\")"
"(mapcar 'add_list selectionlist)"
"(end_list)"
);strcat
);action_tile
(action_tile "sfiles" "(select_all_from)")
(action_tile "rafiles" "(remove_all)")
(action_tile "browse" "(setq userfilepath (getdwgs))")
(action_tile "run" "(err1)")
(action_tile "cancel" "(done_dialog 1)")
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(setq ddiag (start_dialog))
(unload_dialog dcl_id)
(princ)
); defun
(princ)
;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
;;Returns the List of selected indexes of a listbox
;; Arguments:
;; sellist - string of selected items in a listbox (eg: "0 2 3")
(defun getSelctedIndexList(sellist / count item retlist)
(setq count 1)
(while (setq item (read sellist))
(setq retlist (cons item retlist))
(while (and
(/= " " (substr sellist count 1))
(/= "" (substr sellist count 1))
)
(setq count (1+ count))
)
(setq sellist (substr sellist count))
)
(reverse retlist)
);defun
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
;;Returns the List based on the User Selection
;; Arguments:
;; source - list of all the items
;; selctn - list of selected index (use getSelctedIndexList function to get this)
;; add? - boolean , T to add and F to remove
(defun AddRemoveItems(source selctn add? / addlist removelist)
(mapcar '(lambda (x) (if(member(vl-position x source) selctn)
(setq addlist(cons x addlist))
(setq removelist(cons x removelist))
))source)
(if add? (reverse addlist) (reverse removelist))
);defun
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(defun remove_all ()
(setq selectionlist nil)
(set_tile "dwgs" "")
(start_list "dwgs")
(mapcar 'add_list selectionlist)
(end_list)
(princ)
);defun
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(defun select_all_from ()
(setq index 0)
(repeat (length dfiles)
(set_tile "subdirs" (itoa index))
(setq index (1+ index))
)
(princ)
);defun
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(defun getdwgs ()
(setq userfilepath (dwgdirr "Select Folder Location:" "" 512))
;(if (/= nil userfilepath)
(set_tile "udir" userfilepath)
(setq dfiles (vl-sort (vl-directory-files userfilepath "*.dwg")'<))
(start_list "subdirs")
(mapcar 'add_list dfiles)
(end_list)
);defun
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(defun dwgdirr ( msg dir bit / err fld pth shl slf )
(setq err
(vl-catch-all-apply
(function
(lambda ( / app hwd )
(if (setq app (vlax-get-acad-object)
shl (vla-getinterfaceobject app "shell.application")
hwd (vl-catch-all-apply 'vla-get-hwnd (list app))
fld (vlax-invoke-method shl 'browseforfolder (if (vl-catch-all-error-p hwd) 0 hwd) msg bit dir)
)
(setq slf (vlax-get-property fld 'self)
pth (vlax-get-property slf 'path)
pth (vl-string-right-trim "\\" (vl-string-translate "/" "\\" pth))
)
)
)
)
)
)
(if slf (vlax-release-object slf))
(if fld (vlax-release-object fld))
(if shl (vlax-release-object shl))
(if (vl-catch-all-error-p err)
(prompt (vl-catch-all-error-message err))
pth
)
;(princ pth)
)
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
;;; end ;;;
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(defun err1 ()
(if (= nil dfiles)
(progn
(alert "\nNo drawings in current directory...")
);progn
(err2)
);if
);defun
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(defun err2 ()
(if (= nil selectionlist)
(progn
(alert "\nNo drawings to process...")
);progn
(err3)
);if
);defun
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(defun err3 ()
(if (and (setq scr1 "0")
(setq scr2 (get_tile "script"))
(eq scr1 scr2)
);and
(progn
(alert "\nPlease choose a script...")
);progn
(batch_processor)
);if
);defun
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(defun batch_processor ()
(progn
(setq scr (get_tile "script"))
(setq userscript (nth (atoi scr) sname))
(done_dialog 2)
)
(if (= ddiag 1)
(princ "\n Batch Processor Cancled...")
);if
(progn
(if (= ddiag 2)
(cond
((= scr "1") (uscript1))
((= scr "2") (uscript2))
((= scr "3") (uscript3))
((= scr "4") (uscript4))
((= scr "5") (uscript5))
((= scr "6") (uscript6))
);end cond
);if
);progn
(setq selectionlist nil)
(setq dfiles nil)
;(setq scr nil)
(princ)
);defun
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(defun uscript1 ()
(princ (strcat "\n You chose " userscript " from the first popup list box."))
;(command-s "._circle")
;(command "line")
(princ)
)
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(defun uscript2 ()
;(command "line")
(princ (strcat "\n You chose " userscript " from the first popup list box."))
(princ)
)
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(defun uscript3 ()
;(command "line")
(princ (strcat "\n You chose " userscript " from the first popup list box."))
(princ)
)
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(defun uscript4 ()
;(command "line")
(princ (strcat "\n You chose " userscript " from the first popup list box."))
(princ)
)
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(defun uscript5 ()
;(command "line")
(princ (strcat "\n You chose " userscript " from the first popup list box."))
(princ)
)
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
(defun uscript6 ()
;(command "line")
(princ (strcat "\n You chose " userscript " from the first popup list box."))
(princ)
)
;;; -------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+

 


DCL

 

// BatchProcess multiple drawings

batchtest : dialog { // Drawing files
label = "Batch Processor";
: boxed_column {
label = "Drawings to Process:";

:row {

: text {
width = 32;
label = "Folder:";
} // text

} // row

: row {

: edit_box {
width = 50;
fixed_height = true;
key = "udir";
} // edit_box

: button {
label = "Browse";
key = "browse";
width = 12;
mnemonic = "0";
is_default = false;
mnemonic = "B";
} // button

: spacer { width = 1; }

} //row

: spacer { width = 1; }

: row {

: list_box {
key = "subdirs";
width = 40;
height = 10;
multiple_select = true;
value = "";
} // list_box

} // row

: spacer { width = 1; }

: row {

: button {
label = "Add Files";
key = "afiles";
width = 5;
fixed_width = false;
is_default = true;
mnemonic = "A";

alignment = centered;
} // button

: button {
label = "Select All";
key = "sfiles";
width = 5;
fixed_width = false;
is_default = false;
mnemonic = "S";

alignment = centered;
} // button

} // row

: spacer { width = 1; }

: row {

: list_box {
key = "dwgs";
width = 40;
height = 10;
multiple_select = true;
value = "";
} // list_box

} // row

: spacer { width = 1; }

: row {

: button {
label = "Remove Files";
key = "rfiles";
width = 5;
fixed_width = false;
is_default = false;
mnemonic = "F";
alignment = centered;
} // button

: button {
label = "Remove All";
key = "rafiles";
width = 5;
fixed_width = false;
is_default = false;
mnemonic = "R";
alignment = centered;
} // button

} // row

} // column

: row {
: text {
width = 32;
label = "Script Type:";
} // text
} // row

: row {
: popup_list {
key = "script";
width = 40;
fixed_width = true;
value = "";
} // popup_list

: button {
label = "Run";
key = "run";
width = 12;
fixed_width = true;
mnemonic = "0";
is_default = true;
mnemonic = "R";
} // button

: button {
label = "Cancel";
key = "Cancel";
width = 12;
fixed_width = false;
mnemonic = "C";
is_cancel = true;
} // button

} //row

: spacer { width = 2; }


:row {
: errtile {
width = 32;
}
} // row

: row {

: text {
width = 32;
label = "Future text";
} // text

} //row

 

 

 


} // batchtest

 

 

 

 

 

 

 

 

 

0 Likes
Message 5 of 8

martti.halminen
Collaborator
Collaborator

 

While it is generally better to post too much code instead of too little, that is rather a lot  of code for busy people to go through.

You should prepare a minimal, stand-alone test case: cut off anything not necessary to produce the error, starting with anything clearly downstream of the problem.

- of course there is the risk that you'll find the problem yourself when doing this...

 

-- 

 

0 Likes
Message 6 of 8

CSM_MAI
Advocate
Advocate

Thanks for the response. I tried to bypass my error checks and other functions, but still I received the same message. I did some digging and found someone with almost the exact same problem as mine. Their reason for the error was you cannot call up a (command "xxxx" function while a dialog box was open. Somehow I will have to make the dialog box close and then call up my defun. Here's the link below: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/unhandled-exception/td-p/5233079

0 Likes
Message 7 of 8

ActivistInvestor
Mentor
Mentor
Accepted solution

@CSM_MAI wrote:

Thanks for the response. I tried to bypass my error checks and other functions, but still I received the same message. I did some digging and found someone with almost the exact same problem as mine. Their reason for the error was you cannot call up a (command "xxxx" function while a dialog box was open. Somehow I will have to make the dialog box close and then call up my defun. Here's the link below: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/unhandled-exception/td-p/5233079


We can dispense with speculation about this having something to do with .NET.

 

The most-common cause of the problem is trying to use (command) from code that's called from an action_tile callback, especially if the arguments do not complete the command and return AutoCAD to the Command: prompt.

 

From the code that's called from the action_tile callback, try using vla-SendCommand to start a command you define using (defun C:XXXX ()...), and do the rest of the work in that command. 

 

Message 8 of 8

CSM_MAI
Advocate
Advocate

I just got around to testing out what you posted. The vla-SendCommand worked like a charm. I appreciate you input. 

0 Likes