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

0 Members and 1 Guest are viewing this topic.

T.Willey

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

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

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: .cat files? How do they work in LISP??
« Reply #61 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
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 #62 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....

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: .cat files? How do they work in LISP??
« Reply #63 on: June 01, 2007, 03:07:13 PM »
. . . you could have learned OpenDCl by now - really.  It's that easy.
James Buzbee
Windows 8

T.Willey

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

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

Please think about donating if this post helped you.

LE

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

jbuzbee

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

AVCAD

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

T.Willey

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

AVCAD

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

jbuzbee

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

AVCAD

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

T.Willey

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



« Last Edit: June 01, 2007, 05:31:31 PM by AVCAD »