Jump to content

Recommended Posts

Posted

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

  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

  • jamami

    29

  • SLW210

    18

  • BIGAL

    3

  • Lee Mac

    1

Top Posters In This Topic

Posted Images

Posted

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.

 

 

 

Posted

i also noticed that all the dwg icons were inverted when i scripted out all the wblocks !

Posted
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

  

image.png.ed89983536ae9bd5374154386eba2e8d.pngimage.png.ab46e223b58fbb7690d82ad543c3d6f1.png

Posted

the layer color isnt correct either as i have now set layer D-3D-CLM to blue (color 5) 

image.thumb.png.0dcd0a538442fea977e16e0a537143e4.png

Posted

I'll look at it tomorrow at work.

 

Anything else?

Posted (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 by BIGAL
Posted

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 .

 

Posted

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 

 

 

 

 

image.png

Posted (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 by Lee Mac

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...