Lisp Routine Help

Lisp Routine Help

cdavis
Advocate Advocate
117 Views
5 Replies
Message 1 of 6

Lisp Routine Help

cdavis
Advocate
Advocate

Hi all,

I am trying to write a lisp routine that will call up a certain .dws file for layer translation. I am not any good at lisp, and for a lot of the other ones, I have successfully used AI to generate my lisp, except for this one.

 

This is the first step in a conversion process that will start with the .dws file, then run some other lisp routines for specific blocks to specific layers (after the translate), then finish with a block replacement. Unfortunately, I cannot get 2024 Civil 3D to run the .dws file from the command line to load a predefined file. It does not seem that -laytrans, or acet-laytrans works when i try it manually. Here is the lisp routine I have.
Oh, and does anyone know if I replace my username (cdavis) with %username% will work for deployment across my company? Everyone will have the same path, except for the username.

LISP:

(defun c:CTA ( / standardsFile )
;; Path to your DWS file
(setq standardsFile "C:\\Users\\cdavis\\DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\MT to CT Aerial Lidar.dws")

;; Make sure file exists before running
(if (findfile standardsFile)
(progn
(princ "\nRunning Layer Translator using standards file...")

;; Run Layer Translator in command-line mode
;; "L" = Load standards file
;; "T" = Translate
;; "Y" = Yes, apply translation
(command ".acet-laytrans"
"L" standardsFile
"" ;; Finish loading
"T"
"Y"
"" ;; Finish command
)

(princ "\nLayer translation complete.")
)
(princ (strcat "\nCould not find standards file: " standardsFile))
)
(princ)
)

0 Likes
118 Views
5 Replies
Replies (5)
Message 2 of 6

Jeff_M
Consultant
Consultant

@cdavis When posting code, please use the Code tag: 

Code tag.png

See the help file for how to use acet-laytrans:

https://help.autodesk.com/view/OARX/2024/ENU/?guid=GUID-4BD312D1-1850-4DE4-A63D-35367C5F7F5D

 

For the user name issue:

