TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: alloy mold design on June 16, 2022, 10:09:15 AM
-
Hi,I want to change the objects colour and line type, but I can not change the colour ID when I want. What is this problem? Would you help me? Thank you!
(defun C:wg_dd
(/ na sobject clo
) )
(command "chprop" sobject
"" "c" 6 "LT" "Divide2" "") )
(command "chprop" sobject
"" "c" na
"LT" "Divide2" "")
)
)
)
)
-
It worked for me. What error do you get?
-
Your lisp doesn't really make sense to me. are col and na set in another lisp?
This might be better flow.
(defun C:WG_dd
(/ sobject
) (if (setq sobject
(ssget)) ;if something selected change prop (command "chprop" sobject
"" "c" 6 "LT" "Divide2" "") (progn ;else 2nd try at selection ? (command "chprop" sobject
"" "c" #
"LT" "Divide2" "") ;replace # with color number )
)
)
-
I would take a slightly different way
(defun chcx (x / sobject)
(if (setq sobject (entsel "\nPick a object ")) ;if something selected change prop
(command "chprop" sobject "" "c" x "LT" "Divide2" "")
)
(princ)
)
To run type (chcx 6) on command line, yes could do a select color also or make lots of defuns CHC6 CHC4 and so on.
-
Thanks all. only one lisp works. The fuction I want to get is that before or after something selected,I can change the colour ID or not.
I would take a slightly different way
(defun chcx (x / sobject)
(if (setq sobject (entesel "\nPick a object ")) ;if something selected change prop
(command "chprop" sobject "" "c" x "LT" "Divide2" "")
)
(princ)
)
To run type (chcx 6) on command line, yes could do a select color also or make lots of defuns CHC6 CHC4 and so on.
-
Sorry there was a typo it should have been entsel.
A few defuns if you want to go that way.
(defun c:ccc6 ( / )
(command "chprop" (entsel "\nPick a object ") "" "c" 6 "")
)
(defun c:ccc5 ( / )
(command "chprop" (entsel "\nPick a object ") "" "c" 5 "")
)
(defun c:ccc4 ( / )
(command "chprop" (entsel "\nPick a object ") "" "c" 4 "")
)
-
Thanks BIGAL. This is another one I wrote.But I want to improve.
(defun C:wg_dd
(/ sobject clo
)
(setq clo
(getint));here,I want to select something or not. );
(command "chprop" sobject
"" "c" clo
"LT" "Divide2" "") )
Sorry there was a typo it should have been entsel.
A few defuns if you want to go that way.
(defun c:ccc6 ( / )
(command "chprop" (entsel "\nPick a object ") "" "c" 6 "")
)
(defun c:ccc5 ( / )
(command "chprop" (entsel "\nPick a object ") "" "c" 5 "")
)
(defun c:ccc4 ( / )
(command "chprop" (entsel "\nPick a object ") "" "c" 4 "")
)
-
Have a look at this (setq col (acad_colordlg 1)) just paste to command line.