Jump to content

change properties with macro help


jim78b

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...