
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Guys, please remind me because it has been a really long time. I can't seem to pull this off.
I essentially have a list of layers from current drawings I've extracted from over 100 files (resulting in 12,000 uniques layers, OldLayerNames). I have another file that has all of the AutoCAD Layer Standards in there along with linetypes, colors and line weights (2,000+ unique layers StandardLayerNames). I have a team of interns working on manually mapping OldLayerNames to the StandardLayerNames, they will finish sometime tomorrow.
I want a way to read each OldLayerName and determine its StandardLayerName (once the interns finish that tomorrow, I'll have a CSV or TXT file that has OldLayerName,StandardLayerName. That is already done.
I already have another TXT file that has StandardLayerName,Color,LineType,LineWeight.
I can't seem to read-line on my second file and I don't know if its my problem with how I wrote this or if there is a limitation on how many TXT files a lisp can open Line #19 in the Secondary While statement seems to be the problem when I'm in Microsoft Visual Studio Code. (setq NAline (read-line f2))
(defun C:GLMVLtrans() ; Define Funcition - typing GLMVLtrans starts the command - Layer Translator
(princ) ; Dead return
(command "Undo" "BE") ; Start the Undo Begining point
(setq skip 0) ; save variable called skip to 0
(setq f1 (open "C:/Users/jayala/Documents/ATG/Clients/GLMV/Lisp/deleteme.txt" "R")) ; save variable called f1 using a specific file
(setq f2 (open "C:/Users/jayala/Documents/ATG/Clients/GLMV/Lisp/Net App Layer Standards.txt" "R")) ; save variable called f2 using a specific file
;;; Start the primary while statement.
(while ; Start while statement
(setq line (read-line f1)) ; Reads line in F1 and saves it as variable line so that while the line is not nil then repeat below until it is nil
(setq cPos (vl-string-search "," line)) ; Find the digit position of the comma in the line and save the number
(setq OldLayName (substr line 1 cpos)) ; Save the Old Layer name, everything before the comma digit position
(setq NewLayName (substr line (+ cPos 2))) ; Save the New Layer name, everything after the comma digit position
;;; Start the seconday while statement. This will keep looping on the read-line of the second file f2 until it matches the NewLayName with the NALayName
(while ; While
(setq NAline (read-line f2)) ; Reads line in f2 and saves it as variable NAline
(setq NAcPos1 (vl-string-search "," NAline)) ; Find the digit position of the first comma in the line and save the number
(setq NALayName (substr NAline 1 NAcPos1)) ; Extract the NetApp Layer name
;;; Start Main If statement to either merge or create new NetApp layer
(if (= NewLayName NALayName)
(progn
(setq NAcPos2 (vl-string-search "," NAline (+ 1 NACPos1))) ; Find the digit position of the second comma in the line and save the number
(setq NAcPos3 (vl-string-search "," NAline (+ 1 NACPos2))) ; Find the digit position of the third comma in the line and save the number
(setq NALayColor (substr NAline (+ 2 NAcPos1) (- NACPos2 1 NACPos1))) ; Extract the NetApp Color
(setq NALayLtype (substr NAline (+ 2 NAcPos2) (- NACPos3 1 NACPos2))) ; Extract the NetApp Line Type
(setq NALayLweight (/ (atoi (substr NAline (+ 2 NAcPos3))) 100.00)) ; Extract the NetApp Line Weight
(setq DoesLayerExist (TblSearch "Layer" NALayName)) ; Determines if Layer currently exists in the file
(setq skip 0) ; Setq variable Skip to 0
);progn
(setq skip 1)
);if
;;; Start Main If statement to either merge or create new NetApp layer
(if (= skip 1) ; If Skip = 1
(princ) ; Dead Return
(progn ; Progn, Else do the following
(If (/= nil DoesLayerExist) ; If the NALayName already esists
(command "-laymrg" "n" OldLayName "" "n" NALayName "y") ; Merge and delete the old layer to the new NetApp Layer, If it Layer doesn't exist
(progn ; progn, Do the following
(If (= NALayLweight -0.03) ; Start nested if statement, If the detected NetApp linewieght is default
(command "-layer" "n" NALayName "c" NALayColor NALayName "l" NALayLtype NALayName "") ; Make new layer with color, line type, If Not
(progn ; progn, do the following
(command "-layer" "n" NALayName "c" NALayColor NALayName "l" NALayLtype NALayName "lw" NALayLweight NALayName "") ; Make new layer with color, line type and Line weight
(command "-laymrg" "n" OldLayName "" "n" NALayName "y") ; Merge the old layer to the NetApp Layer, If it doesn't exist then
);progn ; progn, stop doing the following from line 48
);If ; End Nested If line 46
);progn ; progn, stop doing the following from line 45
);If ; End If line 43
);progn ; progn, stop doing the following from line 42
);If ; End secondary while satement
);while ; End secondary while satement
(close f2) ; close the file f2
);while ; End while statement
(close f1) ; close the file f1
;;; Wrap up
(command "undo" "end") ; Establishes the Undo End point
(princ) ; dead return
);eof
Solved! Go to Solution.