Author Topic: Modify List of Drawings  (Read 5263 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 2081
Modify List of Drawings
« on: March 13, 2007, 04:09:39 PM »
I am looking to remove a drawing from a list of drawings within a folder.

(defun getdwglist  (folderlist)
    (apply 'append
           (mapcar '(lambda (f)
                      (mapcar '(lambda (name) (strcat f "\\" name))
                              (vl-directory-files f "*.dwg" 1)))
                   folderlist)));Alan Butler fix

I need to eliminate the drawing 2436TB.dwg from the list when using the function getdwglist above.

I can post more of the routine if needed.

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

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Modify List of Drawings
« Reply #1 on: March 13, 2007, 04:26:55 PM »
I have not understood a problem...
It is necessary for you
Code: [Select]
(vl-remove 2436TB.dwg (vl-directory-files f "*.dwg" 1))I have truly understood?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Modify List of Drawings
« Reply #2 on: March 13, 2007, 04:35:00 PM »
Yes Evgeniy, I think thats what he wants ..

(getdwglist01 (list "c:" "d:" "F:") "Drawing1.dwg")
Code: [Select]
(DEFUN getdwglist01 (sfolderlst sexclude)
  (APPLY 'APPEND
         (MAPCAR '(LAMBDA (f)
                    (MAPCAR '(LAMBDA (name) (STRCAT f "\\" name))
                            (VL-REMOVE sexclude (VL-DIRECTORY-FILES f "*.dwg" 1))
                    )
                  )
                 sfolderlst
         )
  )
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Modify List of Drawings
« Reply #3 on: March 13, 2007, 04:46:25 PM »
Thanks guys, I don't know enough to ask the question correctly

The function gets a list of drawings, for example:
"F:\\Jobs\\2006\\060512\\ACAD\\A4-02.dwg"
"F:\\Jobs\\2006\\060512\\ACAD\\A4-03.dwg"
"F:\\Jobs\\2006\\060512\\ACAD\\A4-04.dwg"
"F:\\Jobs\\2006\\060512\\ACAD\\A4-05.dwg"
"F:\\Jobs\\2006\\060512\\ACAD\\A4-06.dwg"
"F:\\Jobs\\2006\\060512\\ACAD\\A4-07.dwg"
"F:\\Jobs\\2006\\060512\\ACAD\\A5-01.dwg"
"F:\\Jobs\\2006\\060512\\ACAD\\A5-02.dwg"
"F:\\Jobs\\2006\\060512\\ACAD\\A5-03.dwg"
"F:\\Jobs\\2006\\060512\\ACAD\\A5-04.dwg"
"F:\\Jobs\\2006\\060512\\ACAD\\A5-05.dwg"
"F:\\Jobs\\2006\\060512\\ACAD\\A5-06.dwg"
"F:\\Jobs\\2006\\060512\\ACAD\\A6-01.dwg"
"F:\\Jobs\\2006\\060512\\ACAD\\A6-02.dwg"
"F:\\Jobs\\2006\\060512\\ACAD\\A6-03.dwg"
"F:\\Jobs\\2006\\060512\\ACAD\\A6-04.dwg"
"F:\\Jobs\\2006\\060512\\ACAD\\A6-05.dwg"
"F:\\Jobs\\2006\\060512\\ACAD\\A6-06.dwg"
"F:\\Jobs\\2006\\060512\\ACAD\\A7-01.dwg"
"F:\\Jobs\\2006\\060512\\ACAD\\A7-02.dwg"

I want to always remove a drawing "2436TB.dwg" for the folder list of drawings.

Here is more of the code:
Code: [Select]
;;;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 ''Sheet Files''\n\t\t  Creates index of all drawings in folder.\n\t\t  By: Jeff Mishler and Alan 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 ;Alan 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)) 17)
      ;;(vla-GetInterfaceObject *acad "ObjectDBX.AxDbDocument.16")
      ;;(vla-GetInterfaceObject *acad "ObjectDBX.AxDbDocument.17")))
      (setq odbx (cond ((< (atoi (substr (getvar "acadver") 1 2)) 16)
                        (vla-GetInterfaceObject *acad "ObjectDBX.AxDbDocument"))
                       ((= (atoi (substr (getvar "acadver") 1 2)) 16)
                        (vla-GetInterfaceObject *acad "ObjectDBX.AxDbDocument.16"))
                       ((> (atoi (substr (getvar "acadver") 1 2)) 16)
                        (vla-GetInterfaceObject *acad "ObjectDBX.AxDbDocument.17"))))
      (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))))
  (setq dwg-list masterlist)
  (reverse masterlist))

