Changing entity color by pressing 1 button
Changing entity color by pressing 1 button
(OP)
does any one of you guys happen to know how to change an entity color by pressing a single button after selecting the entity....say for example "1" to change it to red , "2" to change it to yellow and so on....
thanks
marisse
thanks
marisse





RE: Changing entity color by pressing 1 button
RE: Changing entity color by pressing 1 button
Actually, i want to limit the number of layers that's the reason why i would like to change the entity color/s.
RE: Changing entity color by pressing 1 button
(defun ssColor ( / sset check)
;load the visual lisp extensions
(vl-load-com)
;check for selection
(while
;get the entity and entity name
(setq sset (car (entsel)))
;convert to vl object
(setq sset (vlax-ename->vla-object sset))
;check if the entity has a color property
;and it can be updated
(setq check (vlax-property-available-p sset "Color" T))
;if it can
(if check
;change it's color
(vlax-put-property sset 'Color 4)
);if
);while
(princ)
);defun
(princ)
"Everybody is ignorant, only on different subjects." — Will Rogers
RE: Changing entity color by pressing 1 button
is pressing a single button before selecting the entity ok? (and enter the selection) Then try the macro: ^C^C_select \_change _p; _p _c 1;; for color red.
regards, Lothar
ADT 2004
ACAD 2002
RE: Changing entity color by pressing 1 button
I appreciate your help but i don't really know how to use these tools (macro & lsp). I hope u can enlighten me about these matters.
TY
Marisse
RE: Changing entity color by pressing 1 button
just type 1 for red, 2 for yellow and so on...after selecting the entity.
u can also change lintype by selecting the entity then type h for hidden, c for center....
u can also change ltscale by selecting the entity then typing 0.1, 0.2, 10, 1000....or whatever linetype desired for that entity.
i think it can be done by manipulating the chprop command but i don't know how to do it.
RE: Changing entity color by pressing 1 button
This also works for changing a layer, linetype, lineweight, dimension style, etc.
RE: Changing entity color by pressing 1 button
Yeah, i guess i have to do it that way. But u know, if we have this lisp command i don't need to move the mouse to the drop down menu area. after clicking the enity i can immediately press 1 with my left hand. I can also change the ltscale easily.
RE: Changing entity color by pressing 1 button
Here's a small lisp routine and menu (.mns file)for changing colours.
Load the lisp routine into your start up suite and load the menu file. You don't have the icons for the toolbar so your buttons will all be yellow happy faces but you can edit the button. Mine are simply colour filled buttons i.e. red, yellow etc.,
Hope this helps for the colour change anyway.
Lisp:
;Change Colour.lsp
(defun C:red (/ c1)
(graphscr)
(ssget)
(setq c1 "1")
(command "change" "p" "" "p" "c" c1 "")
)
(defun C:yellow (/ c1)
(graphscr)
(ssget)
(setq c1 "2")
(command "change" "p" "" "p" "c" c1 "" )
)
(defun C:green (/ c1)
(graphscr)
(ssget)
(setq c1 "3")
(command "change" "p" "" "p" "c" c1 "")
)
(defun C:cyan (/ c1)
(graphscr)
(ssget)
(setq c1 "4")
(command "change" "p" "" "p" "c" c1 "")
)
(defun C:blue (/ c1)
(graphscr)
(ssget)
(setq c1 "5")
(command "change" "p" "" "p" "c" c1 "")
)
(defun C:magenta (/ c1)
(graphscr)
(ssget)
(setq c1 "6")
(command "change" "p" "" "p" "c" c1 "")
)
(defun C:white (/ c1)
(graphscr)
(ssget)
(setq c1 "7")
(command "change" "p" "" "p" "c" c1 "")
)
(defun C:gray (/ c1)
(graphscr)
(ssget)
(setq c1 "8")
(command "change" "p" "" "p" "c" c1 "")
)
;End of file
Menu:
//
// AutoCAD menu file
//
***TOOLBARS
**CHANGE_COLOUR
**TB_CHANGE_COLOUR
ID_Change_Colour_0 [_Toolbar("Change Colour", _Floating, _Show, 400, 333, 1)]
ID_UserButton_0 [_Button("User Defined Button", "ICON.bmp", "ICON_16_BLANK")]^C^Cred
ID_UserButton_1 [_Button("User Defined Button", "ICON8628.bmp", "ICON_16_BLANK")]^C^Cyellow
ID_UserButton_2 [_Button("User Defined Button", "ICON5473.bmp", "ICON_16_BLANK")]^C^Cgreen
ID_UserButton_3 [_Button("User Defined Button", "ICON9533.bmp", "ICON_16_BLANK")]^C^Ccyan
ID_UserButton_4 [_Button("User Defined Button", "ICON9090.bmp", "ICON_16_BLANK")]^C^Cblue
ID_UserButton_5 [_Button("User Defined Button", "ICON6284.bmp", "ICON_16_BLANK")]^C^Cmagenta
ID_UserButton_6 [_Button("User Defined Button", "ICON2417.bmp", "ICON_16_BLANK")]^C^Cwhite
ID_UserButton_7 [_Button("User Defined Button", "ICON2392.bmp", "ICON_16_BLANK")]^C^Cgray
***HELPSTRINGS
ID_USERBUTTON_5 [User Defined Button]
ID_USERBUTTON_6 [User Defined Button]
ID_USERBUTTON_7 [User Defined Button]
ID_USERBUTTON_0 [User Defined Button]
ID_USERBUTTON_1 [User Defined Button]
ID_USERBUTTON_2 [User Defined Button]
ID_USERBUTTON_3 [User Defined Button]
ID_USERBUTTON_4 [User Defined Button]
//
// End of AutoCAD menu file
//
RE: Changing entity color by pressing 1 button
Thank you.
RE: Changing entity color by pressing 1 button
You could also use the property pallette for changing color, etc. and it has the ltscale available as well.
RE: Changing entity color by pressing 1 button
Here's a small edit to your lisp and menu files.
Lisp: paste in the following just prior to ;end of file.
(defun C:hidden (/ lt)
(graphscr)
(ssget)
(setq lt "hidden")
(command "change" "p" "" "p" "lt" lt "")
)
(defun C:cont (/ lt)
(graphscr)
(ssget)
(setq lt "continuous")
(command "change" "p" "" "p" "lt" lt "")
)
(defun C:phantom (/ lt)
(graphscr)
(ssget)
(setq lt "phantom")
(command "change" "p" "" "p" "lt" lt "")
)
(defun C:center (/ lt)
(graphscr)
(ssget)
(setq lt "center")
(command "change" "p" "" "p" "lt" lt "")
)
Menu: paste in after ID_USERBUTTON_7
ID__8 [_Button("Change to Hidden", "ICON5991.bmp", "ICON_16_BLANK")]^C^Chidden
ID__9 [_Button("Change to Continuous", "ICON1225.bmp", "ICON_16_BLANK")]^C^Ccont
ID__10 [_Button("Change to Phantom", "ICON7156.bmp", "ICON_16_BLANK")]^C^Cphantom
ID__11 [_Button("Change to Center", "ICON0222.bmp", "ICON_16_BLANK")]^C^Ccenter
[--]
ID__12 [_Button("Windows Calculator", "ICON3706.bmp", "ICON_16_BLANK")]^C^C^P(startapp "calc")
ID__14 [_Button("Windows Wordpad", "ICON1637.bmp", "ICON_16_BLANK")]^C^C^P(startapp "write")
When you remove your change colour menu and reload the edited one, it will provide the extra buttons for the additional functions then you can do your own bitmaps for the buttons.
It is set for 4 basic linetypes, windows calculator and wordpad. I find it handy to have them at a button click.
Haggis