Author Topic: Make Sheet Index using obectDBX  (Read 67977 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Make Sheet Index using obectDBX
« Reply #60 on: February 13, 2006, 10:34:49 AM »
Gary
I changed the way var 'folder' is used so it's not global.
When you call getindex2 it is passed to it so it stays local.

And changed 'getfolder' so it doesn't set a global but returns the needed info.
so this collects it. (setq folder (getfolder))

I put a CAB in most of the lines where I made changes.
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.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make Sheet Index using obectDBX
« Reply #61 on: February 13, 2006, 11:09:14 AM »
Allen

Thanks. Works great. Now I'm really behind in my other work. This routine will say me tons of time.
You sir are da man. This has been a fun project. Thanks again to you, Tim Willey and Jeff Mishler.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Make Sheet Index using obectDBX
« Reply #62 on: February 13, 2006, 11:40:47 AM »
Glad you and Alan got something you are happy with.  I only code on week days, since that is the only place I have CAD and can test if needs be, so sorry I couldn't be any help this weekend.  Looks like you two had fun.
Tim

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

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make Sheet Index using obectDBX
« Reply #63 on: February 13, 2006, 11:57:16 AM »
Tim

You really missed out.

Gary :lmao:
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: Make Sheet Index using obectDBX
« Reply #64 on: February 13, 2006, 08:52:59 PM »
Hmm, me too! But the good news is that I'm 1/2 done moving........can't wait to check out what you guys came up with, but no time now.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make Sheet Index using obectDBX
« Reply #65 on: February 14, 2006, 03:50:30 PM »
Jeff

You know we could not wait for you to get moved in to finish this up. I worked Allen hard on this little project.
I think I've used up all of his free time. Need to get Tim working on the weekend.

I want to thank you all again for spoon feeding me.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Make Sheet Index using obectDBX
« Reply #66 on: February 14, 2006, 04:56:48 PM »
As long as you learn something, then it's all worth it.  And unless you pay me big $$$, then I don't think I will be working weekends.   :lmao:

Hope move goes better than mine did Jeff.
Tim

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

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make Sheet Index using obectDBX
« Reply #67 on: February 15, 2006, 09:11:49 AM »
Here is the latest update, added a dcl interface.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make Sheet Index using obectDBX
« Reply #68 on: February 15, 2006, 11:02:59 AM »
Small correction, along with sample drawings for testing.

Later

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make Sheet Index using obectDBX
« Reply #69 on: February 27, 2006, 10:47:34 AM »
Allen

This is a similar request. I am using your routine to now search of multiple occurancess of the same attributed block.
And, I am stuck on how to do this. I have it searching for the right block which has three values. My problem is that it only lists
one occurrance of the block, and each drawing has up to fifteen.


Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;function to extract 2 attribute values from a specific block in the drawings of a specified folder
;;;by Jeff Mishler Feb. 9, 2006
;;;
;;;new functions and rewrite by Allen Butler
;;;
;;;added BrowseForFolder title and info
;;;added AutoCAD's progress bar while routine runs
;;;
;;;added reconstruct list coding
;;;added open notepad with room finish list
;;;
;;;by Gary Fowler
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;pulled out this function from getindex below
(defun getfolder ()
  (defun BrowseForFolder (/ sh parentfolder folderobject result folder)
    ;;as posted the autodesk discussion customization group by Tony Tanzillo
    (vl-load-com)
    (setq sh
   (vla-getInterfaceObject
     (vlax-get-acad-object)
     "Shell.Application"
   )
    )
    (if (not ARCH#LOGO)(setq ARCH#LOGO " Your Logo"))
    (setq folder
   (vlax-invoke-method
     sh 'BrowseForFolder 0 (strcat ARCH#LOGO " : Select drawing location for ''Room Files''\n\t\t  Creates index of all drawings in folder.\n\t\t  By: Jeff Mishler and Allen Butler") 0)
    ) ;;added BrowseForFolder title and info
    (vlax-release-object sh)

    (if folder
      (progn
(setq parentfolder
       (vlax-get-property folder 'ParentFolder)
)
(setq FolderObject
       (vlax-invoke-method
ParentFolder
'ParseName
(vlax-get-property Folder 'Title)
       )
)
(setq result
       (vlax-get-property FolderObject 'Path)
)
(mapcar 'vlax-release-object
(list folder parentfolder folderobject)
)
result
      )
    )
  )
  (defun getdwglist (folderlist)
    (apply 'append
   (mapcar '(lambda (f)
      (mapcar '(lambda (name)
(strcat f "\\" name)
       )
      (vl-directory-files f "*.dwg" 1)
      )
    )
   folderlist
   )
    )
  )
  (browseforfolder) ; return the folder ;Allen Butler fix
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun getindex  (blkList folder / *acad atts dwgs f layouts masterlist name odbx val1 val2 n)
  (if (and (setq *acad (vlax-get-acad-object))
            folder ;CAB
   (setq dwgs (getdwglist (list folder)))
      )
    (progn
      (setq n 1)
      ;;added progress bar count marker
      (if (member "acetutil.arx" (arx))
        (ACET-UI-PROGRESS-INIT
          "Please Wait while the Program is Running"
          (length dwg)))
      ;;added progress bar start 
      (setq odbx (if (< (atoi (substr (getvar "acadver") 1 2)) 16)
                   (vla-GetInterfaceObject *acad "ObjectDBX.AxDbDocument")
                   (vla-GetInterfaceObject *acad "ObjectDBX.AxDbDocument.16")))
      (foreach
             dwg  dwgs
        ;;(ARCH:WORKING) ;;spinner test not used
        (if (member "acetutil.arx" (arx))
          (ACET-UI-PROGRESS-SAFE n)(ARCH:WORKING))
        ;;added progress bar running
        (setq n (+ n 1))
        ;;added progress bar count marker
        (if
          (and (not (vl-catch-all-error-p
                      (vl-catch-all-apply '(lambda () (vla-open odbx dwg)))))
               ;; see if the block is even in the drawing
               ;;  check for blocks
               (vl-remove
                 nil
                 (mapcar
                   '(lambda (x)
                      (not (vl-catch-all-error-p
                             (vl-catch-all-apply
                               '(lambda () (vla-item (vla-get-blocks odbx) (car x)))))))
                   blklist))) ; and
           (setq masterlist
                  (cons
                    (cons
                      (cons "DWG"
                            (strcat "" (vl-filename-base dwg) "")) ;.dwg
                      (GetBlockAtts odbx blkList))
                    masterlist))))
      (mapcar 'vlax-release-object (list odbx *acad))))
  (reverse masterlist))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;functions by Allen Butler
(defun getattvalues  (blkobj taglist / valuelist tmptag)
  (foreach
         att  (vlax-invoke blkobj 'getattributes)
    (if (vl-position (setq tmptag (vla-get-tagstring att)) taglist)
      (setq valuelist (cons (cons tmptag (vla-get-textstring att)) valuelist))))
  valuelist)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;functions by Allen Butler
(defun getblockatts  (doc inputlist / rtnlist tmplist tmpinputlist attlist)
  (foreach
         lst  inputlist
    (setq tmpinputlist (cons (mapcar 'strcase lst) tmpinputlist)))
  (vlax-for
         lo  (vla-get-layouts doc)
    (setq rtnlist
           (if rtnlist
             (append rtnlist
                     (list (cons "TAB" (strcat "---  " (vla-get-name lo) "  ---"))))
             (list (cons "TAB" (strcat "---  " (vla-get-name lo) "  ---")))))
    (vlax-for
           obj  (vla-get-block lo)
      (if (and (= (vla-get-objectname obj) "AcDbBlockReference")
               (setq tmplist (assoc (vla-get-name obj) tmpinputlist)))
        (if (setq attlist (getattvalues obj (cdr tmplist)))
          (setq rtnlist (append rtnlist attlist))))))
  rtnlist)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;; List of Attributed Blocks Values - change to suite ;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun CRIIT  (/ indexlist blkData file x a b c folder got-list op dcl_id)
  (defun dcl_error ()
    (ARCH:MsgBox
    " DCL Error" 16"
     File could not be Found.
--------------------------------------------------------------------------------------------
     Lisp Routine's DCL File not found. Check and Verify Support Paths."
    )
    (exit)
  )
  (defun about_help ()
    (ARCH:MsgBox
    " Rules of Thumb" 64"
     Program Information
--------------------------------------------------------------------------------------------
     This routine searches for custom attributed blocks change to meet
     your CAD Standards."
    )
  )
  (setq folder (getfolder)) ;CAB
  ;;functions by Allen Butler
  (defun padout  (word len / spaces)
    (repeat (- len (strlen word)) (setq spaces (cons 32 spaces)))
    (strcat word (vl-list->string spaces)))
    ;-------------------------------------------------------------------------------- 
  ;;searchs for these blocks revision "RM-TAG" 
  (setq blkData '(("RM-TAG" "ROOM" "ROOM-NO" "FINISH")))
    ;-------------------------------------------------------------------------------- 
  (setq indexlist (getindex blkdata folder)) ;get attributed blocks from all unit file drawings CAB
    ;--------------------------------------------------------------------------------
  (if (member "acetutil.arx" (arx))
    (ACET-UI-PROGRESS-DONE))
  ;;added progress bar finish
  (setq file (open "C:\\Temp\\RoomIndex.txt" "w"))
    ;--------------------------------------------------------------------------------   
  (foreach
         dwg  indexlist
    ;;write to list_box and notepad
    (if (assoc "DWG" dwg)(setq x (padout (cdr (assoc "DWG" dwg)) 10)))   
    (if (assoc (cadar blkdata) dwg)
      (setq a (padout (cdr (assoc (cadar blkdata) dwg)) 16))
      (setq a (padout "" 16)))

    (if (assoc (caddar blkdata) dwg)
      (setq b (padout (cdr (assoc (caddar blkdata) dwg)) 5))
      (setq b (padout "" 5)))   

    (if (assoc (car (cdddar blkdata)) dwg)
      (setq c (padout (cdr (assoc (car (cdddar blkdata)) dwg)) 10))
      (setq c (padout "" 10)))
    (write-line (strcat x) file)
    (write-line (strcat "            " a b c) file)   
    ;;(setq got-list (append (list (strcat a b c)) got-list))
    (setq got-list (append (list x) (list (strcat "              " a b c)) got-list))
  )
  (close file)
  ;;added dialog box interface
  (defun do_act (key_pr) (setq op key_pr)(done_dialog)(princ))
  (setq ARCH#LOGO " Arch Program©")
  (setq ARCH#YEAR (substr (rtos (getvar "CDATE") 2 16) 1 4))
  ;;(setq dcl_id (load_dialog (strcat "" "ARCH_CreateRoomIndex-CRI.dcl")))
  (setq dcl_id (load_dialog (strcat ARCH#CUSF "BLOC/" "ARCH_CreateRoomIndex-CRI.dcl")))
  (if (not (new_dialog "ARCH_RoomIndex" DCL_ID "" '(-1 -1))) (dcl_error))   
  (set_tile "set-title" (strcat ARCH#LOGO " : CRI                           Create Room Index List"))
  (set_tile "set-copyright" (strcat ARCH#LOGO " " ARCH#YEAR " for AutoCAD®"))
  (start_list "file-list")
  (mapcar 'add_list got-list)
  (end_list)
  (set_tile "dir" (strcat "  Room File Directory is [" folder "]"))
  (action_tile "accept" "(do_act $key)") 
  (action_tile "about" "(about_help)")
  (action_tile "cancel" "(princ \"\\n*** ///////// Program  CANCELLED ///////// ***\")(done_dialog)")
  (start_dialog)
  (cond
    ((= op "accept")(command ".shell" "notepad C:\\Temp\\RoomIndex.txt"))     
  )     
  (unload_dialog dcl_id) 
  (princ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;(prompt "\n* Command name is: \"CRI\" *")
(CRIIT)
(princ)
« Last Edit: February 27, 2006, 11:02:50 AM by Gary Fowler »
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Make Sheet Index using obectDBX
« Reply #70 on: February 27, 2006, 11:10:16 AM »
In the getindex routine you will have to use an ssget to collect all the blocks. Then
iterate through collecting the attributes of each block.

After that you will need to alter the write-line code to accommodate the altered list.
If you have trouble with it send me a test drawing & I'll take a look.
Or someone else may jump in.
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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Make Sheet Index using obectDBX
« Reply #71 on: February 27, 2006, 11:37:49 AM »
FYI...
You can't use ssget with ObjectDBX.  I didn't read the whole code again, I just read Alan's last post.  If you want to list all the block occurances in a drawing opened in ObjectDBX, then you have to cycle through all the layouts, and count them as you find them.
Tim

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

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make Sheet Index using obectDBX
« Reply #72 on: February 27, 2006, 11:47:31 AM »
Thanks

I'm lost on how to do this. I only need to search model space. The unit plan has multiple attributed blocks.
I just need it to get them all per each drawing file. Remember I still don't speak vlisp.

Would I just need to do a foreach search? Here is a typical drawing file.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Make Sheet Index using obectDBX
« Reply #73 on: February 27, 2006, 02:15:09 PM »
OK here it is.
I didn't test the dcl.
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.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make Sheet Index using obectDBX
« Reply #74 on: February 27, 2006, 03:13:01 PM »
Allen

Thank you, that works perfectly. I modified the code slightly. Now how would I make the list of each unit drawing "list line"
to be iin numerical order based upon the room number?

Code: [Select]
  (foreach dwg  indexlist
    (foreach itm dwg
    ;;write to list_box and notepad
      (cond
        ((= "DWG" (car itm))         
         (setq x (padout (cdr itm) 10))         
         ;(write-line (strcat x) file)
         )   
        ((= (nth 1 (car blkdata)) (car itm))
         (setq a (padout (cdr  itm) 16)))
        ((= (nth 2 (car blkdata)) (car itm))
         (setq b (padout (cdr  itm) 5))) 
        ((= (nth 3 (car blkdata)) (car itm))
         (setq c (padout (cdr itm) 10)))
        )
        (if (and a b c)
          (progn           
            (if (not x)(setq x "          "))
            (write-line (strcat x a b c) file)           
            (setq got-list (append (list (strcat x a b c)) got-list))
            (setq a nil b nil c nil x nil)))
  ))
  (close file)
  ;;added dialog box interface
  (defun do_act (key_pr) (setq op key_pr)(done_dialog)(princ))
  (setq ARCH#LOGO " Arch Program©")
  (setq ARCH#YEAR (substr (rtos (getvar "CDATE") 2 16) 1 4))
  ;;(setq dcl_id (load_dialog (strcat "" "ARCH_CreateRoomIndex-CRI.dcl")))
  (setq dcl_id (load_dialog (strcat ARCH#CUSF "BLOC/" "ARCH_CreateRoomIndex-CRI.dcl")))
  (if (not (new_dialog "ARCH_RoomIndex" DCL_ID "" '(-1 -1))) (dcl_error))   
  (set_tile "set-title" (strcat ARCH#LOGO " : CRI                           Create Room Index List"))
  (set_tile "set-copyright" (strcat ARCH#LOGO " " ARCH#YEAR " for AutoCAD®"))
  (start_list "file-list")
  (mapcar 'add_list (reverse got-list))
  (end_list)

Thank you, again.

Gary
« Last Edit: February 27, 2006, 03:32:25 PM by Gary Fowler »
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64