TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: whdjr on November 08, 2005, 11:47:17 AM
-
Why would start_list stop working in Acad2006 when it has a loaded dcl file and a valid list?
-
dunno, did it work in A2k5 or previous?
-
Yes and it worked in 2006 just a couple of hours ago. I have restarted Acad a dozen times and it still hasn't reset itself.
-
<dumb question but first one that comes to mind> Was the tile renamed?
-
I've had cases where restarting acad doesn't help that restarting the cpu does.
-
I tried a warm boot and a cold boot and it didn't fix the problem. On top of that I tested some of my other lisp code with dcl files and they didn't work either. Something is terrible screwy here. :x
-
Is it possible you've inadvertently re-defined a lisp function like start_list, end_list etc?
-
I guess anythings possible.
What should I do - make sure any of my code doesn't load automatically then try to step it off in the VLIDE?
-
I'd start by carefully examining the lisp program files that I edited on or about the time everything went south, particularly those that are loaded automagically on startup.
-
I suggest you check the path to the DCL files as well
-
I can't find anything that I've changed. It just doesn't make since. It shows that the dcl file is loaded. It shows that the list info is available. It just won't start the list. :evil:
-
Time to start posting code me thinks.
-
Alright here goes:
It is unfinished but should run. I tried to compile all the utility functions and variables into this code from my toolbox so holler if you are missing something.
Lisp code:
(defun c:att (/ attlist strlist *acad*
*adoc* *layouts* *layout_list*
*sort* *get_atts* *dialog*
)
;;;
(setq *acad* (vlax-get-acad-object))
(setq *adoc* (vla-get-activedocument *acad*))
(setq *layouts* (vla-get-layouts *adoc*))
(defun *layout_list* (/ lst)
(vlax-map-collection
*layouts*
'(lambda (x) (setq lst (cons x lst)))
)
(cdr
(*sort* lst 'vla-get-taborder)
)
)
;;;
(defun *sort* (lst func)
(vl-sort lst
'(lambda (e1 e2)
(< ((eval func) e1) ((eval func) e2))
)
)
)
;;;
(defun *get_atts* (obj)
(vlax-safearray->list
(vlax-variant-value
(vla-getattributes
(if (eq (type obj) 'ENAME)
(vlax-ename->vla-object obj)
obj
)
)
)
)
)
;;;
(defun *dialog* (lst / id eb1 selection)
;
(defun on_list_pick ()
(if (= (get_tile "atts") "")
(mode_tile "select" 1)
(mode_tile "select" 0)
)
)
;
(and (setq id (load_dcl "att.DCL"))
(start_list "atts")
(mapcar 'add_list lst)
(not (end_list))
(action_tile "cancel" "(done_dialog 0)")
(action_tile
"update"
(strcat
"(setq selection (get_tile \"atts\"))"
"(setq eb1 (atoi (get_tile \"eb1\")))(done_dialog 1)"
)
)
(action_tile
"apply"
"(done_dialog 2)"
)
(action_tile "atts" "(on_list_pick)")
(not (mode_tile "update" 1))
(not (mode_tile "apply" 1))
(start_dialog)
(not (unload_dialog id))
)
(if selection
selection
(*error* "No selection made ")
)
)
;;;
;;;
;;;
(defun load_dcl (name / dcl dcl_id)
(while
(if (minusp (setq dcl_id (load_dialog name)))
(setq dcl (getfiled "Select correct DCL file location: "
dcl
"dcl"
(+ 8 128)
)
)
(not (new_dialog "attribute_edit" dcl_id))
)
)
dcl_id
)
;;;
(defun *error* (msg)
(princ "\nError: ")
(princ msg)
(princ)
(gc)
(princ)
)
;;;
;;;
;;;
(setq attlist (mapcar
'(lambda (x)
(vlax-for obj (vla-get-block x)
(if (and (eq (vla-get-objectname obj)
"AcDbBlockReference"
)
(eq (vla-get-name obj) "R-TB30X42")
)
(car
(vl-remove
nil
(mapcar '(lambda (y)
(if (eq (vla-get-tagstring y) "XXX")
(list x y)
)
)
(*get_atts* obj)
)
)
)
)
)
)
(*layout_list*)
)
strlist (mapcar '(lambda (z)
(strcat (vla-get-name (car z))
"\t"
(vla-get-textstring (cadr z))
)
)
attlist
)
)
(*dialog* strlist)
(princ)
)
Dcl file:
attribute_edit : dialog {
label = "Attribute Edit";
: list_box {
key = "atts";
tabs = "30";
height = 12;
multiple_select = true;
}
:boxed_column {
label = "\"Number Of\" to match Index of Drawings";
:edit_box {
key = "eb1";
label = " Enter starting sheet number:";
edit_limit = 4;
width = 30;
action = "";
}
}
:row {
: button {
label = "&Update";
key = "update";
width = 10;
}
: button {
label = "&Apply";
key = "apply";
width = 10;
}
: button {
label = "&Cancel";
is_cancel = true;
key = "cancel";
width = 10;
}
}
:spacer_1 {
}
:text_part {
label = "Copyright 2005 Will DeLoach";
}
}
and a test dwg:
When run you should get a dialog box with the tab name and 'XXX' on the same line in the dialog box.
Thanks for all your help,
-
I can't download from here and don't have time to dive real deep, but can you add this line:
(mapcar 'prin1 strlist)
right before --
(*dialog* strlist)
and then tell us what it displays when you run the proggy?
-
This is what it returns:
"A7.01\tXXX""A7.02\tXXX""A7.03\tXXX""A7.04\tXXX"
which is exactly what it is supposed to return.
"
A7.01 - tabname
\t - this is just for tab spacing in the dcl file
XXX - this is the shhet number(the whole purpose of this tool is to set that programmaticly)
"
-
Excellent.
Does it display the dialog per the start_dialog call (inside the and structure; inside the *dialog* function)?
-
Yes.
-
oops...no it does not. It loads the dialog and flashes the dialog when the 'new_dialog' call is made, but the start_list nils out before the dialog is filled.
-
Well ... my suggestion is o put this little snip (progn (alert "I'm here") t) within the and structure --
(and
(progn (alert "I'm here") t)
(setq id (load_dcl "att.DCL"))
(start_list "atts")
(mapcar 'add_list lst)
(not (end_list))
(action_tile "cancel" "(done_dialog 0)")
...
)
And keep moving it ahead, line by line until it stops displaying the alert.
-
(and
(setq id (load_dcl "att.DCL"))
(progn (alert "I'm here") t)
(start_list "atts")
(mapcar 'add_list lst)
(not (end_list))
(action_tile "cancel" "(done_dialog 0)")
...
)
That was the last place it worked.
-
You are not specifying your dialog box to use ... you MUST also use NEW_DIALOG to invoke the dialog to use.
Use this scenario:
(setq id (load_dcl "att.DCL"))
(new_dialog "attribute_edit" id)
-
I already call 'new_dialog' here:
(defun load_dcl (name / dcl dcl_id)
(while
(if (minusp (setq dcl_id (load_dialog name)))
(setq dcl (getfiled "Select correct DCL file location: "
dcl
"dcl"
(+ 8 128)
)
)
(not (new_dialog "attribute_edit" dcl_id))
)
)
dcl_id
)
But I changed it and put it like this:
(defun load_dcl (name / dcl dcl_id)
(while
(if (minusp (setq dcl_id (load_dialog name)))
(setq dcl (getfiled "Select correct DCL file location: "
dcl
"dcl"
(+ 8 128)
)
)
;(not (new_dialog "attribute_edit" dcl_id))
)
)
dcl_id
)
<snippet>
(setq id (load_dcl "att.DCL"))
(new_dialog "attribute_edit" id)
(start_list "atts")
<snippet>
But it still doesn't work. :-(
-
Will,
The Code you posted loads and displays without exception for me. Tested with AC2005 winXPpro.
-
Yeah it worked for me this morning, but now it doesn't. I don't know what changed to make it not work.
-
Have you tried a System wide search for ANY file modified date stamped today. See if anything seems out of place ...
-
I only worked on one other lisp file today and it didn't have anything to do with a dcl file. I did not do a system wide scan though.
Well guys I appreciate your help today and look for some more tomorrow. Right now I have to leave. Maybe things will look brighter in the morning. :-)
-
Does this anomaly ONLY apply to this routine, or to ALL your DCL's ?
added :
Just for completeness, loaded and ran in AC2006 as well as 2005.
-
I won't be able to look at this until 10pm tonight, but I certainly will try after that.
Hope this gets solved soon (my money is still on start_list, add_list etc. being redefined).
-
(my money is still on start_list, add_list etc. being redefined).
Wouldn't something like this verify that?
_$ (type start_list)
SUBR
_$ (setq tmp start_list)
#<SUBR @0243c7e8 START_LIST>
_$ (setq start_list nil)
nil
_$ (type start_list)
nil
_$ (setq start_list 7)
7
_$ (type start_list)
INT
_$ (setq start_list tmp)
#<SUBR @0243c7e8 START_LIST>
-
(type start_list) => SUBR
(defun start_list () (princ))
(type start_list) => SUBR
-
<violently shakes Jeff_M>
Oh, yeah :oops:
/me goes back to lurking
-
We're all doing a million things besides trying to help out our friends on this board Jeff, so I wouldn't sweat some minuscule little detail when you've helped out so many folks in so many BIG ways. This doesn't even count as an insect, so put you happy mug back on and de-lurk please.
:)
Edit: Hey, there was no shakin' going on!
-
Wait a minute......
(defun start_list () (princ))
START_LIST
_$ (type start_list)
USUBR ;;<<<<<<not the same as SUBR!
-
What AutoCAD version Jeff? I copied mine right from the AutoCAD 2004 text screen (albeit cleaned out the command crud).
-
This was from the VLIDE in 2002.....going to test in 2006 now
-
VLIDE? What's that?
:lmao:
-
Hi Guys,
Jeff,
From the VLIDE,
Tools -> Environment Options -> General Options ->
What is the SETQ to Protected symbols toggle setting.
I have Prompt to enter Break Loop set and the re-assignment spits the Dummy.
-
It's what allows things to get redefined, evidently. Testing in 2006, performing the steps exactly the same, first in the command window then in the VLIDE, restarting Acad bewteen tests......
The first method returns this:
Command: (defun start_list () (princ "It's been redefined...")(princ))
START_LIST
Command: (type start_list)
SUBR
Command: (start_list)
It's been redefined...
The second returns this:
_$ (type start_list)
SUBR
_$ start_list
#<SUBR @0d2ef8f8 START_LIST>
_$ (defun start_list () (princ))
START_LIST
_$ (type start_list)
USUBR
_$ start_list
#<USUBR @127557bc START_LIST>
One more little quirk that makes you go "Huh?"
Kerry, I've tried it set to all but the Error setting.....all give the same result for me
-
2006, command line only --
Command: (type start_list)
SUBR
Command: (defun start_list () (princ))
START_LIST
Command: (type start_list)
SUBR
re: What is the VLIDE ... I only use it for compiling, I never code in it; never.
Catch ya later guys.
-
From the Lisp help file:
SUBR Internal AutoLISP functions or functions loaded from compiled (FAS or VLX) files.
Functions in LISP source files loaded from the AutoCAD Command prompt may also appear as SUBR.
SYM Symbols
VARIANT Variant
USUBR User-defined functions loaded from LISP source files
So it appears that it matters HOW the lisp is loaded as to whether it is a SUBR or USUBR.......
I give up for tonight
-
What's the good word this morning Will?
-
Well guys I'm back and so is my problem. It did not go away last night while I was sleeping. :-(
I tried to follow what you guys were saying about testing functions to see if they have been redefined and I tested start_list, add_list, and end_list and they all returned SUBR.
(type start_list)
SUBR
(type add_list)
SUBR
(type end_list)
SUBR
-
Sadly this doesn't tell us much.
As for redefining said functions, don't just look for defun statements, but also setq and set statements that may have over written those functions.
To me it's very telling that "start_list suddenly stopped working".
-
To me it's very telling that "start_list suddenly stopped working".
So what is it telling you. I have searched thru every file I changed within the last week and I can't find a function anywhere that has been redefined.
-
Will,
Exit Acad,
Edit your Acad2006.lsp file (I know, you are not supposed to but this is temporary) by adding
(setq myuntouchablesubr start_list)
as the very first line;
start acad;
once in the drawing, type (setq start_list myuntouchablesubr)
now trying loading & running your lisp....if it now works then you know for sure that start_list is getting redefined somewhere.
make sure to remove that 1 line from the acad2006.lsp file
Good Luck
-
Good idea Jeff.
-
So what is it telling you.
<sorry to repeat myself but> On face value it suggests rather strongly that start_list etc. has been redefined.
-
Will,
Exit Acad,
Edit your Acad2006.lsp file (I know, you are not supposed to but this is temporary) by adding
(setq myuntouchablesubr start_list)
as the very first line;
start acad;
once in the drawing, type (setq start_list myuntouchablesubr)
now trying loading & running your lisp....if it now works then you know for sure that start_list is getting redefined somewhere.
make sure to remove that 1 line from the acad2006.lsp file
Good Luck
Nothing doing...It still doesn't load.
-
Will, I'm on my way to bed, so probably wont see the end of this.
Have you done a system Search for ANY file that has start_list in it.
.. and do any of these have a recent date stamp.
Think about the usual suspects.
Have you installed any new software recently
Have you run any new ....
Is there a practical joker in your office.
Are there any budding programmers in your office.
-
This may shed more light on the subject or it may just confuse it even more, but all this time I have been stepping thru the code in the VLIDE like I always do when testing. Well after I tried this last option from Jeff I changed it back and then reopened the dwg. Without opening the VLIDE I loaded the code and proceeded to run it. It worked. It brought up MP's alert box and then it populated my dialog box. After this I open the VLIDE and proceeded to step thru the code as always and it nil'd out at the start_list function as before.
So what does that tell us? anything?
-
Have not done nothing on DCL for quite a while....
(start_list "atts" 3 0)
Can you do that... and what happens?
-
3 and 0 are the optional defaults so it really doesn't help to put them. With them in it works without stepping thru the vlide but not if you step thru it.
-
W.A.G. ==> Are there any weird *ssed ASCII codes in your source code, like 160?
-
Well, I'm plum out of ideas, unless you wanna send me your 'puter :| :evil:
Just saw your latest post.....I know what MP's going to say, something that includes the words "never" & "vlide" :-P
What's it tell us? Don't do that! Although I just stepped through it just fine......
-
Just saw your latest post.....I know what MP's going to say, something that includes the words "never" & "vlide" :-P
I'd never say that -- to each his own, and whatever makes you productive.
Back on track: I'm baffled by this problem -- it works, it doesn't work. In 16+ years pounding lisp I've never encountered that.
-
Ok if I put a breakpoint anywhere in this 'and' portion of the code it returns a nil and the program stops. If it is after the 'and' portion everything continues fine.
(and (setq id (load_dcl "att"))
(start_list "atts")
(mapcar 'add_list lst)
(not (end_list))
(action_tile "cancel" "(done_dialog 0)")
(action_tile
"update"
(strcat
"(setq selection (get_tile \"atts\"))"
"(setq eb1 (atoi (get_tile \"eb1\")))(done_dialog 1)"
)
)
(action_tile
"apply"
"(done_dialog 2)"
)
(action_tile "atts" "(on_list_pick)")
(not (mode_tile "update" 1))
(not (mode_tile "apply" 1))
(start_dialog)
(not (unload_dialog id))
)
-
Do you have access to another machine to try the code on? If it works on another machine with the same version of AutoCAD, I'd say it's time to reinstall (or at least repair install) AutoCAD.