×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Changing entity color by pressing 1 button

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

RE: Changing entity color by pressing 1 button

Easiest way would be to just change the layer?  With different layers being different colors.  Not just 1- button, but it is one menu-bar.

RE: Changing entity color by pressing 1 button

(OP)
Thanks JStephen,

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

This is from the Afralisp site

(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

marisse,

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

(OP)
Thanks Borgunit & Exxit,

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

(OP)
i guess i'm looking for an autolisp regarding changing properties. U can change color, linetype, layer, ltscale, lineweight and thickness.

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

In my opinion, the easiest way, without requiring anything additional is to select your object, then go up to the drop down for colors on the Properties Toolbar, and select the color you want.  It takes three left mouse click (select object, select dropdown to open it, and select color), but the method you are seeking would take a mouse click and a keystroke, so not much different.
This also works for changing a layer, linetype, lineweight, dimension style, etc.


RE: Changing entity color by pressing 1 button

(OP)
TY CDH,

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

marisse,

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

(OP)
know what haggis?  it works wonderful. Thanks a lot!

Thank you.

RE: Changing entity color by pressing 1 button

I guess that's what's great about AutoCAD, you can customize it your way!  Personally, I don't like to use the keyboard for anything other than typing notes and such.  The keys most used by me are space-bar and delete.
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

marisse,

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources