jim78b Posted September 12, 2022 Posted September 12, 2022 hello i want to do a macro that change after selection the colors of elements but don't work. ^C^C_chprop;p;c;ByBlock; Quote
Steven P Posted September 12, 2022 Posted September 12, 2022 (edited) Is that a permanent change or a temporary change? This will change a single selection permanently (defun c:chcol ( / MyEnt ) (setq MyEnt (car (entsel "Select"))) (command "chprop" MyEnt "" "C" "ByBlock" "") ) If you want to select many items then you can change the '(car (entsel ...))' part to a selection set (ssget) (defun c:chcol ( / MySS ) (setq MySS (ssget)) (command "chprop" MySS "" "C" "ByBlock" "") ) Edited September 12, 2022 by Steven P Quote
jim78b Posted September 12, 2022 Author Posted September 12, 2022 WHAT DO YOU MEAN FOR PERMANENTLY? I need macro because i use tool palette buttons. Quote
jim78b Posted September 12, 2022 Author Posted September 12, 2022 is possible change color permanently to all object in my drawing enclosed blocks until i edit them? Quote
SLW210 Posted September 12, 2022 Posted September 12, 2022 I have moved your thread to the https://www.cadtutor.net/forum/forum/56-the-cui-hatches-linetypes-scripts-macros/ Forum. Quote
Steven P Posted September 12, 2022 Posted September 12, 2022 If t is a command from AutoCAD this is relatively to copy to a LISP, follow the above example as you need in future ( - tells the LISP you are about to do something command - tells the LISP that you are using a command "chprop" - tells the LISP the command name, here also in " " since you are entering text and not a variable (change this to whatever command you want to use) MyEnt - tells the LISP to enter a variable into the command (no " "), go to CAD command line and work through the command, copying what you type there into the LISP "" - puts in an enter / escape / space / end of selection, just as you would type into the command line "C" - tells the LISP the next value to pass to the command you are running, here "C" for colour "ByBlock" - as above, the next value to use "" - as above an enter / space / escape to end the selection, or here to end the comamnd ) - tells the LISP you have finished telling it to do something In between 'command' and the final ')' all you need to do is type into the LISP exactly what you type into the command line with " " either side of any text (but not if you are using a variable) .. hope this helps you out and can work it out next time 1 Quote
Steven P Posted September 12, 2022 Posted September 12, 2022 18 minutes ago, jim78b said: WHAT DO YOU MEAN FOR PERMANENTLY? I need macro because i use tool palette buttons. It is possible to change an entity colour temporarily for example if you're doing other stuff and want to highlight what you selected, then go back after, or to make a normal change 1 Quote
Steven P Posted September 12, 2022 Posted September 12, 2022 and for buttons this should work as the command srtring (command "chprop" (car (entsel "Select")) "" "C" "ByBlock" "") I think 1 Quote
jim78b Posted September 12, 2022 Author Posted September 12, 2022 Then i want use this for select the same entities and create a block is possible ? Thanks a lot Quote
jim78b Posted September 12, 2022 Author Posted September 12, 2022 for example why this macro don't work?? ^C^C_change \;p; Quote
jim78b Posted September 12, 2022 Author Posted September 12, 2022 i need a macro that first select entities then change color to byblock and the create a block as usual Quote
Steven P Posted September 12, 2022 Posted September 12, 2022 3 hours ago, jim78b said: for example why this macro don't work?? ^C^C_change \;p; That's for someone else to explain I tend to keep my CAD as simple as possible so I can get a new or different computer and be working again as quick as possible and without spending hours creating new buttons and more detailed customisations, can't help you with that one If what I suggested above works go with that till someone else can answer for you, and then what is below will work. To select entities, use the ssget option and perhaps an internet search to give you https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-create-block-insert-that-block/td-p/5431779 Modify that might give you this: (defun c:chcol ( / MySS ) (setq MySS (ssget)) (command "chprop" MySS "" "C" "ByBlock" "") (c:blk MySS) ) ;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-create-block-insert-that-block/td-p/5431779 ;;(defun c:blk (/ selectionset insertionpoint number Blockname) (defun c:blk (selectionset / insertionpoint number Blockname) ;; (if (and (setq selectionset (ssget "_:L")) (setq insertionpoint (getpoint "\n Specify Block Insertion Point :")) ;; ) (progn (setq number 1 Blockname (strcat "MyBlock" (itoa number)) ) (while (tblsearch "BLOCK" Blockname) (setq Blockname (strcat "MyBlock" (itoa (setq number (1+ number)))) ) ) (command "_.-Block" Blockname insertionpoint selectionset "") (command "_.-insert" Blockname insertionpoint "" "" "") ) (princ) ) (princ) ) 1 Quote
jim78b Posted September 12, 2022 Author Posted September 12, 2022 I appreciate your help very much . However i want to learn because some macro can not work ... Quote
BIGAL Posted September 13, 2022 Posted September 13, 2022 Macros can use lisp commands ^c^c(command "chprop" (ssget '((0 . "INSERT"))) "" "C" "ByBlock" "") 2 1 Quote
jim78b Posted September 13, 2022 Author Posted September 13, 2022 Thanks a lot i aveva lot of difficult to learn...and is possible then assign color 200 ti the block ?then is perfect 1 Quote
jim78b Posted September 13, 2022 Author Posted September 13, 2022 Can you explain this code please ? Quote
Steven P Posted September 13, 2022 Posted September 13, 2022 2 hours ago, jim78b said: Thanks a lot i aveva lot of difficult to learn...and is possible then assign color 200 ti the block ?then is perfect Have a guess how you would change "ByBlock" colour to colour "200" - it might work. Quote
jim78b Posted September 13, 2022 Author Posted September 13, 2022 ^C^C_select \_change _p; _p _c byblock;;^C^C_block;\\;_o; in this the block deleted! Quote
jim78b Posted September 13, 2022 Author Posted September 13, 2022 ok undestrand! but i want macro for put them in toolpalettes buttons Quote
jim78b Posted September 13, 2022 Author Posted September 13, 2022 sorry can you modify your lisp so i can assign a name to the block? Quote
Recommended Posts
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.