Jump to content

Pick Viewport To Change All Colors To 253 Including Xrefs And Blocks.


caxtin

Recommended Posts

Surprisingly, I cannot find a LISP to automatically changeall colors in a selected viewport to one color.

 

It’s either I see question where they are directed tosomething not related to the question, or two codes that were never finalizedby the helper.

 

My goal is to select a viewport (or viewports) and have allthe colors inside the viewport(s) change to color 254 – all entities includingblocks and xrefs. Traditionally I haveto go inside the viewport and change the colors in the Viewport Color column inthe Layer Manager. So, I would like toachieve this with a LISP code for viewport(s) in Papar Space.

Thanks in advance!

Link to comment
Share on other sites

In the title of the thread you wanted the color to be equal to 253 and in the thread you wanted to 254 , so you can change the number of the color to the one you want .

 

Just double click to activate the VIEWPORT that you want to change the colors to , and the code should get you out of it when its done . :D

 

NOTE : the function vla-put-activeviewport did not work in Cad 2013 and either 2014 .

 

(defun c:Test (/ *error*)
 (defun *error* (x)(vla-endUndomark doc) (setvar 'cmdecho 1) (princ "\n*Cancel*"))
 (or doc (setq doc (vla-get-activedocument (vlax-get-acad-object))))
 (setvar 'cmdecho 0)
 (vla-StartUndomark doc)
 (command "_.vplayer" "_color" 254 "*" "_current" "")
 (vla-put-mspace doc :vlax-false)
 (setvar 'cmdecho 1)
 (vla-endUndomark doc)
 (princ)
)
(vl-load-com)

Link to comment
Share on other sites

Sorry about the confusion about the color mixup, but that was no big deal. As you mentioned, I just changed to the color I need.

 

I thought I just have to click on the viewport, if I have to just double-click into the viewport to get what I need, just great. That's fine too and much better and much esasier than what I have been doing. I currently use 2014, loaded the code, and it worked like a charm.

 

I sure really appreciate your help/time in writing the code. Thank you soooooo much! I did a test and it worked like a charm.

 

Thanks again!

:D

Link to comment
Share on other sites

Sorry about the confusion about the color mixup, but that was no big deal. As you mentioned, I just changed to the color I need.

 

I thought I just have to click on the viewport, if I have to just double-click into the viewport to get what I need, just great. That's fine too and much better and much esasier than what I have been doing. I currently use 2014, loaded the code, and it worked like a charm.

 

I sure really appreciate your help/time in writing the code. Thank you soooooo much! I did a test and it worked like a charm.

 

Thanks again!

:D

 

Excellent , You're welcome . :)

Link to comment
Share on other sites

Tharwat, never assume system variables. Always store and reset.

While you may leave CMDECHO at 1 by default, someone else may set it to 0 in their startup.

Link to comment
Share on other sites

Tharwat, never assume system variables. Always store and reset.

While you may leave CMDECHO at 1 by default, someone else may set it to 0 in their startup.

 

Agreed , :thumbsup:

 

Thank you .

Link to comment
Share on other sites

  • 1 year later...

sorry to bump in to this thread..

if i want the color dialog to pop up and select a color is it possible?

Edited by nod684
Link to comment
Share on other sites

sorry to bump in to this thread..

if i want the color to dialog to pop up and select a color is it possible?

 

Yes it is .

 

Have a play with this .

 

(setq color (acad_colordlg 256))

Link to comment
Share on other sites

  • 3 years later...

Sorry to bump this one, is it possible to filter the xref that will not be change?

 

Example : i don't want the xref containing arch, elec to be changed. The rest will be overridden with color 8

Link to comment
Share on other sites

You need to make a list of what you dont want changed as it would be easier to do a global change then change a few back.

 

(vla-StartUndomark doc)
-> a defun ask layer and save current colour 
 (command "_.vplayer" "_color" 254 "*" "_current" "")
-> change the layer parameters back for the few

 

Cad_noob How do you propose entering the layers to undo ? A dcl list, type name etc. Hence in my code answer -> a defun

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