Author Topic: Check for plot setups with Autolisp - No ActiveX in Core Console  (Read 1623 times)

0 Members and 1 Guest are viewing this topic.

densan

  • Mosquito
  • Posts: 12
I have the need to use the AutoCAD core console due to the amount of drawings in a cleanup process 1000's+.   In my research, I learned that,
"Visual Lisp (ActiveX) commands DO NOT WORK with AutoCAD Core Console at this time.  Only straight AutoLISP commands work.  Anything with a VL prefix does not work."
And now I have to create code that checks if two page setups exist in the drawing and if not then import them both from a template.
I am struggling structuring the list and the conditional section, also I included a sample drawing file for testing.

Thanks for any help you can provide.

Code - Auto/Visual Lisp: [Select]
  1. ;;Orignal code by Fred Schreck
  2. ;;CAD/IT Manager
  3. ;;Kaplan McLaughlin Diaz Architects
  4. ;;San Francisco
  5. ;;2000
  6. (defun c:plotsetupcheck (/ ObjectList EntPlotDataList plssetup)
  7.   (setq ObjectList
  8.          (car
  9.            (cdr
  10.              (member '(3 . "ACAD_PLOTSETTINGS") (entget (namedobjdict)))
  11.            )
  12.          )
  13.   )
  14.   (setq EntPlotDataList (cdr ObjectList))
  15.   (setq PlotDataList (entget EntPlotDataList))
  16.   (setq plssetup (assoc 3 PlotDataList)) ;; Stuck here
  17. ;; Check for setup named "Basic_24x36" and "DWG To PDF"
  18.  
  19.  
  20. ;; Conditional section begin
  21.   )
  22. ;; Conditional section end
  23. (command "-psetupin"
  24.            "\\\\Server\\CleanUp\\AutoCAD\\Automation\\Template.dwt"
  25.            "DWG To PDF"
  26. )
  27. (command "-psetupin"
  28.            "\\\\Server\\CleanUp\\AutoCAD\\Automation\\Template.dwt"
  29.            "Basic_24x36F"
  30. )
  31.   (princ)
  32. )

If interested here is some reference material for the AutoCAD Core Console:
https://www.autodesk.com/autodesk-university/class/AutoCAD-Scripting-Core-AutoCAD-Core-Console-2018
https://www.keanw.com/2012/02/the-autocad-2013-core-console.html

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Check for plot setups with Autolisp - No ActiveX in Core Console
« Reply #1 on: July 03, 2019, 12:39:26 PM »
Give this a try:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:plotsetupcheck (/ l)
  2.                   (mapcar 'cdr
  3.                           (vl-remove-if
  4.                             '(lambda (x) (/= 3 (car x)))
  5.                             (dictsearch (namedobjdict) "ACAD_PLOTSETTINGS")
  6.                           )
  7.                   )
  8.           )
  9.   )
  10.   (foreach pagesetup '("DWG To PDF" "Basic_24x36F")
  11.     (or (vl-some '(lambda (x) (= x (strcase pagesetup))) l)
  12.         (command "-psetupin" "\\\\Server\\CleanUp\\AutoCAD\\Automation\\Template.dwt" pagesetup)
  13.     )
  14.   )
  15.   (princ)
  16. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

densan

  • Mosquito
  • Posts: 12
Re: Check for plot setups with Autolisp - No ActiveX in Core Console
« Reply #2 on: July 08, 2019, 02:12:54 PM »
Thank you very much ronjonp. I will be studying the code a lot.
It is simplier than my original approach.
 :-D

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Check for plot setups with Autolisp - No ActiveX in Core Console
« Reply #3 on: July 08, 2019, 04:14:18 PM »
Glad to help :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC