FOREACH element returned from a list run a LISP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone..
Hope you are all having a good day...
I have tried to come up / merge code to run a LISP on a returned list (Thanks Lee Mac for the Getfiles function) but am not sure how to merge it.
(my head is bursting already)
my code is:
(defun titleblock(aNme / bNme lay ss att e)
(vl-load-com)
(if (or (not aNme) (/= aNma ""))
(progn
(setq bNme "*Drwg title*")
(setq e "")
(setq lay (getvar "ctab"))
(if (and (not (eq "MODEL" (strcase lay)));;If not model and has block bnme inserts
(setq ss (ssget "_X"
(list (cons 0 "INSERT")
(cons 2 bNme)
(cons 66 1)
(cons 410 lay)
)
)
)
)
;;for each attribute in the first block bnme in selection ss
(progn
(foreach att (vlax-invoke
(vlax-ename->vla-object (ssname ss 0))
'GetAttributes
)
(if (apply 'eq (mapcar 'strcase (list aNme (vla-get-TagString att))))
(setq e (vla-get-TextString att))
)
)
)
)
(if (not (eq e ""))
(setq e e)
(setq e "")
)
)
(setq e nil)
)
)
(defun c:pdf ()
(foreach n (LM:getfiles "Select Drawings" "" "dwg")
(setvar "wipeoutframe" 0)
(Command "undo" "m")
(Setq nm (strcat (getvar "dwgprefix") "Issue\\" (titleblock "R10") "_" (titleblock "R11") "-" (titleblock "R1") " " (titleblock "R2") " " (titleblock "R3") " " (titleblock "R4")));<<<PDF Directory
(Command "-plot" "y" "" "DWG TO PDF.PC3" "ISO full bleed A0 (841.00 x 1189.00 MM)" "m" "l" "n" "w" "0,0" "1189,841" "1=1" "c" "y" "Normal-added.ctb" "y" "y" "n" "n" nm "n" "y")
)
)
(defun c:pdfs ()
(setvar "wipeoutframe" 0)
(foreach layout (layoutlist)
(setvar "ctab" layout)
(Setq nm (strcat (getvar "dwgprefix") "Issue\\" (titleblock "R10") "_" (titleblock "R11") "-" (titleblock "R1") " " (titleblock "R2") " " (titleblock "R3") " " (titleblock "R4")));<<<PDF Directory
(Command "-plot" "y" "" "DWG TO PDF.PC3" "ISO full bleed A0 (841.00 x 1189.00 MM)" "m" "l" "n" "w" "0,0" "1189,841" "1=1" "c" "y" "Normal-added.ctb" "y" "y" "n" "n" nm "n" "y")
))and if I include LM:getfiles within my startup, I don't understand why it cannot run c:pdf on the list returned..?
I get an error saying:
Enter a layout name or [?] <Model>: Enter an output device name or [?] <DWFx ePlot (XPS Compatible).pc3>: DWG TO PDF.PC3 Enter paper size or [?] <ISO full bleed A1 (841.00 x 594.00 MM)>: ISO full bleed A0 (841.00 x 1189.00 MM) Enter paper units [Inches/Millimeters] <Millimeters>: m Enter drawing orientation [Portrait/Landscape] <Landscape>: l Plot upside down? [Yes/No] <No>: n Enter plot area [Display/Extents/Limits/View/Window] <Display>: w Enter lower left corner of window <259147.651703,208410.269836>: 0,0 Enter upper right corner of window <259147.651703,208410.269836>: 1189,841 Enter plot scale (Plotted Millimeters=Drawing Units) or [Fit] <Fit>: 1=1 Enter plot offset (x,y) or [Center] <0.00,0.00>: c Plot with plot styles? [Yes/No] <Yes>: y Enter plot style table name or [?] (enter . for none) <>: Normal-added.ctb Plot with lineweights? [Yes/No] <Yes>: y Enter shade plot setting [As displayed/legacy Wireframe/legacy Hidden/Visual styles/Rendered] <As displayed>: y
Enter file name <Drawing2-Model.pdf>: n Save changes to page setup [Yes/No]? <N> n Proceed with plot [Yes/No] <Y>: C:\Program Files\Autodesk\AutoCAD 2017\Issue\_-
Yes or No, please.
; error: Function cancelled
Proceed with plot [Yes/No] <Y>: *Cancel*
which I understand means it is not obtaining variable nm but am very confused as to why?
Also, does anyone know if I can build in BACKGROUNDPLOT as 3 to force the PDFing to run in the background.
Hopefully someone will be able to help?
Thanks
Steve