TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: whdjr on November 08, 2005, 11:47:17 AM

Title: 'start_list' not working...Please help!
Post 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?
Title: Re: 'start_list' not working...Please help!
Post by: Keith™ on November 08, 2005, 11:49:36 AM
dunno, did it work in A2k5 or previous?
Title: Re: 'start_list' not working...Please help!
Post by: whdjr on November 08, 2005, 12:08:19 PM
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.
Title: Re: 'start_list' not working...Please help!
Post by: MP on November 08, 2005, 12:13:17 PM
<dumb question but first one that comes to mind> Was the tile renamed?
Title: Re: 'start_list' not working...Please help!
Post by: Bob Wahr on November 08, 2005, 12:20:26 PM
I've had cases where restarting acad doesn't help that restarting the cpu does.
Title: Re: 'start_list' not working...Please help!
Post by: whdjr on November 08, 2005, 01:32:16 PM
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
Title: Re: 'start_list' not working...Please help!
Post by: MP on November 08, 2005, 01:36:36 PM
Is it possible you've inadvertently re-defined a lisp function like start_list, end_list etc?
Title: Re: 'start_list' not working...Please help!
Post by: whdjr on November 08, 2005, 01:41:34 PM
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?
Title: Re: 'start_list' not working...Please help!
Post by: MP on November 08, 2005, 01:43:35 PM
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.
Title: Re: 'start_list' not working...Please help!
Post by: Keith™ on November 08, 2005, 02:08:56 PM
I suggest you check the path to the DCL files as well
Title: Re: 'start_list' not working...Please help!
Post by: whdjr on November 08, 2005, 02:34:27 PM
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:
Title: Re: 'start_list' not working...Please help!
Post by: MP on November 08, 2005, 02:57:47 PM
Time to start posting code me thinks.
Title: Re: 'start_list' not working...Please help!
Post by: whdjr on November 08, 2005, 03:19:50 PM
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:
Code: [Select]
(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:

Code: [Select]
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,
Title: Re: 'start_list' not working...Please help!
Post by: MP on November 08, 2005, 03:49:08 PM
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?
Title: Re: 'start_list' not working...Please help!
Post by: whdjr on November 08, 2005, 04:00:24 PM
This is what it returns:
Code: [Select]
"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)
"
Title: Re: 'start_list' not working...Please help!
Post by: MP on November 08, 2005, 04:11:04 PM
Excellent.

Does it display the dialog per the start_dialog call (inside the and structure; inside the *dialog* function)?

Title: Re: 'start_list' not working...Please help!
Post by: whdjr on November 08, 2005, 04:27:17 PM
Yes.
Title: Re: 'start_list' not working...Please help!
Post by: whdjr on November 08, 2005, 04:29:44 PM
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.
Title: Re: 'start_list' not working...Please help!
Post by: MP on November 08, 2005, 04:38:04 PM
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.
Title: Re: 'start_list' not working...Please help!
Post by: whdjr on November 08, 2005, 04:45:41 PM
(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.
Title: Re: 'start_list' not working...Please help!
Post by: Keith™ on November 08, 2005, 05:01:29 PM
You are not specifying your dialog box to use ... you MUST also use NEW_DIALOG to invoke the dialog to use.

Use this scenario:
Code: [Select]
(setq id (load_dcl "att.DCL"))
(new_dialog "attribute_edit" id)
Title: Re: 'start_list' not working...Please help!
Post by: whdjr on November 08, 2005, 05:08:21 PM
I already call 'new_dialog' here:
Code: [Select]
(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:
Code: [Select]
(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. :-(
Title: Re: 'start_list' not working...Please help!
Post by: Kerry on November 08, 2005, 05:23:20 PM
Will,
The Code you posted loads and displays without exception for me. Tested with AC2005 winXPpro.

Title: Re: 'start_list' not working...Please help!
Post by: whdjr on November 08, 2005, 05:25:09 PM
Yeah it worked for me this morning, but now it doesn't.  I don't know what changed to make it not work.
Title: Re: 'start_list' not working...Please help!
Post by: Kerry on November 08, 2005, 05:30:33 PM
Have you tried a System wide search for ANY file modified date stamped today. See if anything seems out of place ...
Title: Re: 'start_list' not working...Please help!
Post by: whdjr on November 08, 2005, 05:34:04 PM
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. :-)
Title: Re: 'start_list' not working...Please help!
Post by: Kerry on November 08, 2005, 05:38:11 PM
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.
Title: Re: 'start_list' not working...Please help!
Post by: MP on November 08, 2005, 06:33:15 PM
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).
Title: Re: 'start_list' not working...Please help!
Post by: Jeff_M on November 08, 2005, 06:49:22 PM
(my money is still on start_list, add_list etc. being redefined).
Wouldn't something like this verify that?
Code: [Select]
_$ (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>
Title: Re: 'start_list' not working...Please help!
Post by: MP on November 08, 2005, 06:51:59 PM
(type start_list) => SUBR

(defun start_list () (princ))

(type start_list) => SUBR
Title: Re: 'start_list' not working...Please help!
Post by: Jeff_M on November 08, 2005, 07:00:36 PM
Quote from: MP
<violently shakes Jeff_M>
Oh, yeah  :oops:

/me goes back to lurking
Title: Re: 'start_list' not working...Please help!
Post by: MP on November 08, 2005, 07:05:57 PM
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!
Title: Re: 'start_list' not working...Please help!
Post by: Jeff_M on November 08, 2005, 07:07:57 PM
Wait a minute......
Code: [Select]
(defun start_list () (princ))
START_LIST
_$ (type start_list)
USUBR  ;;<<<<<<not the same as SUBR!
Title: Re: 'start_list' not working...Please help!
Post by: MP on November 08, 2005, 07:10:11 PM
What AutoCAD version Jeff? I copied mine right from the AutoCAD 2004 text screen (albeit cleaned out the command crud).
Title: Re: 'start_list' not working...Please help!
Post by: Jeff_M on November 08, 2005, 07:15:43 PM
This was from the VLIDE in 2002.....going to test in 2006 now
Title: Re: 'start_list' not working...Please help!
Post by: MP on November 08, 2005, 07:16:37 PM
VLIDE? What's that?

 :lmao:
Title: Re: 'start_list' not working...Please help!
Post by: Kerry on November 08, 2005, 07:23:18 PM
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.

Title: Re: 'start_list' not working...Please help!
Post by: Jeff_M on November 08, 2005, 07:35:53 PM
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
Title: Re: 'start_list' not working...Please help!
Post by: MP on November 08, 2005, 09:41:15 PM
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.
Title: Re: 'start_list' not working...Please help!
Post by: Jeff_M on November 08, 2005, 10:04:12 PM
From the Lisp help file:
Quote
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
Title: Re: 'start_list' not working...Please help!
Post by: MP on November 09, 2005, 08:29:21 AM
What's the good word this morning Will?
Title: Re: 'start_list' not working...Please help!
Post by: whdjr on November 09, 2005, 08:31:20 AM
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.

Code: [Select]
(type start_list)
SUBR

(type add_list)
SUBR

(type end_list)
SUBR
Title: Re: 'start_list' not working...Please help!
Post by: MP on November 09, 2005, 08:35:08 AM
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".
Title: Re: 'start_list' not working...Please help!
Post by: whdjr on November 09, 2005, 09:14:51 AM
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.
Title: Re: 'start_list' not working...Please help!
Post by: Jeff_M on November 09, 2005, 09:51:43 AM
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
Title: Re: 'start_list' not working...Please help!
Post by: MP on November 09, 2005, 10:04:49 AM
Good idea Jeff.
Title: Re: 'start_list' not working...Please help!
Post by: MP on November 09, 2005, 10:09:31 AM
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.
Title: Re: 'start_list' not working...Please help!
Post by: whdjr on November 09, 2005, 10:18:10 AM
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.
Title: Re: 'start_list' not working...Please help!
Post by: Kerry on November 09, 2005, 10:25:00 AM
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.




Title: Re: 'start_list' not working...Please help!
Post by: whdjr on November 09, 2005, 10:27:05 AM
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?
Title: Re: 'start_list' not working...Please help!
Post by: LE on November 09, 2005, 10:33:58 AM
Have not done nothing on DCL for quite a while....

Code: [Select]
(start_list "atts" 3 0)

Can you do that... and what happens?
Title: Re: 'start_list' not working...Please help!
Post by: whdjr on November 09, 2005, 10:39:34 AM
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.
Title: Re: 'start_list' not working...Please help!
Post by: MP on November 09, 2005, 10:41:35 AM
W.A.G. ==> Are there any weird *ssed ASCII codes in your source code, like 160?
Title: Re: 'start_list' not working...Please help!
Post by: Jeff_M on November 09, 2005, 10:42:14 AM
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......
Title: Re: 'start_list' not working...Please help!
Post by: MP on November 09, 2005, 10:45:16 AM
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.
Title: Re: 'start_list' not working...Please help!
Post by: whdjr on November 09, 2005, 10:47:12 AM
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.
Code: [Select]
    (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))
    )
Title: Re: 'start_list' not working...Please help!
Post by: Chuck Gabriel on November 09, 2005, 01:28:53 PM
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.