Jump to content

Lisp colour change for all layers and blocks


hyposmurf

Recommended Posts

Hi VVA,

1.Our Model background was black,but when I tried white or grey,it still doesn't work,no source drawing.

2.Because sth conflict with our customise system,our CTRL + A command is disable,so normally we just use mouse to select all.I tried mouse,still nothing happened.what I gonna do?

 

thanks

I bind grey source drawing and all ok.

1. What color of your Model tab background?

2. If to use CTRL+A that something is selected?

PS.

From my practice.

Colour of model Model tab background set to True color 0,0,0.

Insert xref by black colour. Xref on model tab it is not visible, but it was selected on CTR+A.

Link to comment
Share on other sites

2.Because sth conflict with our customise system,our CTRL + A command is disable,so normally we just use mouse to select all.I tried mouse,still nothing happened.what I gonna do?

Copy or type this in command line

(SSSETFIRST nil (ssget "_ALL"))

 

Variant 2:

Type in command line _PSELECT and then _all

Link to comment
Share on other sites

1. I change code in #14. Now Color?? commands work whith Attributes (I hope :))

2. I run _AUDIT command in your file

Command: _audit

 

Fix any errors detected? [Yes/No] : Y

 

Auditing Header

 

 

DXF Name Current Value Validation Default

AcDbSortentsTable(1493)

Error for Entry (69F62,69FA2) eDuplicateKey fixed

AcDbSortentsTable(1493)

Error for Entry (69F72,6A0B0) eDuplicateKey fixed

AcDbSortentsTable(1493)

Error for Entry (69FB2,69F92) eDuplicateKey fixed

AcDbSortentsTable(1493)

Error for Entry (69FD2,69FC2) eDuplicateKey fixed

 

88 Blocks audited

Pass 1 199 objects audited

Pass 2 199 objects audited

Pass 3 4800 objects audited

Total errors found 4 fixed 4

2. Insert test.dwg as xref. Type ClorXREF and select 252 color. Bind your test.dwg without problem.

bindtest.dwg

Link to comment
Share on other sites

Hi VVA,

I have been tried your method,still doesn't work on my test drawing,I don't know why:(.Command line will show "Regenerating model"(see the attachment).Would mind post a smal video or screen shot about how you bind the drawing?By the way, the color of attribute has been changed,thanks a lot!

before bind.jpg

binding.jpg

after bind.jpg

Link to comment
Share on other sites

I have found the decision of this problem. Similar, it is bug AutoCAD.

In version 2006 all is normal.

In versions 2008 and 2009 similar problems are observed.

For bind of the xref use a command _CLASSICXREF and its option bind

Link to comment
Share on other sites

Sorry,I tried the command & bind option,will show this.The strange thing is,when I don't change the xref color,the drawing can be bind.By the way,which cad version you use?

 

I think I found the problem,as long as there is dimension ,the drawing will lost.but I don't konw how to slove it

binding.jpg

Link to comment
Share on other sites

Yes, at me too such messages. Then try to change algorithm.

Open a file test.dwg, run ColorX and change colour to 252 and then insert as xref.

Link to comment
Share on other sites

Hi,VVA,thanks for the solution.

This can slove the problem,but not the best way.Because we don't want to change anything from the source drawing.

 

BTW,when I use colorxref,all the color can be changed,except the dimension one,maybe lisp code can help with that.

 

Thanks a lot:)

Yes, at me too such messages. Then try to change algorithm.

Open a file test.dwg, run ClorX and change colour to 252 and then insert as xref.

Link to comment
Share on other sites

  • 2 weeks later...
BTW,when I use colorxref,all the color can be changed,except the dimension one,maybe lisp code can help with that.

Edit lisp in #14 Now it colored dimension

Link to comment
Share on other sites

Command:

ColorX - change color all object of drawing. All layer unlock and thaw

ColorXREF change color xref only on a current session. All layer unlock and thaw

ColorXL - change color all object of drawing. Objects on the locked and frozen layers are ignored

ColorXREFL change color xref only on a current session. Objects on the locked and frozen layers are ignored

*** Add 20.03.2009

Now ColorX ColorXREF work with Attrubutes

*** Add 30.03.2009

Now ColorXREF and ColorXREFL colored dimension.

(defun mip:layer-status-restore    ()
 (foreach item    *MIP_LAYER_LST*
   (if    (not (vlax-erased-p (car item)))
     (vl-catch-all-apply
   '(lambda ()
      (vla-put-lock (car item) (cdr (assoc "lock" (cdr item))))
      (vla-put-freeze
        (car item)
        (cdr (assoc "freeze" (cdr item)))
      ) ;_ end of vla-put-freeze
    ) ;_ end of lambda
     ) ;_ end of vl-catch-all-apply
   ) ;_ end of if
 ) ;_ end of foreach
 (setq *MIP_LAYER_LST* nil)
) ;_ end of defun