(setq user (getvar 'Username))
(setq standardsFile (strcat "C:\\Users\\" user "\\DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\MT to CT Aerial Lidar.dws")
Jeff_M, also a frequent Swamper
EESignature
Message 3 of 6

BlackBox_
Advisor
Advisor

@cdavis Depending on your IT department, there can be a difference in UserName & LoginName sysvars, as @paullimapa  reminded me here: 

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/need-a-lisp-for-multiple-object-stl-...

 

Cheers


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

Message 4 of 6

Jeff_M
Consultant
Consultant

@BlackBox_ I learned something new today. I never knew there is a LoginName, nor that MYDOCUMENTSPREFIX existed... 🤔

 

@cdavis I revise my suggestion to this:

(setq user (vl-string-subst "" "Documents" (getvar 'MYDOCUMENTSPREFIX) ))
(setq standardsFile (strcat user "DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\MT to CT Aerial Lidar.dws")
Jeff_M, also a frequent Swamper
EESignature
Message 5 of 6

cdavis
Advocate
Advocate

Jeff_M, thank you for letting me know about the code tag, sorry about that. I am very new at all of this, and to be honest, I have been able to get AI to write most of the simple routines for me.

Would this be the case for any lisp that I need others to point to. For instance, I am also doing a lisp that will demand load and run several other lisp routines. Would I need to use the suggested code one time at the beginning, or for each "load" sequence

As a little background, our company uses the Autodesk Docs cloud for all our standards to run through, so each staff member that uses Civil 3D logs into ACCDOCS and it synchs the data from the cloud to the local user. Each log in is assigned By IT as the same for every instance of company logins, so the computer username is the same as the system admin/server info. So when I develop some standards and lisp routines, I need them to be able to fire form anyone's computer. So the "username" is cdavis for me, JDoe, JSmith, etc. I know when we set up the Profiles for Civil 3D, we are able to just use the %username% in place of the actual name for all the profile paths.

(defun c:LiDAR ( / )

  (princ "\n=== Starting Batch Routine ===")

  ;; --- Load each routine ---
  (load "C:\\Users\\cdavis\\DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\Code\\VT-LiDAR.lsp")
  (load "C:\\Users\\cdavis\\DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\Code\\APR-LiDAR.lsp")
  (load "C:\\Users\\cdavis\\DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\Code\\UT-LiDAR.lsp")
  (load "C:\\Users\\cdavis\\DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\Code\\DI-LiDAR.lsp")
  (load "C:\\Users\\cdavis\\DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\Code\\Tree-LiDAR.lsp")
  (load "C:\\Users\\cdavis\\DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\Code\\Topo-LiDAR.lsp")
  (load "C:\\Users\\cdavis\\DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\Code\\TCD-LiDAR.lsp")
  (load "C:\\Users\\cdavis\\DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\Code\\SN-LiDAR.lsp")
  (load "C:\\Users\\cdavis\\DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\Code\\MTR-LiDAR.lsp")
  (load "C:\\Users\\cdavis\\DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\Code\\MH-LiDAR.lsp")
  (load "C:\\Users\\cdavis\\DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\Code\\LTG-LiDAR.lsp")
  (load "C:\\Users\\cdavis\\DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\Code\\HYD-LiDAR.lsp")
  (load "C:\\Users\\cdavis\\DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\Code\\CB-LiDAR.lsp")
  (load "C:\\Users\\cdavis\\DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\Code\\BX-LiDAR.lsp")
  (load "C:\\Users\\cdavis\\DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\Code\\CVT-LiDAR.lsp")
  (load "C:\\Users\\cdavis\\DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\Code\\VA-LiDAR.lsp")
  (load "C:\\Users\\cdavis\\DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\Code\\Poles-LiDAR.lsp")

  ;; --- Run each routine in sequence ---
  (princ "\nRunning VT-LiDAR...")
  (c:VT-LiDAR)

  (princ "\nRunning APR-LiDAR...")
  (c:APR-LiDAR)

  (princ "\nRunning UT-LiDAR...")
  (c:UT-LiDAR)

  (princ "\nRunning DI-LiDAR...")
  (c:DI-LiDAR)

  (princ "\nRunning Tree-LiDAR...")
  (c:Tree-LiDAR)

  (princ "\nRunning Topo-LiDAR...")
  (c:Topo-LiDAR)

  (princ "\nRunning TCD-LiDAR...")
  (c:TCD-LiDAR)

  (princ "\nRunning SN-LiDAR...")
  (c:SN-LiDAR)

  (princ "\nRunning MTR-LiDAR...")
  (c:MTR-LiDAR)

  (princ "\nRunning MH-LiDAR...")
  (c:MH-LiDAR)

  (princ "\nRunning LTG-LiDAR...")
  (c:LTG-LiDAR)

  (princ "\nRunning HYD-LiDAR...")
  (c:HYD-LiDAR)

  (princ "\nRunning CB-LiDAR...")
  (c:CB-LiDAR)

  (princ "\nRunning BX-LiDAR...")
  (c:BX-LiDAR)

  (princ "\nRunning CVT-LiDAR...")
  (c:CVT-LiDAR)

  (princ "\nRunning VA-LiDAR...")
  (c:VA-LiDAR)

  (princ "\nRunning Poles-LiDAR...")
  (c:Poles-LiDAR)

  ;; Zoom extents at end
  (command "ZOOM" "E")

  (princ "\n=== All routines completed ===")
  (princ)
)

 

0 Likes
Message 6 of 6

BlackBox_
Advisor
Advisor

This may help expedite the load process, and *should* demand-load the routines for each user: 

(setq path
       (strcat
         (vl-string-subst "" "Documents" (getvar 'mydocumentsprefix))
         "DC\\ACCDocs\\MarkThomas\\CAD-Support\\Project Files\\Survey\\Layer Converters\\Caltrans\\Code\\"
       )
)
(autoload (strcat path "VT-LiDAR.lsp") '("VT-LiDAR"))
;; more here


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps