Need help creating a LISP

Need help creating a LISP

Markeckert
Enthusiast Enthusiast
2,353 Views
45 Replies
Message 1 of 46

Need help creating a LISP

Markeckert
Enthusiast
Enthusiast
I need to write a lisp that will perform the following. I'm somewhat of a newbie to LISPs so any help would be greatly appreciated. Here is what the LISP needs to perform.
  1. Starting from an open DWG file in AutoCAD2024 the LISP should open the rest of the dwg files that are in the same folder.
  2. Apply predefined Plot Offset properties (Which I will add to the code) to each of the dwg files open. It should also save the properties in the dwg files.
  3. Run the AutoCAD publishing process utilizing Adobe Acrobat Pro to create a single pdf containing all the dwg files as pages in the PDF.    Thanks for the help.
0 Likes
2,354 Views
45 Replies
Replies (45)
Message 21 of 46

Moshe-A
Mentor
Mentor

@Markeckert ,

 

So where is the problem?  as i see it's not IDwgFldr

i am also running R2024 without any issue

in the target folder how many sheets you have?

 

Moshe

 

 

0 Likes
Message 22 of 46

Markeckert
Enthusiast
Enthusiast

These are the files that end up in my target folder after running IDwgFldr.

 

Markeckert_0-1766157278089.png

Here is the contents of the pdf file.

Markeckert_1-1766157381428.png

 

0 Likes
Message 23 of 46

Moshe-A
Mentor
Mentor

if you manually plot it, is it ok?

IDwgFldr plot using acad.ctb you need to change it to get the right result.

0 Likes
Message 24 of 46

Markeckert
Enthusiast
Enthusiast

I've attached the PDF created manually from AutoCAD using the setting of DWG To PDF.pc3 and acad.ctb  that are in your IDwgFldr. I also changed the IDwgFldr to use Adobe pdf2.pc3 and ECS Plot style.ctb with a Paper size of Letter (code is below)?  It produced the same output as I sent you before with those two lines at the bottom of the PDF.

       (command ".-plot" "_Yes" "" "Adobe.pc3" "Letter" "_Inches" "_Landscape"
        "_No" "_Window" "_None" plotLL "_None" plotUR "1=1" "0,0" "_Yes" "ecs plot stye.ctb" "_Yes" "" "" "_Yes" "_Yes")
  
0 Likes
Message 25 of 46

Moshe-A
Mentor
Mentor

@Markeckert Hi,

 

i am asking you simple questions and you are trying vary hard to give me pictures instead of answers.

1.  at first the lisp was encounter errors, up to now you did not say even once: YES the lisp is working all that way down OK or NOT?

    (and temporary put aside the fact you are getting blank pdf)

2. i ask you if you do plot manually is it OK?

3. i ask you "in target folder how many sheets you have?" if you have 2-3 dwg than what is the point in using such a lisp at all?

 

Can you do the following test: for me?

add to target folder more sheets up to 8-10. if currently you do not have 8-10, then copy one multiple times with different names,

make sure the insertion base point is at lower left corner run the lisp and say if it runs free of errors and what is the pdf result? (stop sending pictures 🙏)

 

the (command ".-plot") function is an unforgiving in term of wrong syntax arguments, so make sure you are putting the exact string and in place.

for example: you changed to "ECS Plot style.ctb" but in code you put  "ecs plot stye.ctb" , every character has a meaning.

if it runs with errors, than something in the command plot prompts is not exactly the same as running with "DWG to PDF.pc3" and you will have to figure it

by your self by doing trail & error, otherwise revert back to "DWG to PDF.pc3".

 

Moshe

0 Likes
Message 26 of 46

Markeckert
Enthusiast
Enthusiast

Hi Moshe, I'm going to answer your question as best I can. I'm running your latest version without any changes for the Plot style. 

1) IDwgFldr ran to completion without any errors.

2) If I plot it manually it comes out correctly.

3) Running IDwgFldr - The target folder produces one pdf with all of the input dwg files on one page. 

I ran your test with 8 dwg files in the directory and made sure the insertion point was in the lower left corner. It ran without errors and produced one pdf file with 9 images. It included the original page that I opened Autocad with the other 8. 

One other note that I may not have made clear. Each input DWG needs to be on a separate page in the output PDF.

 

0 Likes
Message 27 of 46

bugtrackin
Community Visitor
Community Visitor

Employee time tracking software helps businesses accurately record working hours, monitor productivity, and manage remote or on-site teams more effectively. With features such as automatic time tracking, activity monitoring, detailed reports, and real-time insights, companies can understand how time is spent across projects and tasks. Reliable employee time tracking tools reduce time theft, improve accountability, and simplify payroll and billing processes. This software is especially valuable for remote and hybrid teams, where visibility and transparency are essential. By using modern employee time tracking software, businesses can optimise workforce performance, improve operational efficiency, and make informed, data-driven decisions.

Screenshot 2025-12-22 at 3.40.14 PM.pngScreenshot 2025-12-22 at 3.40.06 PM.pngScreenshot 2025-12-22 at 10.54.34 AM.pngScreenshot 2025-12-22 at 11.21.47 AM.png

0 Likes
Message 28 of 46

Sea-Haven
Mentor
Mentor

@bugtrackin what does that have to do with this post? Why did you not start a new post.

 

0 Likes
Message 29 of 46

Sea-Haven
Mentor
Mentor

I am not sure as not running Acad at moment, but if Aecoreconsole or OBDX supports "Plot" you can make a single pdf of each dwg without opening the dwg, you could just save a in a dwg a simple box with the path & name of the dwg to be plotted as a guide. I use Ghostscript to rejoin the pdf's back into a single pdf via lisp.

 

Will see if OBDX works.

 

One more question you talk about plotting sheets, is that Model space only so how are the 2 plot corners defined ? Are you always having the Model title block fixed in size and location, are there layouts to be plotted ? Can you clarify please.

0 Likes
Message 30 of 46

Moshe-A
Mentor
Mentor

@Markeckert  hi,

 

Ha 🤣 seems i miss this positive reply.

if every thing now works fine then what is preventing you from saying 'Close this as my Solution'?

 

Moshe

 

 

0 Likes
Message 31 of 46

Markeckert
Enthusiast
Enthusiast

Hi Moshe, I'm still having problems.

I'm running your latest version without any changes for the Plot style. Here are the results.

1) I was able to run IDwgFldr ran to completion without any errors.

2) Running IDwgFldr - The target folder produces one pdf with all of the input dwg files on one page. 

I ran your test with 8 dwg files in the directory and made sure the insertion point was in the lower left corner. It ran without errors and produced one pdf file with 9 images. It included the original page that I opened Autocad with the other 8. 

Each input DWG needs to be on a separate page in the output PDF.

 

3) If I plot manually in AutoCAD the PDF comes out correctly with all 8 DWGs as PDF pages 1-8 .

0 Likes
Message 32 of 46

Moshe-A
Mentor
Mentor

@Markeckert ,

 

"Each input DWG needs to be on a separate page in the output PDF"

So the only issue left is that you want each block on separate pdf page?

Some how i recall that you initially asked to print all to one page - am i wrong??

 

Moshe

0 Likes
Message 33 of 46

Moshe-A
Mentor
Mentor

Guess i am wrong, as i said at the beginning only the PUBLIC command can do what you want or move to VBA forum

but you insist on AutoLISP and this is our limitation - sorry 

 

 

 

0 Likes
Message 34 of 46

Markeckert
Enthusiast
Enthusiast

Is there a VBA forum in the AutoCAD community?

0 Likes
Message 35 of 46

Moshe-A
Mentor
Mentor
0 Likes
Message 36 of 46

Markeckert
Enthusiast
Enthusiast

Moshe, I was just looking at some of the other LISP programs. Would you be able to utilize the code in either of these to create the output PDF with separate pages? I've attached them.

0 Likes
Message 37 of 46

Markeckert
Enthusiast
Enthusiast

Sea-Haven, I believe the Model title block is always fixed in size and location. I think we use the same layout for all plots. Let me know if you need any other information. 

0 Likes
Message 38 of 46

Moshe-A
Mentor
Mentor

@Markeckert ת

 

neither of these lisps do what you want 

 

 

0 Likes
Message 39 of 46

Sea-Haven
Mentor
Mentor

It looks like need to use PUBLISH you can write the DSD file that is used to plot multiple dwg's. There is code for that here. Not sure if I can help. Have in my to do list, if have time will try to do something.

 

Give this a try makes a dsd file so can use Publish.

 

NOTE you must have your Model plot configuration pre-set for it to work. That can be done if needed but an extra step using OBDX..

 

; make dsd file by AlanH Dec 2025

(defun c:makedsd (/ file layouts_to_plot NumTabs OldFda )
 
(setq files (vl-directory-files (getvar "dwgprefix") "*.dwg" 0))
(setq pre (getvar 'dwgprefix))
(setq pathtxt (strcat (getvar "dwgprefix") "newfile.dsd"))
(setq fname (getstring T "\nEnter file name for pdf "))

(setq file (open (strcat (getvar "dwgprefix") "newfile.dsd") "w"))
(write-line "[DWF6Version]" file)
(write-line  "Ver=1" file)
(write-line  "[DWF6MinorVersion]" file)
(write-line  "MinorVer=1" file)
(foreach val files
  (write-line (strcat "[DWF6Sheet:" pre  val) file)
  (write-line (strcat "DWG=" pre val) file)
  (write-line "Layout=Model" file)
  (write-line "Setup=" file)
  (write-line (strcat "OriginalSheetPath="  pre val) file)
)
(write-line "[Target]" file)
(write-line "Type=6" file)
(write-line (strcat "DWF=" (getvar "dwgprefix") fname ".PDF") file)
(write-line (strcat "OUT=" (getvar "dwgprefix")) file)
(write-line "LocationType=2" file)
(write-line "[SheetSet Properties]" file)
(write-line "NoOfCopies=1" file)
(write-line "PlotStampOn=FALSE" file)
(write-line "PromptForDwfName=FALSE" file)
(write-line "GenerateDwfName=TRUE" file)
(write-line "IncludeLayer=FALSE" file)
(write-line "IncludeOffLayers=FALSE" file)
(write-line "[PdfOptions]" file)
(write-line "ConvertTextToGeometry=FALSE" file)
(write-line "LineMerge=FALSE" file)
(write-line "EmbedTtf=TRUE" file)
(write-line "ImageAntiAliasing=TRUE" file)
(write-line "JPEGImageCompression=TRUE" file)
(write-line "ExportHyperlinks=TRUE" file)
(write-line "CreateBookmarks=TRUE" file)
(write-line "VectorResolution=2400" file)
(write-line "RasterResolution=300" file)
(write-line "PdfA=0" file)
(close file)

(setvar 'FILEDIA 0)   ; Turn off file dialogs
(command "-PUBLISH" (strcat (getvar "dwgprefix") "newfile.dsd"))
(setvar 'filedia 1)

(princ)
);defun

0 Likes
Message 40 of 46

Markeckert
Enthusiast
Enthusiast

Sea-Haven, I have a lisp that is performing most of the functions that I needed. However, when it publishes the PDF it does not apply the Plot settings to the output PDF. I've attached the lisp file. Are you able to provide a change to this lisp that might resolve the issue?

0 Likes