Strategy for dealing with customer files using yellow lines

My company often get DWGs from customers or contractors were objects are yellow or other pale colors. They may be colored by layer, or by assigning color to the object.  The layers are easy to change, but when objects in blocks and sub-blocks are colored by entity, this can be a major problem. This is obviously because they are using a black background for the CAD screen, where yellow shows up clearly.  Then, when they plot, they would use a pen profile that uses color to indicate line weight.  Of course, that pen profile is never given to us.  

The companies that  are unlikely to change their practices. My company often prints in color. In order to incorporate their drawings into ours, I often spend a half hour or more working to make their drawings acceptable.

A LISP routine could probably do all the color changes, perhaps changing all layer colors to be inverted in intensity. And likewise for any explicit entity colors in blocks and sub-blocks. But my LISP skills are not up to this task. 

Does anyone know of an existing utility to to the color changes?

Thanks,
-Joe

Comments

  • this will do it. in a .lsp file, load, and call with Block2Bylayer.

    (defun C:Block2Bylayer (/ ss cnt idx blkname donelist Update)
     
    ;main routine
      (if (> (logand (cdr (assoc 70 (tblsearch "layer" "0"))) 1) 0)
        (COMMAND "-layer" "t" 0 "")
        ;(princ "\nLayer 0 must be thawed before running FIXBLOCK!\n")
      )
      (if (progn
            (princ "\nSelect Blocks, or to do entire drawing:\n")
            (setq cnt 0
                  ss (ssget '((0 . "INSERT"))))
          )
        ;do chosen blocks
        (progn
          (setq idx (sslength ss))
          (while (>= (setq idx (1- idx)) 0)
            (if (not (member (setq blkname (strcase (cdr (assoc 2 (entget (ssname ss idx)))))) donelist))
              (progn
                (if (BlkClrByLay blkname)
                  (setq cnt (1+ cnt))
                )
                (setq donelist (cons blkname donelist)))))
        )
        ;do all blocks
        (while (setq blkname (cdr (assoc 2 (tblnext "BLOCK" (not blkname)))))
          (if (BlkClrByLay blkname)
            (setq cnt (1+ cnt))
          )
        )
      )
      (princ (strcat "\n" (itoa cnt) " block" (if (= cnt 1) "" "s") " redefined\n"))
      (princ)
    )

    ;update a given block name
    (defun BlkClrByLay (bname / ename elist STARTED ELISTALL)
      (setq ename (tblobjname "BLOCK" bname))
      (if (and ename (zerop (logand 52 (cdr (assoc 70 (entget ename '("*"))))))) ;the * is for xdata, 70 IS TO CHECK FOR XREFS
        (progn
          (while ename
            (setq elist (entget ename '("*")))
            (SETQ ELISTALL (CONS ELIST ELISTALL))
            (IF (AND STARTED
                     (= (cdr (assoc 0 elist)) "INSERT")
                )
              ;CLEAN THE BLOCK
              (BlkClrByLay (cdr (assoc 2 elist)))
            )
            ;NOW CLEAN THE BLOCK ITSELF
            (setq elist (if (assoc 62 elist)
                          (subst '(62 . 256) (assoc 62 elist) elist) ;color to bylayer
                          (append elist '((62 . 256)))
                        )
            )
            (entmod elist)
            (setq ename (entnext ename))
            (SETQ STARTED 1)
          )
          (if (/= "ENDBLK" (cdr (assoc 0 elist)))
            (entmake '((0 . "ENDBLK") (8 . "0")))
          )
          (princ (strcat "\nCleaned block: " bname "  had " (ITOA (LENGTH ELISTALL)) " entities."))
          'T ;send true back
        )
      )
    )

  • (defun c:ColorShift ()

    (princ "ColorShift changes everything from one color to another. ")
    (setq c1 (getint "Enter color number to change from: ") )
    (setq c2 (getint "Enter color number to change to: ") )

    (setq acDoc (vla-get-activedocument (vlax-get-acad-object) ) )

    (setq ss1 (ssget "X" (list (cons 62 c1) ) ) )
    (setq obj1 (vla-get-activeselectionset acDoc) )
    (vlax-for item obj1 (vla-put-color item c2) )

    (vlax-for obj2 (vla-get-Layers acDoc)
    (if (= (vla-get-Color obj2) c1) (vla-put-Color obj2 c2) )
    )

    )
  • but that does not handle items inside a block. Its good example code though for anyone trying to affect properties of objects based on other props.
  • This is similar to a previous post
    https://forum.bricsys.com/discussion/11733

    Here the issue was dealing with objects set to true color rather than ACI value. See the approach mentioned by Patrik, and the LISP provided by Roy.

    BTW I have a routine here to toggle background color between black and white Read more about "Toggle Background Colour (TBC)"

    Regards, Jason Bourhill CAD Concepts 
  • That's all I know how to do in Lisp. Unless someone else knows how to fix it to include entities inside blocks, the only thing I can suggest is to QuickSelect all the blocks in the file and burst them before doing the color shift.

    Or save as DXF and do a Replace All in Notepad++. That's a pretty crude approach, but it does get entities inside and outside of blocks, as well as layer colors, all in one operation. The Replace All has to be done in "Extended" search mode, and the search and replace strings have to be in this format:
    62\r\n   xxx
    with xxx representing a color code of one to three digits, and with three blank spaces before it.
  • @ James:
    Two small remarks regarding your code:
    1. In my experience you will never reach an "ENDBLK" entity using entnext.
    2. Creating such an entity for an existing block is not necessary (but does not create any problems either).

  • Thanks for looking so closely Roy. I have never debugged it that closely, and did not write all the code originally.

    I even forgot to change the name from FIXBLOCK in the thaw message! I would write my own if I had not found it though, this is a critical one fro our company.

    I also have one that does all properties to bylayer.

  • BricsCAD has the commands BKGCOLOR and BKGCOLORPS available to set the color of the modelspace and paperspace respectively. I use this, and defined a toolbar command to toggle between black and white in the modelspace using diesel.

    Create a tool with the following command string:
    [code]$M=$(if,$(and,$(=,$(getvar,BKGCOLOR),256)),_bkgcolor;7;,_bkgcolor;256;)[/code]

    Add a a toolbar and you have a button to toggle the color of the modelspace
This discussion has been closed.