1 / 28

Enforcing CAD Standards Using Visual LISP ®

Enforcing CAD Standards Using Visual LISP ®. R. Robert Bell Design Technology Manager, Sparling. Expectations. You do NOT need to know Visual LISP You will be exposed to some Visual LISP code. R. Robert Bell.

ron
Download Presentation

Enforcing CAD Standards Using Visual LISP ®

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Enforcing CAD Standards Using Visual LISP® R. Robert Bell Design Technology Manager, Sparling

  2. Expectations • You do NOT need to know Visual LISP • You will be exposed to some Visual LISP code

  3. R. Robert Bell • Design Technology Manager at Sparling since 2007(largest US electrical specialty firm) • Former network administrator at an MEP firm for 19 years • Writing code since 1983 • Former AUGI Director • Self-admitted Autodesk/AUGI discussion group junkie • Active participant in Autodesk Beta Programs • Published author

  4. Getting to Know You • How many have been CAD Managers for more than 2 years? • How many have little or no programming in AutoCAD?

  5. File Load Order • Acad20xx.lsp • Acad.rx • Acad.lsp • Acad20xxDoc.lsp • AcadDoc.lsp • MNL files • CUIx LISP Node • S::Startup

  6. Acad.rx • Text-based file • Loads ARX files • Filenames listed will load automatically

  7. Acad.lsp • Text-based file • Contains Visual LISP code • Executes only once per AutoCAD session • Leave AcadLspAsDoc=0

  8. AcadDoc.lsp • Text-based file • Contains Visual LISP code • Executes every time a drawing is opened

  9. MNL Files • Text-based file • Contains Visual LISP code • Executes every time a drawing is opened • Loads automatically as part of the CUIx

  10. CUIx LISP Node • Part of the CUIx • Executes every time a drawing is opened • Loads the LSP file

  11. S::Startup • Special Visual LISP function • Executes every time a drawing is opened • Executes after the command line is available • Append code to S::Startup

  12. Lost In Stupid Parentheses • Each opening parenthesis needs a closing parenthesis • A function name follows an open parenthesis • Data may follow the function name • Most functions return data (=sky "blue")

  13. Sample Visual LISP Code (if (= sky "blue") (DoWearShorts) (DoGrabUmbrella) )

  14. Editing Visual LISP Code • Can be done in Notepad • Use the VLIDE • Parenthesis matching • Color coding • Debugging tools • AU 2009 Classes on the VLIDE • CP218-2L • CP222-1L

  15. Bootstrapping • Profiles are important for CAD Standards • Specifies file search path • Specifies plot support items • Profiles can be deployed • Starting AutoCAD by not using your shortcut • Profiles can be changed • Enforce standards every time a drawing is opened

  16. Working with the Current Profile (wcmatch (strcase (getvar "Cprofile") ) (strcase "Sparling") ) (setq myProfile (vla-get-preferences (vlax-get-acad-object) ; <- needs (vl-load-com) ) )

  17. Settings in the Options, File Dialog Box (setqmyFiles (vla-get-files myProfile) ) (setqappPath (strcat (vla-get-path (vlax-get-acad-object)) "\\" ) )

  18. Forcing a Setting in the Options, File Dialog Box (vla-put-supportpath myFiles (strcat "P:\\Acad" ";" (strcat (getvar "RoamableRootPrefix") "Support") ";" (strcatappPath "Support") ) )

  19. Initializing the Environment • Highlighting (setvar "Highlight" 1) • File Dialogs (setvar "FileDia" 1) • Automatic Field Evaluation (setvar "FieldEval" (+ 1 2 4 8 16))

  20. Bitcodes • Some system variables use bitcode values • Bitcodes are like a bank of light switches • The first switch has a value of 1 • Each subsequent switch's value is double the previous • All "ON" values are added together • Each possible value is a unique combination of on/off positions

  21. Setting a Maximum Limit on Save Times (setvar "SaveTime" (min (getvar "SaveTime") 15 ) )

  22. Fixing a "Broken" Main Spelling Dictionary (if (= (getvar "DctMain") "" ) (setvar "DctMain" "enu") )

  23. Checking the Version of AutoCAD (if (> (atof (getvar "AcadVer") ) 17.1 ) (setvar "LayerDlgMode" 0) )

  24. Report to Mama (defunReportIssue (msg filename / file user ws) (if (setq file (open filename “a”)) (progn (write-line (strcat “User: “ (getvar “LoginName”) “, Workstation: “ (getenv “ComputerName”) “, “ msg) file) (close file))) (princ))

  25. Using the Reporting Function (if (and (= (atof (getvar “AcadVer”)) 18.0) (= (substr (getvar “_VerNum”) 1 (vl-string-search “ (UNICODE)” (getvar “_VerNum”))) “D.215.0.0”)) (ReportIssue “Has SP1.” “C:\\Temp\\AutoCAD 2010 Service Pack Report.txt”))

  26. Demand Loading • ;;;My Sample.lsp • (defun C:MySample () • ;; Lots of code here • (princ)) • ;;;AcadDoc.lsp • (defun C:MySample () • ;; Autoload the application • (load “My Sample.lsp”) • ;; Execute the newly loaded application’s function • (C:MySample))

  27. Summary • Enforcing standards in the profile is important • Cannot be done effectively without "programming" • Visual LISP is an easy way enforce standards

More Related