TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: AVCAD on May 25, 2007, 11:16:11 AM

Title: .cat files? How do they work in LISP??
Post by: AVCAD on May 25, 2007, 11:16:11 AM
I am starting a new project...yes a new one...even though I am not tha good at code but...it keeps me busy tring to learn some new things.

This new one is a Detail manager. Yes I know there are plenty out there but I would like to make my own.

Just a basic manager, you select a catalogue the list comes up, you select your block you hit insert. done.

here is a screen of the ui I have. All my blocks are made or being made. Layering and colors and what layer to insert them on isnt a bigdeal cause they are all created on their correct layers so inserting them on layer 0 is fine and not a big deal to so do a (setvar "clayer" 0) in the code.

(http://img360.imageshack.us/img360/9711/uisymbtv8.png)

I have some Lisp code written for this already but its by far no where near being right or even at apoint where I am not imbarrassed to post it lol.

Now the reason i asked about .cat files is cause I was talking to some here and he said he used a file that was a .cat file that held the list info and block info in there and just had to call that file out. Ofcourse he said he doesnt remember how it worked.....which jsut leads me to believe he didnt actually code it lol.

But thought I would ask here seeing as smart r gents u :-)


edited it cause i had forget to take off my real name on the ui... i dont want you too track me down and kill me...
Title: Re: .cat files? How do they work in LISP??
Post by: T.Willey on May 25, 2007, 11:21:02 AM
If the .cat file is just a text based file, then you can just use 'open' to open the correct file, and the use 'read-line' to get each line of text in the file within a 'while' loop.
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on May 25, 2007, 11:50:09 AM
ya a .cat file is just text

Code: [Select]
Description ---------------------- File ----------------------------------- Block --- Slide --- Slide Lib --------
"C1: RECESSED PTZ CAMERA"        "C:/CHI-CUSTOMCAD/Details/AV-DETAILS"      "C1"      "C1"      "AV-Details"

right now thats what it looks like...I have a .ini file set up...my thought was that i need this file to call out where too look for the files

Code: [Select]
Description ----------------- File
"Books"                       "c:/CHI-CustomCAD/Sybman/Booklist.cat"
"AV Details"                  "c:/CHI-CustomCAD/Sybman/AVdetails.cat"
"TC Details"                  "c:/CHI-CustomCAD/Sybman/TCdetails.cat"
"SC Details"                  "c:/CHI-CustomCAD/Sybman/SCdetails.cat"
"AC Details"                  "c:/CHI-CustomCAD/Sybman/ACdetails.cat"
"TE Details"                  "c:/CHI-CustomCAD/Sybman/TEdetails.cat"
"People/Humans Details"       "c:/CHI-CustomCAD/Sybman/PHdetails.cat"
"TB Details"                  "c:/CHI-CustomCAD/Sybman/TBdetails.cat"
"Misc Details"                "c:/CHI-CustomCAD/Sybman/MISCdetails.cat"

So I was thinking that the Catalog/books would look at the Booklist.cat file wich would hold the list of catalogs in it basically just the drop menu selection. and depending on what book is selected would then call up which list of details to bring up.

it even possible to do this with in vlisp or is this a differant type of programing? This is all new to me, i guess I am just feeling out the landscape.
Title: Re: .cat files? How do they work in LISP??
Post by: T.Willey on May 25, 2007, 12:13:13 PM
If you save all your files (.cat) in the acad search path, then there is no need to have an '.ini' file to locate them.  You can just use the 'findfile' function within lisp to locate the '.cat' files.
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on May 25, 2007, 01:57:47 PM
how would you call out the lines in the cat file? or an ini file for that matter? I just want to see how this all works
Title: Re: .cat files? How do they work in LISP??
Post by: T.Willey on May 25, 2007, 02:08:22 PM
Once you have the path to the file use 'open' and set what is returned to a variable.  Then use 'read-line' on that variable within a 'while' loop.  I'm only giving you hints this time  :wink: so you will have to look into the help to see how to use them.  If you don't understand after that, then maybe I will provide code.  We shall see......  :-)
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on May 25, 2007, 02:27:12 PM
there isnt really a good help file for the read-line function can you explain it a bit?

so far i have..

Code: [Select]
(setq blist (open "c:/chi-customcad/symbman/booklist.cat" "r"))
its a start! lol
Title: Re: .cat files? How do they work in LISP??
Post by: Maverick® on May 25, 2007, 02:32:09 PM
there isnt really a good help file for the read-line function can you explain it a bit?

Googly Moogly (http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node195.html)
Quote
[Function]
read-line &optional input-stream eof-error-p eof-value recursive-p

read-line reads in a line of text terminated by a newline. It returns the line as a character string (without the newline character). This function is usually used to get a line of input from the user. A second returned value is a flag that is false if the line was terminated normally, or true if end-of-file terminated the (non-empty) line. If end-of-file is encountered immediately (that is, appears to terminate an empty line), then end-of-file processing is controlled in the usual way by the eof-error-p, eof-value, and recursive-p arguments.

The corresponding output function is write-line.
Title: Re: .cat files? How do they work in LISP??
Post by: T.Willey on May 25, 2007, 02:32:34 PM
What read-line does is read the lines within a file, one by one.  Each call to it increases to the next line.  So you will want to read all the lines, put them into a list, and then when it's done, put that list into you dcl file.  So to use read-line you would do (with your code provided)
Code: [Select]
(while (setq tempTextLine (read-line blist))
 (setq TextList (cons tempTextLine TextList))
 )
... here add the list to the dcl, and close the file you opened
Title: Re: .cat files? How do they work in LISP??
Post by: T.Willey on May 25, 2007, 02:34:49 PM
there isnt really a good help file for the read-line function can you explain it a bit?

Googly Moogly (http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node195.html)
Quote
[Function]
read-line &optional input-stream eof-error-p eof-value recursive-p

read-line reads in a line of text terminated by a newline. It returns the line as a character string (without the newline character). This function is usually used to get a line of input from the user. A second returned value is a flag that is false if the line was terminated normally, or true if end-of-file terminated the (non-empty) line. If end-of-file is encountered immediately (that is, appears to terminate an empty line), then end-of-file processing is controlled in the usual way by the eof-error-p, eof-value, and recursive-p arguments.

The corresponding output function is write-line.
Common Lisp is a little different than AutoLisp within Acad though, but a good find and tip nontheless.
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on May 25, 2007, 02:58:46 PM
Thats what I have so far...

Code: [Select]
(defun c:symbman ( / dcl_id)

  (setq booklist (open "C:/Chi-CustomCAD/Symbman/Booklist.cat" "r")
(while (setq tempTextLine (read-line booklist))
  (setq TextList (cons tempTextLine TextList)))
  (start_list "books")
  (mapcar 'add_list booklist)
  (end_list)
        (close booklist))

;;----------------------dcl stuff-----------------------------
  (setq dcl_id (load_dialog "symb_man.dcl"))
  (if (not (new_dialog "symb_man" dcl_id))
    (exit)
  ) ;if

is that on the right path? cause it isnt working...
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on May 25, 2007, 03:18:09 PM
hmm....i got the list too work.

part of the code..

Code: [Select]
  (setq booklist (open "C:/Chi-CustomCAD/Symbman/Booklist.cat" "r"))
(while (setq tempTextLine (read-line booklist))
  (setq blist (cons tempTextLine blist)))
        (close booklist)


;;----------------------dcl stuff-----------------------------
  (setq dcl_id (load_dialog "symb_man.dcl"))
  (if (not (new_dialog "symb_man" dcl_id))
    (exit)
  ) ;if

  (start_list "books")
  (mapcar 'add_list blist)
  (end_list)
Title: Re: .cat files? How do they work in LISP??
Post by: CAB on May 25, 2007, 03:23:05 PM
Here is some old code you can use.
Code: [Select]
  ;;  TxtFile2List by CAB
  ;;  open the file, read the data
  ;;  returns data from file
  (defun File2list (filename ; file name
                    onestr ; t = all lines 2 one string
                    case ; nil = no change
                    ;;         U = force to upper case
                    ;;         L = force to lower case
                    / handle stream itm FileData
                   )
    (if
      (and
        (eq 'str (type filename))
        (setq filename (findfile filename))
        (setq handle (open filename "r"))
      )
       (progn
         (while (setq stream (read-line handle))
                  (setq  FileData (cons stream FileData))
         ) ; while
         (close handle)
         
         (if FileData
           (setq FileData
                   (mapcar '(lambda(itm) 
                        (cond
                          ((= case "U") (setq itm (strcase itm)))
                          ((= case "L") (setq itm (strcase itm t)))
                        ) ; cond stmt
                        (if (/= (vl-string-trim " \t\n" itm) "")
                          (if onestr
                            (setq itm (strcat itm (chr 13) itm))
                            (setq itm (cons itm result))
                          )
                        )
                     )
                  (reverse FileData)
                  )
       )
       ) ; progn
    ) ; endif
     FileData
  )
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on May 25, 2007, 04:34:32 PM
how can I get the variable that is selected with in a popup_box in the DCL?

SO when "option 1" is selected in the popup_box a new list is then added too the list box..

Code: [Select]
;;*************************************************************
;;*************************************************************
;;***                                                       ***
;;***            S Y M B _ M A N . L S P                    ***
;;***                                                       ***
;;***         Version 1.0   05/10/07 - STARTED              ***
;;***                                                       ***
;;*************************************************************
;;*************************************************************

;; use this line to run program
(defun c:symbman ( / dcl_id)

;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; X =             Main Routine                  = X
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
(get_blist_list)
(get_avdetails_list)
(get_tcdetails_list)

(get_books) 

;;----------------------dcl stuff-----------------------------
  (setq dcl_id (load_dialog "symb_man.dcl"))
  (if (not (new_dialog "symb_man" dcl_id))
    (exit)
  )

  (start_list "books")
  (mapcar 'add_list blist)
  (end_list)

  (start_list "dlist")
  (mapcar 'add_list details)
  (end_list)

  (action_tile "accept" "(insert_blocks)")
  (action_tile "cancel" "(done_dialog) (setq click nil) (set_var_nil)")

  ;;-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
 
  (start_dialog)
  (unload_dialog dcl_id)

  (if click
    (insert_block)
  )
  (princ)
); end defun

;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;             End Of Main Routine             
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; X =          S u b  R o u t i n e s           = X
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

;;-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
(defun get_blist_list()
  (setq booklist (open "C:/Chi-CustomCAD/Symbman/Booklist.cat" "r"))
(while (setq temp1 (read-line booklist))
  (setq blist (cons temp1 blist)))
        (close booklist)
  )

(defun get_avdetails_list() 
  (setq avdetails (open "C:/Chi-CustomCAD/Symbman/AVdetails.cat" "r"))
(while (setq temp2 (read-line avdetails))
(setq avlist (cons temp2 avlist)))
        (close avdetails)
  )

(defun get_tcdetails_list() 
  (setq tcdetails (open "C:/Chi-CustomCAD/Symbman/TCdetails.cat" "r"))
(while (setq temp3 (read-line tcdetails))
(setq tclist (cons temp3 tclist)))
        (close tcdetails)
  )

(defun get_stuff()
  (get_books)
  (get_detail_lists)
  (setq click T)
  )

(defun get_books()
  (setq bookD (get_tile "books"))
   (cond
    ((= bookD "AV Details")
  (setq details avdetails))
    ((= bookD "TC Details")
  (setq details tcdetails))
    )
  )

(defun set_var_nil()
  (setq blist nil)
  )

(defun insert_blocks()
  (set_var_nil) 
  (setq click T)
  (done_dialog)
  )

;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; X =          E n d   O f   F i l e            = X
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

the DCL

Code: [Select]
symb_man : dialog
{
label = "Detail Manager";        // label for GUI
: popup_list {                                  // starts popup_list
          label = "Catalog:";
          key = "books";           
          edit_width = 20;         
          fixed_width = true;
          }                                     // ends popup_list
// keeps next in the same row
: row {                                         // start row
          fixed_width = true;

// starts to rack information selection box
: boxed_column {                                // start boxed column
          label = "Detail Block Names:";
         
: list_box {                                    // starts list box
          key = "dlist";
          is_tab_stop = true;
          width = 30;
          }                                     // ends edit box
        }                                      // ends boxed column
         
// This image is for the preview box
: boxed_column {                                // start boxed column
          label = "Detail Image:";

: image {                                       // define image tile
         key = "detailimage";                   // give it a name
         color = 0;
         aspect_ratio = 1;                      // aspect of slide file
         width = 30;                  // and now a width
         fixed_height = true;
         }                                      // ends image
       } // ends boxed column
     }
// end of the preview box code
     
// starts cancel, ok buttons
: row {          // defines the OK/Cancel button row
  : spacer { width = 1; }
  : button {    // defines the OK button
    label = "&Ok";
    is_default = true;
    key = "accept";
    width = 8;
    fixed_width = true;
  }
  : button {    // defines the Cancel button
    label = "&Cancel";
    is_cancel = true;
key = "cancel";
    width = 8;
    fixed_width = true;
  }
  : spacer { width = 1;}
} // starts cancel, ok buttons
: row {
  :text {
     label = "";
     }
     }
  // starts the logo and paragraph
}                                               // ends dialog

Heres what I got...so far....To be coontinued...i am going to get my drink on....
Title: Re: .cat files? How do they work in LISP??
Post by: T.Willey on May 25, 2007, 05:08:07 PM
You have (within the lisp) an action_tile call that watches when the value of the popup_list is changed.  When it is changed, it will call a sub-routine that will
First: clear the list
Second: populate the list again with the new value

It might also have to recognized what value is select, and then find the correct '.cat' file to fill the list_box with.
Title: Re: .cat files? How do they work in LISP??
Post by: CAB on May 25, 2007, 05:16:21 PM
AVCAD
Look here, scroll down to My Popup List
http://web2.airmail.net/terrycad/Tutorials/MyDialogs.htm

More info here:
http://www.jefferypsanders.com/autolisp_DCL.htm
Title: Re: .cat files? How do they work in LISP??
Post by: CAB on May 25, 2007, 05:23:39 PM
One more:
http://www.afralisp.net/lispa/lisp71.htm
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on May 30, 2007, 10:26:22 AM
hmm..i tried to work with this again but i dont know all the lisp commands too well and cant find what some things actually do like $value i see it alot in code but i cant find any help files telling me what it actually is.

I changed some code and got some stuff to work. Like I get the drop down list now for the catalogs which is reading from a .cat file. and I get the detail list variable set but my condition statment isnt working. probably because i dont know what action_tile command to use to constantly watch the dropdown menu...

I added in a defun too set all the variables used too back to nil once you hit escape (cancle) or accept. I was finding that with out that the drop list just kept getting longer and longer with the same info.

I am trying to work on this in sections so i am not all over the place.

first goal was just to get the dcl right..i did that, that i am actually not too bad at.

second was too get the lisp to actually load the dcl...i am getting better at that...

third was too get the variables to load what i wanted it too load...which it does..if you run the program and check the variables with !(name) they are right....i think  :ugly:

fourth I got the drop down too populate from the cat file...

now...i need too get the drop down to be constantly monitored for a change and to have that change talk to the detail list box so that depending on the drop menu option selected is what list would be visiable in the list box.

I guess once that happens...next step would be to get the selection in the list box and insert the correct detail depending on that selection...but i want to get that list box worked out first

I dont want you guys to completly write this but if you can give me some examples of thes action_tiles and how they are monitored it would be really helpful.

CAB...i read the sites you posted but honestly sometimes its like reading chinese too me....I do appreciate the sites and I read them all the time and every now and then the light comes on and i go "oh, shit thats what it means" lol

here is the code.

Code: [Select]
;; use this line to run program
(defun c:symbman ( / dcl_id)
 
;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; X =             Main Routine                  = X
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

(get_alllists)
;; (get_books)

;;----------------------dcl stuff-----------------------------
  (setq dcl_id (load_dialog "symb_man.dcl"))
  (if (not (new_dialog "symb_man" dcl_id))
    (exit)
  )

  (start_list "books")
  (mapcar 'add_list blist)
  (end_list)

  (start_list "dlist")
  (mapcar 'add_list details)
  (end_list)

  (mode_tile "books" 2)
 
  (action_tile "books" "(setq books $value)")
  (action_tile "dlist" "(setq block $value)")
  (action_tile "accept" "(insert_blocks)")
  (action_tile "cancel" "(done_dialog) (setq click nil)")
  ;;(set_var_nil) ;; add to cancel once working
  ;;(set_slide) ;; for slide setup

  ;;-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
 
  (start_dialog)
  (unload_dialog dcl_id)

  (if click
    (insert_block)
  )

); end defun

;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;             End Of Main Routine             
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; X =          S u b  R o u t i n e s           = X
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

;;-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

(defun get_alllists()
  (setq booklist (open "C:/Chi-CustomCAD/Symbman/Booklist.cat" "r"))
(while (setq temp (read-line booklist))
  (setq blist (cons temp blist)))
        (close booklist)

  (setq avdetails (open "C:/Chi-CustomCAD/Symbman/AVdetails.cat" "r"))
(while (setq temp0 (read-line avdetails))
(setq avlist (cons temp0 avlist)))
        (close avdetails)

  (setq tcdetails (open "C:/Chi-CustomCAD/Symbman/TCdetails.cat" "r"))
(while (setq temp1 (read-line tcdetails))
(setq tclist (cons temp1 tclist)))
        (close tcdetails)
  )

(defun get_books()
   (cond
    ((= books "0") (setq details avlist))
    ((= books "1") (setq details tclist))
;;    ((= books "2") (setq details sclist))
;;    ((= books "3") (setq details aclist))
;;    ((= books "4") (setq details telist))
;;    ((= books "5") (setq details phlist))
;;    ((= books "6") (setq details titleblocks))
;;    ((= books "7") (setq details misclist))
    )
  )

(defun set_var_nil()
  (setq blist nil)
  (setq avlist nil)
  (setq avdetails nil) 
  (setq tclist nil)
  (setq tcdetails nil)
  (setq books nil)
  (setq booklist nil)
  (setq details nil)
  )

(defun insert_blocks()
  ;;(set_var_nil)
  (setq click T)
  (done_dialog)
    (princ "\nInserting Blocks...")
  )
     

;;======================================================
;;           Dialog Box - Slide Change                 
;;======================================================
;;  any time a change in "dlist"
;;(defun set_slide (/ x y slide)
;;  (start_image "detail") ; start the image
;;  (setq x (dimx_tile "detail"))
;;  (setq y (dimy_tile "detail"))

;;  (start_image "detail")
;;  (fill_image 0 0 x y 0) ; 0 = black backgroun -15 = gray)
;;  (slide_image 0 -30 x y slide)
;;  (end_image) ; end image
;;) ; defun set_slide

;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; X =          E n d   O f   F i l e            = X
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

here is the DCL it hasnt changed...

Code: [Select]
symb_man : dialog
{
label = "Detail Manager";        // label for GUI
: popup_list {                                  // starts popup_list
          label = "Catalog:";
          key = "books";           
          edit_width = 20;         
          fixed_width = true;
          }                                     // ends popup_list
// keeps next in the same row
: row {                                         // start row
          fixed_width = true;

// starts to rack information selection box
: boxed_column {                                // start boxed column
          label = "Detail Block Names:";
         
: list_box {                                    // starts list box
          key = "dlist";
          is_tab_stop = true;
          width = 30;
          }                                     // ends edit box
        }                                      // ends boxed column
         
// This image is for the preview box
: boxed_column {                                // start boxed column
          label = "Detail Image:";

: image {                                       // define image tile
         key = "detailimage";                   // give it a name
         color = 0;
         aspect_ratio = 1;                      // aspect of slide file
         width = 30;                  // and now a width
         fixed_height = true;
         }                                      // ends image
       } // ends boxed column
     }
// end of the preview box code
     
// starts cancel, ok buttons
: row {          // defines the OK/Cancel button row
  : spacer { width = 1; }
  : button {    // defines the OK button
    label = "&Ok";
    is_default = true;
    key = "accept";
    width = 8;
    fixed_width = true;
  }
  : button {    // defines the Cancel button
    label = "&Cancel";
    is_cancel = true;
key = "cancel";
    width = 8;
    fixed_width = true;
  }
  : spacer { width = 1;}
} // starts cancel, ok buttons
: row {
  :text {
     label = "";
     }
     }
  // starts the logo and paragraph
}                                               // ends dialog

Title: Re: .cat files? How do they work in LISP??
Post by: T.Willey on May 30, 2007, 11:56:04 AM
now...i need too get the drop down to be constantly monitored for a change and to have that change talk to the detail list box so that depending on the drop menu option selected is what list would be visiable in the list box.
For this you need to assign an 'action_tile' to the drop down list.  The '$value' will return what item is selected in the drop down list.  You will need to change what is returned from a string to a number and use the 'nth' function on the list (used to populate the drop down list) to get the right file.  I would use this way instead of trying to list them in a 'cond' statement like you have.

I guess once that happens...next step would be to get the selection in the list box and insert the correct detail depending on that selection...but i want to get that list box worked out first
You need to look at what you can do with the 'start_list' function.  You can empty the list before you fill it, which is what I would do in your case.

Hope that helps.
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on May 30, 2007, 02:50:14 PM
sweet...i got the lists to work right.

not quite sure if i did it the way you were talking about it but it works :-)

I didnt use the nth function...i tried too but its one of those new functions i dont really understand. I am sure it would have probably easier to use it if I understood it.

attached in the program in its current form.

just so you can see it.

So...now that the list populates, the variable (named block) comes up with a number which I dealt with with the popup_list too but that was fine it wasnt a big deal i jsut used the number to call out the list variable to use. but for the blocks i kind of think it would be easier to get the actual name of the block. I know the $value function will just return a number like "1" or "0" depending on what is selected and where it lies in that list...

But for blocks it doesnt work too well cause depending on the catalog that is selected is going to dictate what block it is and 1 or 0 can be anything....that doesnt too clear.../sigh i dont know how to to explain it right now...hopefully someone just understands :-)

what i was thinking of doing for the path of these details is something like

Code: [Select]
(setq avpath "c:/symbman/AV/")
having a setq for each one, AV, TC, SC etc...

and then hoping....to get the block name by the block variable...or maybe I would have set a setq for that too or a cond...maybe like

Code: [Select]
(defun get_blknm()
(cond
((= block "1") (setq blknm "P1"))
((= block "2") (setq blknm "P2"))
)
)

Idk i am just brain storming here and the keypad is infront of me....

i guess then maybe I can call out the insert like...

Code: [Select]
(defun insert_block()
(cond
((= books "0") (command ".-insert" "avpath blknm" / "" "" "" ""))
((= books "1") (command ".-insert" "tcpath blknm" / "" "" "" ""))
)
)

i dont even know if thats possible to do have 2 variables work together, i guess i could skip the avpath variable and just have..

Code: [Select]
(defun insert_block()
(cond
((= books "0") (command ".-insert" "c:\\symbman\\AV\\/"blknm" / "" "" "" ""))
((= books "1") (command ".-insert" "c:\\symbman\\TC\\/"blknm" / "" "" "" ""))
)
)

i dont even know if that works...i am gonna stop typing...i am confusing myself again....








Title: Re: .cat files? How do they work in LISP??
Post by: T.Willey on May 30, 2007, 03:04:58 PM
This part of your code
Code: [Select]
(action_tile "dlist" "(setq block $value)")Will return a number (as a string), which is where the item selected within the list box is at.  So if the first item is selected, it will return a string that has the number zero in it ( "0" ).  With a string you need to change it to an integer 'atoi' (alpha to integer).  Then you can use the 'nth' function with the value returned by 'atoi' on the list that you populated the list box with.  So in you 'chk_books' function I would assign a variable to the list selected each time the popup list is changed.  Say you call it 'catlist' then to get the block name you would use
Code: [Select]
(setq blkname (nth (atoi block) catlist))
To combine two string variable you would use 'strcat' (string characters) on them.

Hope this helps.
Title: Re: .cat files? How do they work in LISP??
Post by: jbuzbee on May 30, 2007, 03:39:51 PM
Sorry to come so late to the party, but your working WAAAAYYYY to hard at this.   :-o  Witness the following:

(http://www.studio2405.com/jdb/dm-01.gif)

The preview is a robust blockview that lets you zoom, pan, and orbit:

(http://www.studio2405.com/jdb/dm-02.gif)

The tree view is programmed to read a list of drawings in a specific directory according to scale.  All blocks starting with "D_" are displayed in the preview.  The blocks can be "imported" from the remote drawing into the active drawing and then inserted (all with a click of the add button).  As you can see I havn't had alot of time to work on our block drawings -

So, lets recap: All details are stored in drawings that corresponds with the plot scale, i.e. 1/2" = 1'-0" etc.  Benefit: Organization.  Lets say your company changes a standard like a layer or text style.  If you have literally hundreds of detail drawings, even using the Standards Manager becomes a daunting task.  With details as blocks in container drawings, standards can be managed easily and globally.

Furthermore this project is extremely simple, both in code and organization.  If you'd like me to post it so you can play around and customize it to your own needs, just let me know.  This will also be a good way to wean you off dcl and into OpenDCL.  Oh, and it's a modeless dialog, which means it floats like a palette . . ..
Title: Re: .cat files? How do they work in LISP??
Post by: Guest on May 30, 2007, 03:46:55 PM
Yeah... post it if you don't mind.  I'd like to poke around with it.

I've just started messing around with ODCL and so far.... me likey!

Here's a SS of a simple program that I've toying with....pretty simple, but it saves a lot of time when having to switch between named views (which we do quite a bit).
Title: Re: .cat files? How do they work in LISP??
Post by: GDF on May 30, 2007, 03:48:02 PM
James

Quote
With details as blocks in container drawings, standards can be managed easily and globally.

I am learning the hard way, that container drawings have a lot of advantages.

If you stick with dcl, you can always add an image preview enlarger...

Gary
Title: Re: .cat files? How do they work in LISP??
Post by: Guest on May 30, 2007, 03:51:01 PM
But if you use the DwgPreview control in ODCL, you wouldn't need the extra SLD or SLB file to view the drawing - and what happens when your drawing changes?  You have to remember to update the slide image.
Title: Re: .cat files? How do they work in LISP??
Post by: Guest on May 30, 2007, 03:57:32 PM
So, lets recap: All details are stored in drawings that corresponds with the plot scale, i.e. 1/2" = 1'-0" etc.  Benefit: Organization. 
Let me see if I follow you...

Let's say you have a "host" drawing called "BOLTS".  Within that host drawing you have blocks of various size/length bolts and from your little do-hickey there, you can import a block from the host drawing into the current drawing??
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on May 30, 2007, 04:08:54 PM
i am sorry I have no clue what open DCL is....i have seen it pop it lately, is it something new with Acad? we are still on 2004....
Title: Re: .cat files? How do they work in LISP??
Post by: Guest on May 30, 2007, 04:12:41 PM
It's just the greatest thing (http://otb.manusoft.com/2007/01/introducing-opendcl-for-autocad.htm) since the line command.

Think of it as DCL on steroids.
Title: Re: .cat files? How do they work in LISP??
Post by: jbuzbee on May 30, 2007, 04:33:15 PM
Quote
Let's say you have a "host" drawing called "BOLTS".  Within that host drawing you have blocks of various size/length bolts and from your little do-hickey there, you can import a block from the host drawing into the current drawing??

Exactly.  Lets say you want to complete a suite of window details.  Everytime the damn architect wants a new sill detail, or casing detail, or whatever, just take a detail that's closest in said drawing; copy; explode; modify; save with a new name; bang: Dialog updates, preview updates, instantly available to users, your a small autocad god, etc.

Take a look at the attached.

You'll need to add somewhere:

Code: [Select]
(vl-load-com)

(setq jbthisdrawing(vla-get-activedocument(vlax-get-acad-object)))

And just make sure OpenDCL.arx is loaded.
Title: Re: .cat files? How do they work in LISP??
Post by: GDF on May 30, 2007, 04:36:45 PM
But if you use the DwgPreview control in ODCL, you wouldn't need the extra SLD or SLB file to view the drawing - and what happens when your drawing changes?  You have to remember to update the slide image.

Matt

True you do have to make the slide (only one slide is needed per block). To help with creating the slide library, I use
Slideman.exe

One of these days I will learn opendcl...

Gary
Title: Re: .cat files? How do they work in LISP??
Post by: GDF on May 30, 2007, 04:40:20 PM
Quote
Let's say you have a "host" drawing called "BOLTS".  Within that host drawing you have blocks of various size/length bolts and from your little do-hickey there, you can import a block from the host drawing into the current drawing??

Exactly.  Lets say you want to complete a suite of window details.  Everytime the damn architect wants a new sill detail, or casing detail, or whatever, just take a detail that's closest in said drawing; copy; explode; modify; save with a new name; bang: Dialog updates, preview updates, instantly available to users, your a small autocad god, etc.

Take a look at the attached.

You'll need to add somewhere:

Code: [Select]
(vl-load-com)

(setq jbthisdrawing(vla-get-activedocument(vlax-get-acad-object)))

And just make sure OpenDCL.arx is loaded.

James

You mean darn architect?

Where do I get opendcl.arx for 2008?

Gary
Title: Re: .cat files? How do they work in LISP??
Post by: jbuzbee on May 30, 2007, 04:43:55 PM
Quote
You mean darn architect?
I can say that - I am one!!  :lmao: (it's funnier than you think)

OpenDCL is here:

http://sourceforge.net/projects/opendcl (http://sourceforge.net/projects/opendcl)
Title: Re: .cat files? How do they work in LISP??
Post by: GDF on May 30, 2007, 04:49:25 PM
James

When I go to the site...all I want  (or need) is the arx file. What is the full install?

Gary
Title: Re: .cat files? How do they work in LISP??
Post by: GDF on May 30, 2007, 05:09:37 PM
James

When I go to the site...all I want  (or need) is the arx file. What is the full install?

Gary

James

Ok, I have the opendcl.arx file and have run your routine (loaded all files).

Command: ; error: no function definition: JB:STANDARDANNOBLOCKADD

Command: ; error: no function definition: JB:OPENDBXDOCUMENT

No image and the error messages above^

Thanks

Gary

Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on May 30, 2007, 05:20:45 PM
As much as i appreciate the info on OpenDCL and yet another way I will probably have to learn to do things...I think I am gonna focus on this untill i can get it down pretty good. I  think Either way you have to know LSP dont you? the Creating the DCL was never a probaly for me its the LSP code that does it....

Ok anyways..

I up loaded a new version some code changes and what not...it asks me for a block name now when i run the insert command...but I have a (strcat path blknm) in there but its not taking it...both variables are set correctly but its jsut not going into the insert command right. I think I am doing it right but I am sure there is like a . or a ; or a ) missing somewhere....

Some blocks are included in the attachment jsut the ones that its coded for right now

Title: Re: .cat files? How do they work in LISP??
Post by: T.Willey on May 30, 2007, 05:39:36 PM
You are making this harder than it needs to be.  This whole defun is not needed.
Code: [Select]
(defun get_blknm()
  (cond
    ((= books "0") (= block "0") (setq blknm "PS1.dwg"))
    ((= books "0") (= block "1") (setq blknm "PS2.dwg"))
    ((= books "0") (= block "2") (setq blknm "PS3.dwg"))
    ((= books "0") (= block "3") (setq blknm "nil"))
    ((= books "0") (= block "4") (setq blknm "SP1.dwg"))
    ((= books "0") (= block "5") (setq blknm "SP2.dwg"))
    ((= books "0") (= block "6") (setq blknm "SP3.dwg"))
    ((= books "0") (= block "7") (setq blknm "SP4.dwg"))
    ((= books "0") (= block "8") (setq blknm "SP5.dwg"))
    ((= books "0") (= block "9") (setq blknm "SP6.dwg"))
    ((= books "0") (= block "10") (setq blknm "SP7.dwg"))
    ((= books "0") (= block "11") (setq blknm "SP8.dwg"))
    ((= books "0") (= block "12") (setq blknm "SP9.dwg"))
    ((= books "0") (= block "13") (setq blknm "SP10.dwg"))
    ((= books "0") (= block "14") (setq blknm "SP11.dwg"))
    )
  )
With running the code, the variable 'avlist' returns this.
Quote
"PS1: Tab Tensioned Projection Screen"
"PS2: Manual Projection Screen"
"PS3: Motorized Projection Screen"
"[....]"
"SP1: Recessed Speaker Enclose"
"SP2: Flush Mounted Speaker"
"SP3: Landscape Speaker"
"SP4: Pendant Speaker"
"SP5: Pole Mounted Speaker"
"SP6: Recessed Program Speaker"
"SP7: Ceiling Speaker"
"SP8: Ceiling Speaker"
"SP9: Recessed Subwoofer Speaker"
"SP10: Ceiling Mounted Program Speaker"
"SP11: Wall Mounted Program Speaker"
With this part of the code
Code: [Select]
(action_tile "dlist" "(setq block $value)")You get a string containing a number, which will relate to and item in the above list.  Lets say block = "1" for now.  This means that you want to insert "PS2.dwg".  This
Code: [Select]
(setq tempStr (nth (atoi block) avlist))will set tempStr = "PS2: Manual Projection Screen".  Now since you have an identifier between the block name and the description, you can trim the string to show only the block name with something like
Code: [Select]
(setq Pos (vl-string-search ":" tempStr))
(setq BlkName (substr tempStr 1 Pos))
Now BlkName = "PS2", so your insert part will look like
Code: [Select]
(command "_.insert" (strcat path BlkName ".dwg") pause pause pause)
Does this make sense?  The great thing about lisp is lists.  Learn to use them and you can do so many things.
Title: Re: .cat files? How do they work in LISP??
Post by: jbuzbee on May 30, 2007, 06:30:53 PM
Gary, let me correctly wrap this into an application instead of piecemealing it together.  I have multiple sub routines spread out over a wide array of files.  Let me put something together tested and I'll post . . ..
Title: Re: .cat files? How do they work in LISP??
Post by: jbuzbee on May 30, 2007, 06:41:07 PM
Forgot one little routine.  I copied them all into one file.  This works for me . . ..
Title: Re: .cat files? How do they work in LISP??
Post by: Guest on May 31, 2007, 08:35:48 AM
Nice little proggy... Can't wait to disect it.   :evil:

One thing I noticed... The DWG preview is mirrored.  I assume it's not like that on your end?  The drawing inserts just fine, but the view is flip-flopped.
Title: Re: .cat files? How do they work in LISP??
Post by: GDF on May 31, 2007, 11:35:01 AM
Forgot one little routine.  I copied them all into one file.  This works for me . . ..

James

Thanks...still getting an error.

Command: JBDETAILMANAGER
; error: bad argument type: stringp nil

Command:
Command: ; error: bad argument type: stringp nil

Gary
Title: Re: .cat files? How do they work in LISP??
Post by: Guest on May 31, 2007, 11:41:54 AM
1. You have to have a KB.dws file
2. You need a subfolder called DETAILS
3. The attached DWG goes into the DETAILS folder

(I think that's all)
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on May 31, 2007, 12:58:52 PM
Ok...

TW..I took you advice and youre right that was alot easier to get I dont need to have a big long list of Cond statments...thanks! I didnt know how that all worked which is why i probably never thought of it.

But i still get this

(http://img46.imageshack.us/img46/9900/shituu3.png)

The insert command should work....if I run it manually and copy and past in the strcat like it works fine but in when you hit except i get the above. it just asks for a block name its like it isnt reading the strcat in the command....idk..

I attached the latest of the code no blocks cause you should have them from the previous posting.

maybe I jsut attached the code wrong but i dont know from the looks of it too me at least it should work.
Title: Re: .cat files? How do they work in LISP??
Post by: CAB on May 31, 2007, 01:56:56 PM
AVCAD
Another version to consider.

<edit: new lisp>
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on May 31, 2007, 02:12:55 PM
hmm...i tried it but it froze my ACAD...

i think i am pretty close on mine, I jsut dont know why it gives me what i get in my last post...after that works I jsut have to get the slides too work....might be easier then i think though
Title: Re: .cat files? How do they work in LISP??
Post by: CAB on May 31, 2007, 03:08:49 PM
Sorry about that, I changed the lisp file if you want to try again.

I only wanted to expose you to other ways to write the routine.

PS there is no error trap on the INSERT command, That is where I get errors.
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on May 31, 2007, 04:33:20 PM
man this is got me really confused....I cant figure out why it wont insert the block...all the variables are right...the code for the (command ".-insert" (strcat path BlkName) pause "0,0" "" "" "") is right...but i wont insert it.....
Title: Re: .cat files? How do they work in LISP??
Post by: LE on May 31, 2007, 04:41:36 PM
man this is got me really confused....I cant figure out why it wont insert the block...all the variables are right...the code for the (command ".-insert" (strcat path BlkName) pause "0,0" "" "" "") is right...but i wont insert it.....

(command "_.-insert" "MY-BLOCK-NAME-HERE" pause "1.0" "1.0" "") ;; 5 arguments
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on May 31, 2007, 04:50:06 PM
man this is got me really confused....I cant figure out why it wont insert the block...all the variables are right...the code for the (command ".-insert" (strcat path BlkName) pause "0,0" "" "" "") is right...but i wont insert it.....

(command "_.-insert" "MY-BLOCK-NAME-HERE" pause "1.0" "1.0" "") ;; 5 arguments

thats what I have (strcat path BlkName) is a block name its just set in a variable

...well i did edit it too (command ".-insert" (strcat path BlkName) pause "1.0" "1.0" "")

still ge the same error
Title: Re: .cat files? How do they work in LISP??
Post by: LE on May 31, 2007, 05:00:41 PM
man this is got me really confused....I cant figure out why it wont insert the block...all the variables are right...the code for the (command ".-insert" (strcat path BlkName) pause "0,0" "" "" "") is right...but i wont insert it.....

(command "_.-insert" "MY-BLOCK-NAME-HERE" pause "1.0" "1.0" "") ;; 5 arguments

thats what I have (strcat path BlkName) is a block name its just set in a variable

(command ".-insert" (strcat path BlkName) pause "0,0" "" "" "") ;; those are 6.... I mean not that will matter it will have an extra enter, maybe it is something else, try to enclose the filename with findfile (findfile (strcat path BlkName)) .... and see if that works...
Title: Re: .cat files? How do they work in LISP??
Post by: Kerry on May 31, 2007, 05:07:40 PM
is this the problem
??
(defun get_details( / path BlkName)
  (setq usrlyr (getvar "clayer"))
  (setq usrosmode (getvar "osmode"))
  (setq dtllyr (setvar "clayer" "0"))
  (setvar "clayer" dtllyr)
  (command "_.insert" (strcat path BlkName) pause pause pause)
  )

Where are the variables path and BlkName set ?
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on June 01, 2007, 10:05:59 AM
Enclosing it in a Findfile didnt work either i didnt  think it would but at this point I will try anything....

The Path and BlkName variables are set in 2 defuns..

Code: [Select]
(defun set_paths()
  (cond
    ((= books "0") (setq path "C:/Chi-CustomCAD/Symbman/AV/"))
    ((= books "1") (setq path "C:/Chi-CustomCAD/Symbman/TC/"))
    ((= books "2") (setq path "C:/Chi-CustomCAD/Symbman/SC/"))
    ((= books "3") (setq path "C:/Chi-CustomCAD/Symbman/AC/"))
    ((= books "4") (setq path "C:/Chi-CustomCAD/Symbman/TE/"))
    ((= books "5") (setq path "C:/Chi-CustomCAD/Symbman/PEOPLE/"))
    ((= books "6") (setq path "C:/Chi-CustomCAD/Symbman/TB/"))
    ((= books "7") (setq path "C:/Chi-CustomCAD/Symbman/MISC/"))
    )
  )
 
(defun get_blknm()
  (cond
  ((= books "0") (setq tempStr (nth (atoi block) avlist)))
  ((= books "1") (setq tempStr (nth (atoi block) tclist)))
  ((= books "2") (setq tempStr (nth (atoi block) sclist)))
  ((= books "3") (setq tempStr (nth (atoi block) aclist)))
  ((= books "4") (setq tempStr (nth (atoi block) telist)))
  ((= books "5") (setq tempStr (nth (atoi block) phlist)))
  ((= books "6") (setq tempStr (nth (atoi block) tblist)))
  ((= books "7") (setq tempStr (nth (atoi block) misclist)))
  ) 
  (setq Pos (vl-string-search ":" tempStr))
  (setq BlkName (substr tempStr 1 Pos))
  )

(defun get_details( / path BlkName)
  (progn
    (setq usrlyr (getvar "clayer"))
    (setq usrosmode (getvar "osmode"))
    (setq dtllyr (setvar "clayer" "0"))
    (setvar "clayer" dtllyr)
    (command ".-insert" (strcat path BlkName) pause "1.0" "1.0" "")
   )
  )
Title: Re: .cat files? How do they work in LISP??
Post by: LE on June 01, 2007, 10:48:41 AM
Have not read the whole topic or the most of them, so no idea, anyway

What error you are getting?


Now, can you make a variable from one of your paths and a drawing, like:

Quote
Command: (setq dwg "c:/dwgs/mtext.dwg")
"c:/dwgs/mtext.dwg"

Then just paste the insert code in the command line:
Quote
Command: (command ".-insert" dwg pause "1.0" "1.0" "")

What it does?... something like the quote below?
Quote
.-insert Enter block name or [?]: c:/dwgs/mtext.dwg
Units: Inches   Conversion:    1.0000
Specify insertion point or [Basepoint/Scale/X/Y/Z/Rotate]:
Enter X scale factor, specify opposite corner, or [Corner/XYZ] <1>: 1.0 Enter Y
scale factor <use X scale factor>: 1.0
Specify rotation angle <0>:
Command: nil

HTH
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on June 01, 2007, 11:17:38 AM
baiscally thats what it does...there are 2 variables casue its a symbol mananger....the path variable tells it what dir to look in for the blocks...the blkname variable says what block to grab...which is why there is a strcat in there.

Just cant figure out why it doesnt insert it....

I dont really get an "error" per say...i just doesnt do what i want what i get is the following

(http://img46.imageshack.us/img46/9900/shituu3.png)

it jsut doesnt take the strcat and variable names...but all the variables are set correctly and if I type out in the command line (strcat path blkname) i get what I am suppose too. if I run the insert command manually and type that in I get the correct block also...
Title: Re: .cat files? How do they work in LISP??
Post by: T.Willey on June 01, 2007, 11:19:04 AM
I think Kerry is on the right track.  Take the two variables 'path' and 'BlkName' out of the local variable spots of that defun, and make the local in the main one.  This way they will be use though out the whole lisp.  Late, when you are more comfortable with lisp, we will show you a better way of working with more than one defun (sub-function) within a main defun.  This will show the difference between arguments and variables.

So here
Code: [Select]
(defun get_details( / path BlkName) change to
Code: [Select]
(defun get_details()
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on June 01, 2007, 01:05:19 PM
ok I tried that...

I changed

Code: [Select]
(defun get_details( / path BlkName)
too

Code: [Select]
(defun get_details()
and changed it this...

Code: [Select]
(defun c:symbman ( / dcl_id path BlkName)
but when I ran the program it all worked fine untill I hit OK...it then froze ACAD...

Title: Re: .cat files? How do they work in LISP??
Post by: T.Willey on June 01, 2007, 01:20:27 PM
Post what you are using, so we can trouble shoot better.
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on June 01, 2007, 01:34:31 PM
As Requested.

Code: [Select]
;;*************************************************************
;;*************************************************************
;;***                                                       ***
;;***            S Y M B _ M A N . L S P                    ***
;;***                                                       ***
;;***         Version 1.0   05/10/07 - STARTED              ***
;;***                                                       ***
;;*************************************************************
;;*************************************************************

;; use this line to run program
(defun c:symbman ( / dcl_id path BlkName)
 
;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; X =             Main Routine                  = X
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

(set_var_nil)
(get_all_lists)

;;----------------------dcl stuff-----------------------------
  (setq dcl_id (load_dialog "symb_man.dcl"))
  (if (not (new_dialog "symb_man" dcl_id))
    (exit)
  )

  (start_list "catalog")
  (mapcar 'add_list blist)
  (end_list)

  (mode_tile "catalog" 2)
  (mode_tile "catalog" 3)

  (action_tile "catalog" "(setq books $value) (chk_books)") 
  (action_tile "dlist" "(setq block $value)")
  (action_tile "accept" "(insert_block)")
  (action_tile "cancel" "(done_dialog) (setq click nil)")

  ;;(set_slide) ;; for slide setup

  ;;-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
 
  (start_dialog)
  (unload_dialog dcl_id)

  (if click
    (insert_block)
  )

); end defun

;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;             End Of Main Routine             
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; X =          S u b  R o u t i n e s           = X
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

;;-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

(defun get_all_lists()
  (setq booklist (open "C:/Chi-CustomCAD/Symbman/Booklist.cat" "r"))
(while (setq temp (read-line booklist))
  (setq blist (cons temp blist)))
        (close booklist)

  (setq avdetails (open "C:/Chi-CustomCAD/Symbman/AVdetails.cat" "r"))
(while (setq temp0 (read-line avdetails))
(setq avlist (cons temp0 avlist)))
        (close avdetails)

  (setq tcdetails (open "C:/Chi-CustomCAD/Symbman/TCdetails.cat" "r"))
(while (setq temp1 (read-line tcdetails))
(setq tclist (cons temp1 tclist)))
        (close tcdetails)
   
  (setq scdetails (open "C:/Chi-CustomCAD/Symbman/SCdetails.cat" "r"))
(while (setq temp2 (read-line scdetails))
(setq sclist (cons temp2 sclist)))
        (close scdetails)

  (setq acdetails (open "C:/Chi-CustomCAD/Symbman/ACdetails.cat" "r"))
(while (setq temp3 (read-line acdetails))
(setq aclist (cons temp3 aclist)))
        (close acdetails)

  (setq tedetails (open "C:/Chi-CustomCAD/Symbman/TEdetails.cat" "r"))
(while (setq temp4 (read-line tedetails))
(setq telist (cons temp4 telist)))
        (close tedetails)

  (setq phdetails (open "C:/Chi-CustomCAD/Symbman/PHdetails.cat" "r"))
(while (setq temp5 (read-line phdetails))
(setq phlist (cons temp5 phlist)))
        (close phdetails)

  (setq titleblocks (open "C:/Chi-CustomCAD/Symbman/Titleblocks.cat" "r"))
(while (setq temp6 (read-line titleblocks))
(setq tblist (cons temp6 tblist)))
        (close titleblocks)

  (setq miscdetails (open "C:/Chi-CustomCAD/Symbman/MISCdetails.cat" "r"))
(while (setq temp7 (read-line miscdetails))
(setq misclist (cons temp7 misclist)))
        (close miscdetails)
)

(defun chk_books()
;; book = 0 = AV Details
;; book = 1 = TC Details
;; book = 2 = SC Details
;; book = 3 = AC Details
;; book = 4 = TE Details
;; book = 5 = PEOPLE Details
;; book = 6 = TITLEBLOCKS Details
;; book = 7 = MISC Details
  (start_list "dlist" 3)
  (cond
  ((= books "0") (mapcar 'add_list avlist))
  ((= books "1") (mapcar 'add_list tclist))
  ((= books "2") (mapcar 'add_list sclist))
  ((= books "3") (mapcar 'add_list aclist))
  ((= books "4") (mapcar 'add_list telist))
  ((= books "5") (mapcar 'add_list phlist))
  ((= books "6") (mapcar 'add_list tblist))
  ((= books "7") (mapcar 'add_list misclist))
  )
  (end_list)
  )

(defun set_paths()
  (cond
    ((= books "0") (setq path "C:/Chi-CustomCAD/Symbman/AV/"))
    ((= books "1") (setq path "C:/Chi-CustomCAD/Symbman/TC/"))
    ((= books "2") (setq path "C:/Chi-CustomCAD/Symbman/SC/"))
    ((= books "3") (setq path "C:/Chi-CustomCAD/Symbman/AC/"))
    ((= books "4") (setq path "C:/Chi-CustomCAD/Symbman/TE/"))
    ((= books "5") (setq path "C:/Chi-CustomCAD/Symbman/PEOPLE/"))
    ((= books "6") (setq path "C:/Chi-CustomCAD/Symbman/TB/"))
    ((= books "7") (setq path "C:/Chi-CustomCAD/Symbman/MISC/"))
    )
  )
 
(defun get_blknm()
  (cond
    ((= books "0") (setq tempStr (nth (atoi block) avlist)))
    ((= books "1") (setq tempStr (nth (atoi block) tclist)))
    ((= books "2") (setq tempStr (nth (atoi block) sclist)))
    ((= books "3") (setq tempStr (nth (atoi block) aclist)))
    ((= books "4") (setq tempStr (nth (atoi block) telist)))
    ((= books "5") (setq tempStr (nth (atoi block) phlist)))
    ((= books "6") (setq tempStr (nth (atoi block) tblist)))
    ((= books "7") (setq tempStr (nth (atoi block) misclist)))
    )
    (setq Pos (vl-string-search ":" tempStr))
    (setq BlkName (substr tempStr 1 Pos))
  )

(defun get_details()
  (setq Pos (vl-string-search ":" tempStr))
  (setq BlkName (substr tempStr 1 Pos))
  (setq usrlyr (getvar "clayer"))
  (setq usrosmode (getvar "osmode"))
  (setq dtllyr (setvar "clayer" "0"))
  (setvar "clayer" dtllyr)
  (command ".-insert" (strcat path BlkName) pause "1.0" "1.0" "")
  )
(princ)

(defun set_var_nil()
  (setq blist nil)
  (setq booklist nil) 
  (setq avlist nil)
  (setq tclist nil)
  (setq sclist nil)
  (setq aclist nil)
  (setq telist nil)
  (setq phlist nil)
  (setq tblist nil)
  (setq misclist nil)
  (setq avdetails nil)
  (setq tcdetails nil)
  (setq scdetails nil)
  (setq acdetails nil)
  (setq tedetails nil)
  (setq phdetails nil)
  (setq titleblocks nil)
  (setq miscdetails nil) 
  (setq books nil)
  (setq details nil)
  (setq blocks nil)
  (setq usrlyr nil)
  (setq usrosmode nil)
  (setq dtllyr nil)
  (setq BlkName nil)
  (setq path nil)
  (setq tempStr nil)
  (setq Pos nil)
  )

(defun insert_block()
  (set_paths)
  (get_blknm)
  (get_details)
  (setq click T)
  (done_dialog)
  )
     

;;======================================================
;;           Dialog Box - Slide Change                 
;;======================================================
;;  any time a change in "dlist"
;;(defun set_slide (/ x y slide)
;;  (start_image "detail") ; start the image
;;  (setq x (dimx_tile "detail"))
;;  (setq y (dimy_tile "detail"))

;;  (start_image "detail")
;;  (fill_image 0 0 x y 0) ; 0 = black backgroun -15 = gray)
;;  (slide_image 0 -30 x y slide)
;;  (end_image) ; end image
;;) ; defun set_slide

;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; X =          E n d   O f   F i l e            = X
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

DCL code:

Code: [Select]
symb_man : dialog
{
label = "Detail Manager";        // label for GUI
: popup_list {                                  // starts popup_list
          label = "Catalog:";
          key = "catalog";           
          edit_width = 20;
          fixed_width = true;
          }                                     // ends popup_list
// keeps next in the same row
: row {                                         // start row
          fixed_width = true;

// starts to rack information selection box
: boxed_column {                                // start boxed column
          label = "Detail Block Names:";
         
: list_box {                                    // starts list box
          key = "dlist";
          is_tab_stop = true;
          width = 40;
          }                                     // ends edit box
        }                                      // ends boxed column
         
// This image is for the preview box
: boxed_column {                                // start boxed column
          label = "Detail Image:";

: image {                                       // define image tile
         key = "detailimage";                   // give it a name
         color = 0;
         aspect_ratio = 1;                      // aspect of slide file
         width = 30;                  // and now a width
         fixed_height = true;
         }                                      // ends image
       } // ends boxed column
     }
// end of the preview box code
     
// starts cancel, ok buttons
: row {          // defines the OK/Cancel button row
  : spacer { width = 1; }
  : button {    // defines the OK button
    label = "&Ok";
    is_default = true;
    key = "accept";
    width = 8;
    fixed_width = true;
  }
  : button {    // defines the Cancel button
    label = "&Cancel";
    is_cancel = true;
key = "cancel";
    width = 8;
    fixed_width = true;
  }
  : spacer { width = 1;}
} // starts cancel, ok buttons
: row {
  :text {
     label = "";
     }
     }
  // starts the logo and paragraph
}                                               // ends dialog
Title: Re: .cat files? How do they work in LISP??
Post by: CAB on June 01, 2007, 01:57:40 PM
Change this:
Code: [Select]
(action_tile "accept" "(insert_block)")to this:
Code: [Select]
(action_tile "accept" "(setq click t)")
Title: Re: .cat files? How do they work in LISP??
Post by: T.Willey on June 01, 2007, 02:03:39 PM
The problem is you are trying to have the user select the insertion point before you end the dialog.  You need to do two things.  First change this
Code: [Select]
  (if click
    (insert_block)
  )
to
Code: [Select]
  (if click
    (get_details)
  )
And then comment out the '(get_details)' function in the 'insert_block' function. Like
Code: [Select]
(defun insert_block()
  (set_paths)
  (get_blknm)
;  (get_details)
  (setq click T)
  (done_dialog)
  )

What Alan said might work, but I would do it this way.
Title: Re: .cat files? How do they work in LISP??
Post by: CAB on June 01, 2007, 02:18:26 PM
My 2 cents. 8-)
The code as written has too many gotchas in it & too many global variables.
The vars books & block are not set to a default value so if the user clicks accept before picking the
book & block it will crash & burn.

See my code offering for some solutions.

My last suggestion will work. It only gets the dialog closed before proceeding.
Title: Re: .cat files? How do they work in LISP??
Post by: T.Willey on June 01, 2007, 02:26:31 PM
My 2 cents. 8-)
The code as written has too many gotchas in it & too many global variables.
The vars books & block are not set to a default value so if the user clicks accept before picking the
book & block it will crash & burn.
x2!

My last suggestion will work. It only gets the dialog closed before proceeding.
Wasn't sure since I didn't see a done_dialog call, but you use dcl for more routines that I do, so I figured you would know better.  :-)
Title: Re: .cat files? How do they work in LISP??
Post by: CAB on June 01, 2007, 02:29:42 PM
My last suggestion will work. It only gets the dialog closed before proceeding.
Wasn't sure since I didn't see a done_dialog call, but you use dcl for more routines that I do, so I figured you would know better.  :-)
Maybe not, donedialog that is. :-)
I'm confusing the two routines now. :-o
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on June 01, 2007, 03:01:12 PM
OK! It will now insert the blocks. CAB your solution didnt work for me for somereason did work on your end?

Here is the working code:

Code: [Select]
;;*************************************************************
;;*************************************************************
;;***                                                       ***
;;***            S Y M B _ M A N . L S P                    ***
;;***                                                       ***
;;***         Version 1.0   05/10/07 - STARTED              ***
;;***                                                       ***
;;*************************************************************
;;*************************************************************

;; use this line to run program
(defun c:symbman ( / dcl_id path BlkName)
 
;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; X =             Main Routine                  = X
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

(set_var_nil)
(get_all_lists)

;;----------------------dcl stuff-----------------------------
  (setq dcl_id (load_dialog "symb_man.dcl"))
  (if (not (new_dialog "symb_man" dcl_id))
    (exit)
  )

  (start_list "catalog")
  (mapcar 'add_list blist)
  (end_list)

  (mode_tile "catalog" 2)

  (action_tile "catalog" "(setq books $value) (chk_books)") 
  (action_tile "dlist" "(setq block $value)")
  (action_tile "accept" "(insert_block)")
  (action_tile "cancel" "(done_dialog) (setq click nil)")

  ;;(set_slide) ;; for slide setup

  ;;-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
 
  (start_dialog)
  (unload_dialog dcl_id)

  (if click
    (get_details)
  )

); end defun

;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;             End Of Main Routine             
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; X =          S u b  R o u t i n e s           = X
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

;;-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

(defun get_all_lists()
  (setq booklist (open "C:/Chi-CustomCAD/Symbman/Booklist.cat" "r"))
(while (setq temp (read-line booklist))
  (setq blist (cons temp blist)))
        (close booklist)

  (setq avdetails (open "C:/Chi-CustomCAD/Symbman/AVdetails.cat" "r"))
(while (setq temp0 (read-line avdetails))
(setq avlist (cons temp0 avlist)))
        (close avdetails)

  (setq tcdetails (open "C:/Chi-CustomCAD/Symbman/TCdetails.cat" "r"))
(while (setq temp1 (read-line tcdetails))
(setq tclist (cons temp1 tclist)))
        (close tcdetails)
   
  (setq scdetails (open "C:/Chi-CustomCAD/Symbman/SCdetails.cat" "r"))
(while (setq temp2 (read-line scdetails))
(setq sclist (cons temp2 sclist)))
        (close scdetails)

  (setq acdetails (open "C:/Chi-CustomCAD/Symbman/ACdetails.cat" "r"))
(while (setq temp3 (read-line acdetails))
(setq aclist (cons temp3 aclist)))
        (close acdetails)

  (setq tedetails (open "C:/Chi-CustomCAD/Symbman/TEdetails.cat" "r"))
(while (setq temp4 (read-line tedetails))
(setq telist (cons temp4 telist)))
        (close tedetails)

  (setq phdetails (open "C:/Chi-CustomCAD/Symbman/PHdetails.cat" "r"))
(while (setq temp5 (read-line phdetails))
(setq phlist (cons temp5 phlist)))
        (close phdetails)

  (setq titleblocks (open "C:/Chi-CustomCAD/Symbman/Titleblocks.cat" "r"))
(while (setq temp6 (read-line titleblocks))
(setq tblist (cons temp6 tblist)))
        (close titleblocks)

  (setq miscdetails (open "C:/Chi-CustomCAD/Symbman/MISCdetails.cat" "r"))
(while (setq temp7 (read-line miscdetails))
(setq misclist (cons temp7 misclist)))
        (close miscdetails)
)

(defun chk_books()
;; book = 0 = AV Details
;; book = 1 = TC Details
;; book = 2 = SC Details
;; book = 3 = AC Details
;; book = 4 = TE Details
;; book = 5 = PEOPLE Details
;; book = 6 = TITLEBLOCKS Details
;; book = 7 = MISC Details
  (start_list "dlist" 3)
  (cond
  ((= books "0") (mapcar 'add_list avlist))
  ((= books "1") (mapcar 'add_list tclist))
  ((= books "2") (mapcar 'add_list sclist))
  ((= books "3") (mapcar 'add_list aclist))
  ((= books "4") (mapcar 'add_list telist))
  ((= books "5") (mapcar 'add_list phlist))
  ((= books "6") (mapcar 'add_list tblist))
  ((= books "7") (mapcar 'add_list misclist))
  )
  (end_list)
  )

(defun set_paths()
  (cond
    ((= books "0") (setq path "C:/Chi-CustomCAD/Symbman/AV/"))
    ((= books "1") (setq path "C:/Chi-CustomCAD/Symbman/TC/"))
    ((= books "2") (setq path "C:/Chi-CustomCAD/Symbman/SC/"))
    ((= books "3") (setq path "C:/Chi-CustomCAD/Symbman/AC/"))
    ((= books "4") (setq path "C:/Chi-CustomCAD/Symbman/TE/"))
    ((= books "5") (setq path "C:/Chi-CustomCAD/Symbman/PEOPLE/"))
    ((= books "6") (setq path "C:/Chi-CustomCAD/Symbman/TB/"))
    ((= books "7") (setq path "C:/Chi-CustomCAD/Symbman/MISC/"))
    )
  )
 
(defun get_blknm()
  (cond
    ((= books "0") (setq tempStr (nth (atoi block) avlist)))
    ((= books "1") (setq tempStr (nth (atoi block) tclist)))
    ((= books "2") (setq tempStr (nth (atoi block) sclist)))
    ((= books "3") (setq tempStr (nth (atoi block) aclist)))
    ((= books "4") (setq tempStr (nth (atoi block) telist)))
    ((= books "5") (setq tempStr (nth (atoi block) phlist)))
    ((= books "6") (setq tempStr (nth (atoi block) tblist)))
    ((= books "7") (setq tempStr (nth (atoi block) misclist)))
    )
    (setq Pos (vl-string-search ":" tempStr))
    (setq BlkName (substr tempStr 1 Pos))
  )

(defun get_details()
  (setq Pos (vl-string-search ":" tempStr))
  (setq BlkName (substr tempStr 1 Pos))
  (setq usrlyr (getvar "clayer"))
  (setq usrosmode (getvar "osmode"))
  (setq dtllyr (setvar "clayer" "0"))
  (setvar "clayer" dtllyr)
  (command ".-insert" (strcat path BlkName) pause "1.0" "1.0" "")
  )

(defun set_var_nil()
  (setq blist nil)
  (setq booklist nil) 
  (setq avlist nil)
  (setq tclist nil)
  (setq sclist nil)
  (setq aclist nil)
  (setq telist nil)
  (setq phlist nil)
  (setq tblist nil)
  (setq misclist nil)
  (setq avdetails nil)
  (setq tcdetails nil)
  (setq scdetails nil)
  (setq acdetails nil)
  (setq tedetails nil)
  (setq phdetails nil)
  (setq titleblocks nil)
  (setq miscdetails nil) 
  (setq books nil)
  (setq details nil)
  (setq blocks nil)
  (setq usrlyr nil)
  (setq usrosmode nil)
  (setq dtllyr nil)
  (setq BlkName nil)
  (setq path nil)
  (setq tempStr nil)
  (setq Pos nil)
  )

(defun insert_block()
  (set_paths)
  (get_blknm)
  (setq click T)
  (done_dialog 1)
  )
     

;;======================================================
;;           Dialog Box - Slide Change                 
;;======================================================
;;  any time a change in "dlist"
;;(defun set_slide (/ x y slide)
;;  (start_image "detail") ; start the image
;;  (setq x (dimx_tile "detail"))
;;  (setq y (dimy_tile "detail"))

;;  (start_image "detail")
;;  (fill_image 0 0 x y 0) ; 0 = black backgroun -15 = gray)
;;  (slide_image 0 -30 x y slide)
;;  (end_image) ; end image
;;) ; defun set_slide

;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; X =          E n d   O f   F i l e            = X
;; X =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= X
;; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


now to get the slides to work....and I am done....i hope.....

Thanks for the input guys. I probably would have never figured that out....
Title: Re: .cat files? How do they work in LISP??
Post by: jbuzbee on June 01, 2007, 03:07:13 PM
. . . you could have learned OpenDCl by now - really.  It's that easy.
Title: Re: .cat files? How do they work in LISP??
Post by: T.Willey on June 01, 2007, 03:18:06 PM
Happy to help.

. . . you could have learned OpenDCl by now - really.  It's that easy.
Then he would be learning two languages at once James.  Lisp and OpenDCL.
Title: Re: .cat files? How do they work in LISP??
Post by: LE on June 01, 2007, 03:22:28 PM
Happy to help.

. . . you could have learned OpenDCl by now - really.  It's that easy.
Then he would be learning two languages at once James.  Lisp and OpenDCL.

Or... get instead into C#, and not think in 3 or 5 years from now, "Why I did not start with that language?... OK, keep using this easy one..."   :evil:
Title: Re: .cat files? How do they work in LISP??
Post by: jbuzbee on June 01, 2007, 03:24:46 PM
Sure Luis, that's what they told us about VBA back when 2000i came out remember?  Oh where oh where is VBA now . . ..
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on June 01, 2007, 03:44:05 PM
i have been playing with openDCL...but isnt it just a DCL creating program...kinda like using front page to do creat websites...its like draging and dropping items to create a UI...the behinds of that is still LSP is it not?
Title: Re: .cat files? How do they work in LISP??
Post by: T.Willey on June 01, 2007, 03:47:27 PM
i have been playing with openDCL...but isnt it just a DCL creating program...kinda like using front page to do creat websites...its like draging and dropping items to create a UI...the behinds of that is still LSP is it not?
That is my understand of it.  But, and it's a big but, you can use more tools than just what regular dcl offers.  It is quite a big improvement to regular dcl.
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on June 01, 2007, 03:56:54 PM
oh ya i agree from what I have seen of it its WAY easier to build a UI with it. but I know the code is somewhat differant then LSP and you cant use the vlisp program to open an opendcl file
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on June 01, 2007, 04:01:49 PM
ok here's a question....currently I have buttons setup to run some programs....the buttons are written in to a mns file...is there away in lsp to load that mns so the buttons load when the programs load so i dont have too go through 2 steps? i am sure there is but my brain is fried from working on this program...
Title: Re: .cat files? How do they work in LISP??
Post by: jbuzbee on June 01, 2007, 04:03:57 PM
Consider the following, which is the OnInitialize event - fired when a dialog is opened:
Code: [Select]

(defun c:jb06_00_OnInitialize ( / path)
  (Odcl_Tree_AddParent
    jb06_00_TreeControl1
    (list (list "3/8\"" "00")
 (list "1/2\"" "01")
 (list "3/4\"" "02")
 (list "1\"" "03")
 (list "1 1/2\"" "04")
          (list "3\"" "05")))
  ;load 00 details
  (jb:loaddetails "00")
  (jb:loaddetails "01")
  (jb:loaddetails "02")
  (jb:loaddetails "03")
  (jb:loaddetails "04")
  (jb:loaddetails "05")
)
I'm using the arx function "Odcl_Tree_AddParent" to poulate the tree view im my detail manager form.  Here's the lisp jb:loaddetails:
Code: [Select]

(defun jb:loaddetails(num / file00 path)
  (setq path(strcat(vl-filename-directory(findfile "KB.dws"))"\\Details"))
  (if (findfile(strcat path "\\" num ".dwg"))
  (setq file00(jb:ReturnDBXBlocks(findfile(strcat path "\\" num ".dwg")))))
  (if file00
    (foreach i file00
    (if (=(substr i 1 2)"D_")
      (Odcl_Tree_AddChild  jb06_00_TreeControl1
num
i)))))
Now the files are loaded in the tree view and sorted by scale - that's it - that's all the code required!  Now take a look at what happens when the tree view selection changes:
Code: [Select]

(defun c:jb06_00_TreeControl1_OnSelChanged (sSelText SelKey / path)
  (setq path(strcat(vl-filename-directory(findfile "KB.dws"))"\\Details"))
  (Odcl_BlockView_PreLoadDwg jb06_00_BlockView1
(strcat path "\\" SelKey ".dwg"))
  (Odcl_Control_SetCaption jb06_00_path (strcat path "\\" SelKey ".dwg"))
)
This pre-load the bitmaps for all the blocks in the selected drawing using the arx defined function: Odcl_BlockView_PreLoadDwg.

Now when a detail is selected this happens:
Code: [Select]

(defun c:jb06_00_TreeControl1_OnClicked  (/ sSelText SelKey file path)
  (setq path(strcat(vl-filename-directory(findfile "KB.dws"))"\\Details")
        sSelText (Odcl_Tree_GetItemText
                   jb06_00_TreeControl1
                   (Odcl_Tree_GetSelectedItem jb06_00_TreeControl1))
        SelKey   (Odcl_Tree_GetParent
                   jb06_00_TreeControl1
                   (Odcl_Tree_GetSelectedItem jb06_00_TreeControl1)))
  ;if the right drawing isn't pre-loaded, load it
  (if SelKey
  (if (/= (strcat path "\\" SelKey ".dwg")
          (Odcl_Control_GetCaption jb06_00_path))
    (progn
      (setq file (strcat path "\\" SelKey ".dwg"))
      (Odcl_Control_SetCaption jb06_00_path file)
      (Odcl_BlockView_PreLoadDwg jb06_00_BlockView1 file))))
  ;display block
  (Odcl_BlockView_DisplayBlock jb06_00_BlockView1 sSelText 1 1.25))
The above bit of code displays the blocks preview where the user can zoom and pan to see the block.  No slides required and as has been mentioned if you revise the block the image is automatically updated.  

That's it for this project: a few lines of code!!!

To import a block is a bit more complicated - but really not much.
Code: [Select]
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on June 01, 2007, 05:09:58 PM
can you do the dwgpreview in dcl and lsp? or is that a function only in opendcl?
Title: Re: .cat files? How do they work in LISP??
Post by: T.Willey on June 01, 2007, 05:14:13 PM
OpenDcl is written in ObjectArx, which C++ based (correct me if wrong).  So since C++ is such a powerful language, it has a lot more code options open to it.  So the answer is not really.
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on June 01, 2007, 05:22:35 PM
ok thats fine...i guess untill i learn opendcl....

ok so here is another question...I have the all the slides working fine except I want the slide to view larger...right now the aspect ratio is set to 1 and if i enlarge that too say 2 jsut the box gets bigger...how do I get the actual slide to view larger in the box given. there is alot of extra black room in the box.

here is the code and a pic:

Code: [Select]
(defun set_slide (/ x y slide)
  (start_image "detailimage") ; start the image
  (setq x (dimx_tile "detailimage"))
  (setq y (dimy_tile "detailimage"))

(set_paths)
(get_blknm)

  (setq slide (strcat path blkname))
 
  (start_image "detailimage")
  (fill_image 0 0 x y 0)
  (slide_image 0 -40 x y slide)
  (end_image)
)

(http://img263.imageshack.us/img263/4910/gasej9.png)

Title: Re: .cat files? How do they work in LISP??
Post by: T.Willey on June 01, 2007, 05:28:39 PM
I don't see any pic.  I will have to default this one to Alan, as I have never done a dialog with slides.
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on June 01, 2007, 05:39:32 PM
sorry you probably posted as I as fixing it... :-P
Title: Re: .cat files? How do they work in LISP??
Post by: AVCAD on June 01, 2007, 05:59:22 PM
ok now that this is done...other then the viewable size of the slide...which personnally i am not that worried about...cause all details are printed and in a binder anyways...

let me explain why i wanted to do it with cat files.

This will probably get distributed through out my company and slapped on a network which has offices around the world and we will all be talking to 1 server where these blocks and programs will reside. I didnt want to give everyone the option of adding in blocks of their own cause these are for company standard blocks not do what you will when you will and how you want blocks. SO using the cat files and the way the programs looks at the cat files, all i have too do to update the library is get the new block, a slide of it and update the .cat file and place them on the server and it will update to everyone the next time they load the program.

I am sure you guys being the pro's at this stuff would do it differantly but i am not a pro....lol...and i didn't really know what I was doing.

I thank all of you who helped me figure this out. It was yet again a great learning experience and I actually feel like I had a hand actually completing it this time :-) I am learning still.

Thanks again for all your help.
Title: Re: .cat files? How do they work in LISP??
Post by: T.Willey on June 01, 2007, 06:37:42 PM
You might want to test out the network idea with some local people first.

I'm glad you got it working the way you want it to.  You did most of the work on this one, we just pointed out somethings, and helped you through when needed.
Title: Re: .cat files? How do they work in LISP??
Post by: LE on June 02, 2007, 11:17:28 AM
Forgot one little routine.  I copied them all into one file.  This works for me . . ..

I tested your routine, and I know that the opendcl still is in beta phase, can you please verify if it is returning an aborting error on your acad?

1. did the test under acad 2007
2. loaded the opendcl.17.arx
3. loaded the jbDM.LSP
4. call the command line and select the item 3" on the tree control, then select any of the items from that node (a block) and without closing the routine, close autocad
5. it will return an aborting error:
Quote
FATAL ERROR:  Unhandled Access Violation Reading 0x000f Exception at 896be18h

06/02/2007 at 08:15:57.343  Drawing:
-------------

HTH
Title: Re: .cat files? How do they work in LISP??
Post by: jbuzbee on June 02, 2007, 11:39:06 AM
Luis, interesting.  The form works fine on ADT 2006 but I get a fatal error as you described on AutoCAD Architecture 2008 (don't have 2007 installed).  I'll post a bug report over at sourceforge.  Thanks for the heads up!