(defun mip:layer-status-save ()
 (setq *MIP_LAYER_LST* nil)
 (vlax-for item (vla-get-layers
          (vla-get-activedocument (vlax-get-acad-object))
        ) ;_ end of vla-get-layers
   (setq *MIP_LAYER_LST*
      (cons (list item
              (cons "freeze" (vla-get-freeze item))
              (cons "lock" (vla-get-lock item))
        ) ;_ end of cons
        *MIP_LAYER_LST*
      ) ;_ end of cons
   ) ;_ end of setq
   (vla-put-lock item :vlax-false)
   (if    (= (vla-get-freeze item) :vlax-true)
     (vl-catch-all-apply
   '(lambda () (vla-put-freeze item :vlax-false))
     ) ;_ end of vl-catch-all-apply
   ) ;_ end of if
 ) ;_ end of vlax-for
) ;_ end of defun
(defun ChangeXrefAllObjectsColor (Doc Color / tmp)
 (vlax-for Blk    (vla-get-Blocks Doc)
   (cond
     ((or (= (vla-get-IsXref Blk) :vlax-true)
      (and    (= (vla-get-IsXref Blk) :vlax-false)
       (wcmatch (vla-get-name Blk) "*|*")
      ) ;_ end of and
      ) ;_ end of or
      (vlax-for Obj Blk
    (if (and (vlax-write-enabled-p Obj)
         (vlax-property-available-p Obj 'Color)
        ) ;_ end of and
      (vla-put-Color Obj Color)
    ) ;_ end of if
    (if (and (vlax-write-enabled-p Obj)
         (= (vla-get-ObjectName obj) "AcDbBlockReference")
         (= (vla-get-HasAttributes obj) :vlax-true)
        ) ;_ end of and
      (foreach att    (vlax-safearray->list
             (vlax-variant-value (vla-GetAttributes obj))
           ) ;_ end of vlax-safearray->list
        (if (and (vlax-write-enabled-p att)
             (vlax-property-available-p att 'Color)
        ) ;_ end of and
          (vla-put-Color att Color)
        ) ;_ end of if
      ) ;_ end of foreach
    ) ;_ end of if
    (if (and (vlax-write-enabled-p Obj)
         (wcmatch (vla-get-Objectname Obj) "*Dimension*")
        ) ;_ end of and
      (progn
        (vl-catch-all-apply
          '(lambda    ()
         (vla-put-ExtensionLineColor Obj Col)
         (vla-put-TextColor Obj Col)
         (vla-put-DimensionLineColor Obj Col)
       ) ;_ end of lambda
        ) ;_ end of vl-catch-all-apply
      ) ;_ end of progn
    ) ;_ end of if
      ) ;_ end of vlax-for
     )
     ((= (vla-get-IsLayout Blk) :vlax-true)
      (vlax-for Obj Blk
    (if
      (and    (vlax-write-enabled-p Obj)
       (vlax-property-available-p Obj 'Color)
       (vlax-property-available-p Obj 'Path)
       (wcmatch (strcase (vla-get-ObjectName Obj)) "*BLOCK*")
      ) ;_ end of and
       (vla-put-Color Obj Color)
    ) ;_ end of if
      ) ;_ end of vlax-for
     )
     (t nil)
   ) ;_cond
 ) ;_ end of vlax-for
) ;_ end of defun
(defun ChangeAllObjectsColor (Doc Color)
 (vlax-for Blk    (vla-get-Blocks Doc)
   (if    (= (vla-get-IsXref Blk) :vlax-false)
     (vlax-for    Obj Blk
   (if (and (vlax-write-enabled-p Obj)
        (vlax-property-available-p Obj 'Color)
       ) ;_ end of and
     (vla-put-Color Obj Color)
   ) ;_ end of if
   (if (and (vlax-write-enabled-p Obj)
        (= (vla-get-ObjectName obj) "AcDbBlockReference")
        (= (vla-get-HasAttributes obj) :vlax-true)
       ) ;_ end of and
     (foreach att (vlax-safearray->list
            (vlax-variant-value (vla-GetAttributes obj))
              ) ;_ end of vlax-safearray->list
       (if    (and (vlax-write-enabled-p att)
            (vlax-property-available-p att 'Color)
       ) ;_ end of and
         (vla-put-Color att Color)
       ) ;_ end of if
     ) ;_ end of foreach
   ) ;_ end of if
     ) ;_ end of vlax-for
   ) ;_ end of if
 ) ;_ end of vlax-for
) ;_ end of defun
(defun C:COLORX    (/ doc col)
 (vl-load-com)
 (setq doc (vla-get-activedocument (vlax-get-acad-object)))
 (vla-startundomark doc)
 (mip:layer-status-save)
 (if (setq col (acad_colordlg 7 t))
   (ChangeAllObjectsColor doc col) ;_ col — color number
 ) ;_ end of if
 (mip:layer-status-restore)
 (vla-endundomark doc)
 (princ)
) ;_ end of defun
(defun C:COLORXREF (/ doc col)
 (vl-load-com)
 (alert
   "\This lisp change color xref\nONLY ON A CURRENT SESSION"
 ) ;_ end of alert
 (setq doc (vla-get-activedocument (vlax-get-acad-object)))
 (vla-startundomark doc)
 (mip:layer-status-save)
 (if (setq col (acad_colordlg 7 t))
   (ChangeXrefAllObjectsColor doc col) ;_ col — color number
 ) ;_ end of if
 (mip:layer-status-restore)
 (vla-endundomark doc)
 (princ)
) ;_ end of defun
(defun C:COLORXL (/ doc col)
 (vl-load-com)
 (setq doc (vla-get-activedocument (vlax-get-acad-object)))
 (vla-startundomark doc)
 (if (setq col (acad_colordlg 7 t))
   (ChangeAllObjectsColor doc col) ;_ col — color number
 ) ;_ end of if
 (vla-endundomark doc)
 (princ)
) ;_ end of defun
(defun C:COLORXREFL (/ doc col)
 (vl-load-com)
 (alert
   "\This lisp change color xref\nONLY ON A CURRENT SESSION"
 ) ;_ end of alert
 (setq doc (vla-get-activedocument (vlax-get-acad-object)))
 (vla-startundomark doc)
 (if (setq col (acad_colordlg 7 t))
   (ChangeXrefAllObjectsColor doc col) ;_ col — color number
 ) ;_ end of if
 (vla-endundomark doc)
 (princ)
) ;_ end of defun
(princ
 "\nType ColorX, COLORXREF, ColorXL, COLORXREFL  in command line"
) ;_ end of princ

If you want to operate colour of xref objects in the blanket drawing:

1. Open Xref (sourcing drawing.dwg)

2. Run ColorX and set color bylayer

3.open a blanket drawing

4. Creat layer "Xref"

5. Set layer "Xref" current

6 use xref command to attach the source drawing (sourcing drawing.dwg)

7.change the xref color in layer manager. choose grey

NOTE. If some objects in xref (sourcing drawing.dwg) are placed on a layer 0 your mast change layer of an insert of the external reference in a blanket drawing to grey too. (layer "XREF")

I do not know as this technical term sounds in English. I translate from Russian: there Is an emersion of a layer 0. All objects located on 0 layer in drawing of the external reference (sourcing drawing.dwg) inherit properties of a external reference layer in blanket drawing (layer "XREF")

 

Thanks for this fine lisp, there's just one thing in my drawing which won't get another color and that are the radius dimensions. Maybe there's also a solution for this?

Link to comment
Share on other sites

nice.

but i miss (q)leader

 

(and (eq (vla-get-objectname ent) "AcDbLeader")
         (vla-put-DIMENSIONLINECOLOR ent col)
)

 

and mtext with more then one color

something like

 

(setq txtstr (vlax-get-property vlaobj 'TextString)) 
 (setq txtstr (vl-string-subst XOLDCOLOR XNEWCOLOR txtstr))

Link to comment
Share on other sites

nice.

but i miss (q)leader

 

(and (eq (vla-get-objectname ent) "AcDbLeader")
         (vla-put-DIMENSIONLINECOLOR ent col)
)

 

and mtext with more then one color

something like

 

(setq txtstr (vlax-get-property vlaobj 'TextString)) 
 (setq txtstr (vl-string-subst XOLDCOLOR XNEWCOLOR txtstr))

Thanks. Try #14 now. Add Mleader too.

Link to comment
Share on other sites

hallo,

 

vla-put-LeaderLineColor is not supported on 2007!?

(or have a other leader :()

(0 . "LEADER")..(100 . "AcDbLeader")

 

ObjectName (RO) = "AcDbLeader"

Link to comment
Share on other sites

I little edit #14.

hallo,

vla-put-LeaderLineColor is not supported on 2007!?

(or have a other leader :()

(0 . "LEADER")..(100 . "AcDbLeader")

ObjectName (RO) = "AcDbLeader"

I use catch

(vl-catch-all-apply 'vla-put-LeaderLineColor (list Obj tmp))

Link to comment
Share on other sites

Sorry,

in 2007 it do not works,

error VLA-PUT-LEADERLINECOLOR

in the help of vlide and with vlax-dump-Object, there is no property available, no LEADERLINECOLOR

perheps you use 2008 and it is new in 2008

but

(and (eq (vla-get-objectname ent) "AcDbLeader")
         (vla-put-DIMENSIONLINECOLOR ent col)
)

this works o:)

 

and the colors in mtext...

Link to comment
Share on other sites

  • 6 months later...

This script is nearly what i need, but not just yet :).

In my department (electricity) when we make layout plans, we make the architectural xref grey by changing the layer colours (manually) so the electrical components are more visible on the plot.

This lisp by vva changes the color of the objects but not the layers and is only temporarily, the xref is in full color when reloaded after a save.

Is there a script that changes xref layer colors?

thanks!

Link to comment
Share on other sites

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...