Jump to content

Recommended Posts

Posted

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;

Posted (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 by Steven P
Posted

WHAT DO YOU MEAN FOR PERMANENTLY?

I need macro because i use tool palette buttons.

Posted

is possible change color permanently to all object in my drawing enclosed blocks until i edit them?

Posted

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

 

  • Thanks 1
Posted
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

  • Thanks 1
Posted

and for buttons this should work as the command srtring

 

(command "chprop" (car (entsel "Select")) "" "C" "ByBlock" "")

 

 

I think

  • Thanks 1
Posted

Then i want use this for select the same entities and create a block is possible ? Thanks a lot 

Posted

for example why this macro don't work??

 

^C^C_change \;p;

Posted

i need a macro that first select entities then change color to byblock and the create a block as usual

Posted
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)
)

 

  • Thanks 1
Posted

I appreciate your help very much . However i want to learn because some macro can not work ...

Posted

Macros can use lisp commands ^c^c(command "chprop" (ssget '((0 . "INSERT"))) "" "C" "ByBlock" "")

  • Like 2
  • Thanks 1
Posted

Thanks a lot i aveva lot of difficult to learn...and is possible then assign  color 200 ti the block ?then is perfect 😊😊

  • Like 1
Posted
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.

Posted

^C^C_select \_change _p; _p _c byblock;;^C^C_block;\\;_o;

in this the block deleted!

Posted

ok undestrand! but i want macro for put them in toolpalettes buttons

Posted

sorry can you modify your lisp so i can assign a name to the block?

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...