jamami Posted yesterday at 12:36 PM Author Posted yesterday at 12:36 PM This is a typical example drawing, you will see the bogus linetypes and block. I have processed 6 scripts files now on this one folder (500+ drawings each time), and after each time consumung cycles I realise that something else isn't quite perfect... AA0003-3D-LWT.dwg Quote
jamami Posted yesterday at 12:53 PM Author Posted yesterday at 12:53 PM i am getting somewhere I have wblocked out all entities to a new 'mirror' files, this has got rid of all the detritus. then i hacked your brilliant routine (below) and reprocessed all the files. i have noticed a few files still have am_5 and am_7 layers in them!! ;;; Clean drawings to match standards ;;; ;;; https://www.cadtutor.net/forum/topic/98263-extracting-block-data-to-a-report/#findComment-673250 ;;; ;;; SLW210 (a.k.a. Steve Wilson) ;;; ;;; CheckDrawing_1-1.lsp ;;; ;;; Made more robust layer handling and some general clean-up ;| ************************************************************************************************************** | Moves 3D solids to layer `3D` | | Moves centrelines (assumed to be lines with "center" linetype) to `CL` (for red) or `CL_SS` (for color 150)| | Sets all entities’ color, linetype, and lineweight to BYLAYER | | Sets current layer to `0` | | Purges 3x | | Sets UCS to World | | Sets visual style to Conceptual | | Sets view to SW Isometric | | Zooms to Extents | | Ensures layer `0` is empty, and layers `CL`, `CL_SS`, `3D` exist with correct settings | *************************************************************************************************************|; (defun strp (x) (eq (type x) 'STR)) ;; Ensure required layers exist (adjust as needed) (defun ensure-layer (name color) (if (not (tblsearch "LAYER" name)) (entmake (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") (cons 2 name) ; Layer name (cons 70 0) ; Layer flags (cons 62 color) ; ACI color (cons 6 "Continuous") ; Linetype ) ) ) ) (defun c:setdrawing (/ ) ;; Create layers with specified colors (ensure-layer "D-3D-SOL" 7) ; White (ensure-layer "D-3D-CLG" 1) ; Red (ensure-layer "D-3D-CLM" 5) ; Blue ;; Set current layer to sol (command "_.layer" "_set" "D-3D-SOL" "") (command "_.layer" "_tr" "0" "" "") (command "_.layer" "_lw" "0.3" "" "") (command "_.layer" "_l" "Continuous" "" "") ;; Set current layer to clm (command "_.layer" "_set" "D-3D-CLM" "") (command "_.layer" "_tr" "0" "" "") (command "_.layer" "_lw" "0.18" "" "") (command "_.layer" "_l" "Center" "" "") ;; Set current layer to clg (command "_.layer" "_set" "D-3D-CLG" "") (command "_.layer" "_tr" "0" "" "") (command "_.layer" "_lw" "0.18" "" "") (command "_.layer" "_l" "Center" "" "") ;; Set current layer to 0 (command "_.layer" "_set" "0" "") (command "_.layer" "_tr" "0" "" "") (command "_.layer" "_lw" "0.25" "" "") (command "_.layer" "_l" "Continuous" "" "") ;; Purge unused items (3 passes) (repeat 3 (command "_.purge" "all" "*" "n")) ;; Reset UCS, visual style, and view (command "_.ucs" "_world") (command "_.vscurrent" "Conceptual") (command "_.view" "_swiso") (command "_.zoom" "_extents") (princ "\nDrawing processed successfully.") (princ) ) They all looking good besides that, have several more folders to process now but Im thinking there must be quicker way, like you say let the lisp take the strain. I also want o run the audit report occasionally so i can see if any 'non complaint' blocks have appeared. Quote
jamami Posted yesterday at 12:54 PM Author Posted yesterday at 12:54 PM i also noticed that all the dwg icons were inverted when i scripted out all the wblocks ! Quote
SLW210 Posted yesterday at 02:04 PM Posted yesterday at 02:04 PM That drawing already appears to be cleaned up. Quote
jamami Posted 23 hours ago Author Posted 23 hours ago 2 hours ago, jamami said: This is a typical example drawing, you will see the bogus linetypes and block. I have processed 6 scripts files now on this one folder (500+ drawings each time), and after each time consumung cycles I realise that something else isn't quite perfect... AA0003-3D-LWT.dwg 93.78 kB · 1 download No, it has many linestyles in it that are not needed or puregable, also a block GENAXAH that is not purgeable. I have now script wblocked out the entities and saved a mirror copy, this creates a clean drawing but doesn't solve the issue of extra layers, items on wrong layers, default colors, linetypes , transpancey etc etc etc Quote
jamami Posted 23 hours ago Author Posted 23 hours ago the layer color isnt correct either as i have now set layer D-3D-CLM to blue (color 5) Quote
SLW210 Posted 16 hours ago Posted 16 hours ago I'll look at it tomorrow at work. Anything else? Quote
BIGAL Posted 14 hours ago Posted 14 hours ago (edited) Have you thought about what if it exists as part of this call "(ensure-layer "D-3D-CLM" 5)", your doing a does not exist but you can do a set color if exists. Look at your "ensure-layer". Example code to put in your defun, same if want to change linetype. (command "-layer" "C" color name "") Edited 14 hours ago by BIGAL Quote
jamami Posted 7 hours ago Author Posted 7 hours ago Thanks for suggestion I had done exactly as suggested but I did it as a script file rather than lisp routine adding lines for linetyp, line weight and transparency . Quote
jamami Posted 4 hours ago Author Posted 4 hours ago in the ensure-layer function below the layer name is referenced as dxf group code 2 (defun ensure-layer (name color) (if (not (tblsearch "LAYER" name)) (entmake (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") (cons 2 name) ; Layer name (cons 70 0) ; Layer flags (cons 62 color) ; ACI color (cons 6 "Continuous") ; Linetype ) ) ) ) the autocad reference provides 8 as the layer as shown on the attached image. is this because we are assigning a name under entmake rather than reading a name Quote
Lee Mac Posted 4 hours ago Posted 4 hours ago (edited) The DXF data list supplied to entmake in your ensure-layer function is creating a layer table record (or LAYER entity), for which the reference may be found here, whereas DXF group 8 typically contains the layer referenced by another entity. Edited 4 hours ago by Lee Mac Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.