Author Topic: .cat files? How do they work in LISP??  (Read 30083 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: .cat files? How do they work in LISP??
« Reply #15 on: May 25, 2007, 05:16:21 PM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: .cat files? How do they work in LISP??
« Reply #16 on: May 25, 2007, 05:23:39 PM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

AVCAD

  • Guest
Re: .cat files? How do they work in LISP??
« Reply #17 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


T.Willey

  • Needs a day job
  • Posts: 5251
Re: .cat files? How do they work in LISP??
« Reply #18 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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

AVCAD

  • Guest
Re: .cat files? How do they work in LISP??
« Reply #19 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....









T.Willey

  • Needs a day job
  • Posts: 5251
Re: .cat files? How do they work in LISP??
« Reply #20 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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: .cat files? How do they work in LISP??
« Reply #21 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:



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



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 . . ..
James Buzbee
Windows 8

Guest

  • Guest
Re: .cat files? How do they work in LISP??
« Reply #22 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).

GDF

  • Water Moccasin
  • Posts: 2081
Re: .cat files? How do they work in LISP??
« Reply #23 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
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Guest

  • Guest
Re: .cat files? How do they work in LISP??
« Reply #24 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.

Guest

  • Guest
Re: .cat files? How do they work in LISP??
« Reply #25 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??

AVCAD

  • Guest
Re: .cat files? How do they work in LISP??
« Reply #26 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....

Guest

  • Guest
Re: .cat files? How do they work in LISP??
« Reply #27 on: May 30, 2007, 04:12:41 PM »
It's just the greatest thing since the line command.

Think of it as DCL on steroids.

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: .cat files? How do they work in LISP??
« Reply #28 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.
James Buzbee
Windows 8

GDF

  • Water Moccasin
  • Posts: 2081
Re: .cat files? How do they work in LISP??
« Reply #29 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
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64