|
| 1 | +; random sample file |
| 2 | + |
| 3 | +(defun sampleFunc (x y / a b c d) |
| 4 | + (setq a (list 1 2 3 4) ; does this screw it all up? |
| 5 | + d (setq b 0) |
| 6 | + b (mapcar '+ a)) |
| 7 | + (foreach x a |
| 8 | + (setq d (1+ d)) |
| 9 | + ) |
| 10 | + |
| 11 | + (defun SymPtrOnly () |
| 12 | + (setq gv 32) |
| 13 | + ) |
| 14 | + |
| 15 | + (defun c (a b / q) |
| 16 | + (defun q (r j / z) |
| 17 | + (setq z (* r j)) |
| 18 | + ) |
| 19 | + |
| 20 | + (q a b) |
| 21 | + ) |
| 22 | +) |
| 23 | + |
| 24 | + |
| 25 | +(setq some "random" ; does this trip? |
| 26 | + global (list "variables" "to" "test") |
| 27 | + with (vl-sort '(lambda(a b) (setq c (< a b))) global) |
| 28 | +) |
| 29 | + |
| 30 | +(foreach rando global |
| 31 | + (setq some (strcat some " " rando)) |
| 32 | +) |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | +(defun DumpPidMarkups (/ path pdfList pdfMarkups lineList compList equpList chckList textList resp contractDrawings downloadPdfs downloadPath badFiles noMarkups) |
| 37 | + |
| 38 | + (defun collectMarkups ( file / pchckList pcompList pequpList plineList ptextList markups fixAnno ret ) |
| 39 | + (setq ret nil) |
| 40 | + (if (not (vl-catch-all-error-p (setq markups (vl-catch-all-apply 'NS:XfiniumPDF:GetAnnotations (list file 1))))) ; Hard code page 1 |
| 41 | + (if (> (length markups) 0) |
| 42 | + (progn |
| 43 | + (setq markups (vl-remove-if '(lambda (a) (or (/= (type a) 'LIST) (/= (strcase (nth 3 a)) "FREETEXT") (null (nth 5 a)) (= (nth 5 a) ""))) markups)) |
| 44 | + (setq markups (mapcar '(lambda (a) (list (vl-filename-base file) (nth 4 a) (nth 5 a) (nth 6 a))) markups)) |
| 45 | + (if (> (length markups) 0) |
| 46 | + (progn |
| 47 | + (foreach anno markups |
| 48 | + (setq fixAnno (mapcar '(lambda (l) (if (= (type l) 'STR) (acet-str-replace "\r" "-" (vl-string-trim " " (vl-string-trim (chr 9) l))) l)) anno)) |
| 49 | + (cond |
| 50 | + ((vl-string-search "LINENUMBER" (strcase (nth 1 fixAnno))) |
| 51 | + (setq plineList (cons fixAnno plineList))) |
| 52 | + ((vl-string-search "COMPONENT" (strcase (nth 1 fixAnno))) |
| 53 | + (setq pcompList (cons fixAnno pcompList))) |
| 54 | + ((vl-string-search "EQUIPMENT" (strcase (nth 1 fixAnno))) |
| 55 | + (setq pequpList (cons fixAnno pequpList))) |
| 56 | + ((and (null (vl-string-search "NOT IN SCOPE" (nth 2 fixAnno)))(>= (- (strlen (nth 2 fixAnno)) (strlen (acet-str-replace "-" "" (nth 2 fixAnno)))) 3)) |
| 57 | + (setq pchckList (cons fixAnno pchckList))) |
| 58 | + (t |
| 59 | + (setq ptextList (cons fixAnno ptextList))) |
| 60 | + ) |
| 61 | + ) |
| 62 | + (setq ret (list plineList pcompList pequpList pchckList ptextList)) |
| 63 | + ) |
| 64 | + ) |
| 65 | + ) |
| 66 | + ) |
| 67 | + (setq ret (vl-filename-base file)) |
| 68 | + ) |
| 69 | + ret |
| 70 | + ) |
| 71 | + |
| 72 | + (defun getPdfList ( pth / retList ) |
| 73 | + (setq retList (cadr (NS:ACAD:FilePicker "Select P&IDs to export markups" "Select files" GV:ProjPath "*.pdf"))) |
| 74 | + (cond |
| 75 | + ((null retList) (exit)) |
| 76 | + ((and (vl-consp retList) (= (length retList) 1) (= (car retList) "")) |
| 77 | + (setq retList getPdfList)) |
| 78 | + ((and (vl-consp retList) (> (length retList) 1) (vl-every 'findfile retList)) |
| 79 | + (terpri) |
| 80 | + (prompt (strcat (itoa (length retList)) " PDFs selected for processing"))) |
| 81 | + ) |
| 82 | + retList |
| 83 | + ) |
| 84 | + |
| 85 | + |
| 86 | + (if (null GV:ProjIni) (progn (NS:ACAD:MessageBox *GV:ProjIni* "Project.ini error" 0 16)(exit))) |
| 87 | + |
| 88 | + (setq resp (car (NS:ACAD:MessageBox "Do you want to download drawings?" "P&ID Download and Export" 3 32))) |
| 89 | + (cond |
| 90 | + ((= resp 2) ; Cancel |
| 91 | + (terpri) |
| 92 | + (prompt "P&ID Markup Export Terminated") |
| 93 | + (exit) |
| 94 | + ) |
| 95 | + ((= resp 6) ; Yes |
| 96 | + (setq contractDrawings (vl-catch-all-apply 'NS:Sharepoint:Read (list t GV:ExePath GV:ProjUrl "Contract Drawings" "ID" "Name"))) |
| 97 | + (if (vl-catch-all-error-p contractDrawings) (progn (alert "Error reading from Sharepoint") (exit))) |
| 98 | + (setq contractDrawings (vl-remove-if '(lambda (d) (null (vl-string-search ".pdf" (car d)))) (mapcar 'reverse contractDrawings)) |
| 99 | + downloadPdfs (cadr (NS:ACAD:ListBox "Select PDFs to Download" "Download Drawings" (acad_strlsort (mapcar 'car contractDrawings)) t))) |
| 100 | + (if (null downloadPdfs) (exit)) |
| 101 | + (setq downloadPath (caadr (NS:ACAD:DirPicker "Select Download Path" "Download files" GV:ProjPath))) |
| 102 | + (if (null downloadPath) (exit)) |
| 103 | + (foreach pdf downloadPdfs |
| 104 | + (setq downloadIds (cons (cadr (assoc pdf contractDrawings)) downloadIds)) |
| 105 | + ) |
| 106 | + (NS:SharePoint:Download GV:ExePath (cadr(assoc "SITE" GV:ProjIni)) "Contract Drawings" "ID" (mapcar 'itoa downloadIds) downloadPath) |
| 107 | + (setq defaultPath downloadPath) |
| 108 | + ) |
| 109 | + ((= resp 7) ; No |
| 110 | + (setq defaultPath GV:ProjPath)) |
| 111 | + ) |
| 112 | + (setq pdfList (getPdfList defaultPath)) |
| 113 | + (if (and pdfList (> (length pdfList) 0)) |
| 114 | + (foreach pdf pdfList |
| 115 | + (setq pdfMarkups (collectMarkups pdf)) |
| 116 | + (cond |
| 117 | + ((null pdfMarkups) |
| 118 | + (setq noMarkups (cons (vl-filename-base pdf) noMarkups))) |
| 119 | + ((= (type pdfMarkups) 'STR) |
| 120 | + (setq badFiles (cons pdfMarkups badFiles))) |
| 121 | + ((listp pdfMarkups) |
| 122 | + (if (nth 0 pdfMarkups) |
| 123 | + (setq lineList (append (nth 0 pdfMarkups) lineList))) |
| 124 | + (if (nth 1 pdfMarkups) |
| 125 | + (setq compList (append (nth 1 pdfMarkups) compList))) |
| 126 | + (if (nth 2 pdfMarkups) |
| 127 | + (setq equpList (append (nth 2 pdfMarkups) equpList))) |
| 128 | + (if (nth 3 pdfMarkups) |
| 129 | + (setq chckList (append (nth 3 pdfMarkups) chckList))) |
| 130 | + (if (nth 4 pdfMarkups) |
| 131 | + (setq textList (append (nth 4 pdfMarkups) textList)))) |
| 132 | + ) |
| 133 | + ) |
| 134 | + ) |
| 135 | + (if lineList (IO:WriteLines (cons (list "Page" "Subject" "LineTag" "Author") lineList) (strcat (vl-filename-directory (car pdfList)) "\\Linenumber List.csv"))) |
| 136 | + (if compList (IO:WriteLines (cons (list "Page" "Subject" "ComponentTag" "Author") compList) (strcat (vl-filename-directory (car pdfList)) "\\Components List.csv"))) |
| 137 | + (if equpList (IO:WriteLines (cons (list "Page" "Subject" "EquipmentTag" "Author") equpList) (strcat (vl-filename-directory (car pdfList)) "\\Equipment List.csv"))) |
| 138 | + (if chckList (IO:WriteLines (cons (list "Page" "Subject" "Contents" "Author") chckList) (strcat (vl-filename-directory (car pdfList)) "\\Review Required List.csv"))) |
| 139 | + (if textList (IO:WriteLines (cons (list "Page" "Subject" "Contents" "Author") textList) (strcat (vl-filename-directory (car pdfList)) "\\FreeText List.csv"))) |
| 140 | + (if badFiles (NS:ACAD:ListBox "Error reading the following files" "File Errors" (acad_strlsort badFiles) t)) |
| 141 | + (if noMarkups (NS:ACAD:ListBox "There were no markups on the following files" "No markups" (acad_strlsort noMarkups) t)) |
| 142 | + (terpri) |
| 143 | + (prompt "P&ID Markup Export Complete") |
| 144 | + (princ) |
| 145 | + ) |
| 146 | + |
| 147 | + |
| 148 | +(defun doStuff (pth / retList) |
| 149 | + (setq retList (cadr (NS:ACAD:FilePicker "Select P&IDs to export markups" "Select files" GV:ProjPath "*.pdf" ))) |
| 150 | + (cond |
| 151 | + ((null retList) (exit)) |
| 152 | + ((and (vl-consp retList) (= (length retList) 1) (= (car retList) "")) |
| 153 | + (setq retList getPdfList) |
| 154 | + ) |
| 155 | + ((and (vl-consp retList) (> (length retList) 1) (vl-every 'findfile retList)) |
| 156 | + (terpri) |
| 157 | + (prompt (strcat (itoa (length retList)) " PDFs selected for processing")) |
| 158 | + ) |
| 159 | + ) |
| 160 | + retList |
| 161 | +) |
| 162 | + |
0 commit comments