Thanks
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: Modify List of Drawings
« Reply #4 on: March 13, 2007, 05:03:46 PM »
Here is the whole code.

I would like it to not list the titleblock drawing "2436TB.dwg" (remove it from the list of drawings within the selected folder)

I have tried, but my coding is limited.
Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Modify List of Drawings
« Reply #5 on: March 13, 2007, 05:46:16 PM »
Would this work for you Gary?

Code: [Select]
(defun getdir (message / sh folder result)
  (setq sh (vla-getInterfaceObject
     (vlax-get-acad-object)
     "Shell.Application"
   )
  )
  (setq folder
(vlax-invoke-method
   sh 'BrowseForFolder 0 message 0)
  )
  (vlax-release-object sh)
  (if folder
    (progn
      (setq result
     (vlax-get-property
       (vlax-get-property folder 'Self)
       'Path
     )
      )
      (if (/= (substr result (strlen result)) "\\")
(setq result (strcat result "\\"))
result
      )
    )
  )
)

(setq files (vl-remove "2436TB.dwg"
       (vl-directory-files
(setq dir (getdir "Select folder:"))
"*.dwg"
       )
    )
      files (mapcar '(lambda (x)
       (strcat dir x)
     )
    files
    )
)
« Last Edit: March 13, 2007, 06:21:59 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

GDF

  • Water Moccasin
  • Posts: 2081
Re: Modify List of Drawings
« Reply #6 on: March 13, 2007, 07:04:21 PM »
Ron

Thanks, I think I can make that work into my routine. Will look into tonight. Thanks.

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

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Modify List of Drawings
« Reply #7 on: March 13, 2007, 07:07:52 PM »
.. So you dont want to pass in a folder list as per your sample, only a folder string ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Modify List of Drawings
« Reply #8 on: March 14, 2007, 09:19:52 AM »
.. So you dont want to pass in a folder list as per your sample, only a folder string ?

Here is what the routine does, it reads attributed blocks found in the titleblock and sheet files
located within a project folder. It makes a text file readout of those drawings:

----------------------------------------------------------------------
        Sheet File Directory is: [F:\Jobs\2006\060512\ACAD]
        March 13, 2007 3:57 p.m.   Total Number of Sheets: 119
----------------------------------------------------------------------
              [ ]                                          <---error here...this is the titleblock drawing located within the folder
12 March 2007 [ ]  A0.00     Cover Sheet                   
12 March 2007 [ ]  A0.01     Site Plan                     
12 March 2007 [ ]  A0.01a    Address Plan                 
12 March 2007 [ ]  A1.01     Project Data                 
12 March 2007 [ ]  A1.02a    Fire Proofing Data           
12 March 2007 [ ]  A1.02b    Fire Proofing Data           
12 March 2007 [ ]  A1.02c    Fire Proofing Data           
12 March 2007 [ ]  A1.02d    Fire Proofing Data           
12 March 2007 [ ]  A1.03     Fair Housing Data             
12 March 2007 [ ]  A1.04     TAS Handicap Data             
12 March 2007 [ ]  A1.05     TAS Handicap Data             
12 March 2007 [ ]  A2.00a    Overall Foundation and 1st   
12 March 2007 [ ]  A2.00b    Overall 2nd and 3rd           
12 March 2007 [ ]  A2.00c    Overall Roof Plan             
12 March 2007 [ ]  A2.01a    Foundation Plan Bldg I       
12 March 2007 [ ]  A2.01b    1st Floor Plan Bldg I         
and so on....


Here is the output that I am trying to modify:

("F:\\Jobs\\2006\\060101\\ACAD\\2436TB.dwg"   <---need to delete this drawing
"F:\\Jobs\\2006\\060101\\ACAD\\A0-00.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A0-01.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A1-01.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A1-01a.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A1-02a.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A1-02b.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A1-02c.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A1-03.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A1-04.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A1-05.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A2-00a.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A2-00b.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A2-00c.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A2-00d.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A2-00e.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A2-01a.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A2-01b.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A2-01c.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A2-01d.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A2-01e.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A2-02a.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A2-02b.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A2-02c.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A3-00.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A3-01.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A3-02.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A3-03a.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A3-03b.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A3-04.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A3-05.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A3-06a.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A3-06b.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A3-07.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A4-01a.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A4-01b.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A4-02.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A5-01.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A5-02.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A5-03.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A5-04.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A5-05.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A6-01.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A6-02.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A6-03.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A6-04.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A7-01.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A7-02.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A7-03.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A7-04.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A7-05.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A7-06.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A7-07.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A7-08.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A7-09.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A8-00.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A8-01a.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A8-01b.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A8-01c.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A8-01d.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A8-01e.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A8-02a.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A8-02b.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A8-02c.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A8-03.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A8-04.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A8-05.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A8-06.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A8-07.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A9-01.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\A9-02.dwg"
"F:\\Jobs\\2006\\060101\\ACAD\\seal.dwg")


Thanks, guys for your help on this.

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: Modify List of Drawings
« Reply #9 on: March 14, 2007, 09:26:39 AM »
Would this work for you Gary?

Code: [Select]
(defun getdir (message / sh folder result)
  (setq sh (vla-getInterfaceObject
     (vlax-get-acad-object)
     "Shell.Application"
   )
  )
  (setq folder
(vlax-invoke-method
   sh 'BrowseForFolder 0 message 0)
  )
  (vlax-release-object sh)
  (if folder
    (progn
      (setq result
     (vlax-get-property
       (vlax-get-property folder 'Self)
       'Path
     )
      )
      (if (/= (substr result (strlen result)) "\\")
(setq result (strcat result "\\"))
result
      )
    )
  )
)

(setq files (vl-remove "2436TB.dwg"
       (vl-directory-files
(setq dir (getdir "Select folder:"))
"*.dwg"
       )
    )
      files (mapcar '(lambda (x)
       (strcat dir x)
     )
    files
    )
)

Ron

Perfect, thanks....that works for me. Maybe I'll learn something to.

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

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Modify List of Drawings
« Reply #10 on: March 14, 2007, 10:03:41 AM »
Glad it worked for you.

What do you use those lists for? You can output similar information into a sheet index using fields and sheet set manager too.

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Modify List of Drawings
« Reply #11 on: March 14, 2007, 11:15:54 AM »
Gary,

  Just an idea, but if all you want are the sheet files, and you only have architectural sheets and are named as suck, then you can just change the line that grabs all the drawings.  You are grabbing any file that ends with .dwg.  It seems all you sheets begin with 'A', so I would add that to the file for file, and then you would haven't to worry about grabbing the title block, or the stamp drawing.

With code (my idea)
Code: [Select]
(setq files
 (vl-directory-files
  (setq dir (getdir "Select folder:"))
  "A*.dwg"
  1
  )
)
/idea
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: Modify List of Drawings
« Reply #12 on: March 14, 2007, 11:44:25 AM »
Gary,

  Just an idea, but if all you want are the sheet files, and you only have architectural sheets and are named as suck, then you can just change the line that grabs all the drawings.  You are grabbing any file that ends with .dwg.  It seems all you sheets begin with 'A', so I would add that to the file for file, and then you would haven't to worry about grabbing the title block, or the stamp drawing.

With code (my idea)
Code: [Select]
(setq files
 (vl-directory-files
  (setq dir (getdir "Select folder:"))
  "A*.dwg"
  1
  )
)
/idea


Tim and Ron

Thanks for the help.

Tim

I was looking for the hardest solution, not some simple fix...HEE hee
Man I feel STUPID, I should have thought of that. Sometimes you just
have think outside of the [BOX], my trouble is I can't think either way.

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: Modify List of Drawings
« Reply #13 on: March 14, 2007, 11:48:10 AM »
Tim and Ron

Thanks for the help.

Tim

I was looking for the hardest solution, not some simple fix...HEE hee
Man I feel STUPID, I should have thought of that. Sometimes you just
have think outside of the [BOX], my trouble is I can't think either way.

Gary
You're welcome.  I'm here to do the simple answers.  :-)
I'll be here all week for this purpose.
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: Modify List of Drawings
« Reply #14 on: March 14, 2007, 11:59:22 AM »
I have not understood a problem...
It is necessary for you
Code: [Select]
(vl-remove 2436TB.dwg (vl-directory-files f "*.dwg" 1))I have truly understood?

Evgeniy

Thanks, I see now this would have worked for me also. I just didn't understand your simple
solution also. I know just enough lisp to get into trouble. Thanks.

Gary



Tim

Glad to know you'll be around to help me, I'll try to come up with some more questions....

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