Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp to change the entities color

28 REPLIES 28
SOLVED
Reply
Message 1 of 29
Anonymous
14638 Views, 28 Replies

Lisp to change the entities color

I need a lisp to change the entities color. Three choice for changing the color: 1. change color to red. 2. change color to yellow. 3. change color to green.

need to force the user to press 1 or 2 or 3.

The lisp also need to prompt the user for 2 corners of a window and print a message displaying the number of entities that were changed. Ex: if the user chose number 3, the message should be "527 Entities were changed to the color GREEN". If there are no entities in the window, the message should be like " No entities selected."

Thanks for your help.

28 REPLIES 28
Message 21 of 29
Kent1Cooper
in reply to: Ranjit_Singh2


@Ranjit_Singh2 wrote:

@owitzki wrote:

syntax for true color please!


.... I would avaoid messing with (acad_truecolordlg)


That raises the question:  @owitzki, are you looking for something like what's in Post 1 [a limited set of fixed color choices], or more like the TrueColor version of Post 8 and subsequent replies [the User gets to choose a TrueColor]?  If the latter, I expect it will be necessary to mess with (acad_truecolordlg).

Kent Cooper, AIA
Message 22 of 29
Ranjit_Singh2
in reply to: Kent1Cooper


@Kent1Cooper wrote:

@Ranjit_Singh2 wrote:

@owitzki wrote:

syntax for true color please!


.... I would avaoid messing with (acad_truecolordlg)


That raises the question:  @owitzki, are you looking for something like what's in Post 1 [a limited set of fixed color choices], or more like the TrueColor version of Post 8 and subsequent replies [the User gets to choose a TrueColor]?  If the latter, I expect it will be necessary to mess with (acad_truecolordlg).


You are right. If the user intends to select it from the dialog box he needs to call (acad_truecolordlg). I was assuming the RGB value is known and so the OP was looking for a function to convert to true color.

Message 23 of 29
owitzki
in reply to: Ranjit_Singh2

Tnx Ranjit, I actually want true color for 254 but ... ac254 seems doesn't work!

Message 24 of 29
owitzki
in reply to: Ranjit_Singh2

true color for red should be 255,0,0

Message 25 of 29
owitzki
in reply to: Ranjit_Singh2

Maybe I should give you the lisp I found here in the forum and tried to modify it:

 

(defun c:d254t ( / d )
(vlax-for b (vla-get-blocks (setq d (vla-get-activedocument (vlax-get-acad-object))))
(if (= :vlax-false (vla-get-isxref b))
(vlax-for o b
(if (and (= "AcDbHatch" (vla-get-objectname o))
(= "SOLID" (strcase (vla-get-patternname o)))
(vlax-write-enabled-p o)
)
(vla-put-color o rgb:190,190,190)
)
)
)
)
(vla-regen d acallviewports)
(princ)
)
(vl-load-com) (princ)

Message 26 of 29
owitzki
in reply to: owitzki

The original topic for this was delete all solid hatch and it's a powerful tool. But other designers want solid hatch to be light color (which I made it 254) but it is not safe if some discipline uses 254 as black. If we use true color of 254 (rgb:190,190,190) then my dwg is safe.

Message 27 of 29
owitzki
in reply to: owitzki

true color for 254 (rgb:214,214,214)

Message 28 of 29
owitzki
in reply to: owitzki

Also, using setbylayer command (set color bylayer), it does make all color bylayer but dimension, leader & mtext with forced color, their color don't change. Is there a routine that changes globally all colors bylayer (including mtext, leaders & dimensions)?

Message 29 of 29
Kent1Cooper
in reply to: owitzki


@owitzki wrote:

Also, using setbylayer command (set color bylayer), it does make all color bylayer but dimension, leader & mtext with forced color, their color don't change. Is there a routine that changes globally all colors bylayer (including mtext, leaders & dimensions)?


Do some Searching.  There are routines on these Forums and elsewhere to do that kind of thing.

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report