Jump to content

change color temporarily


jim78b

Recommended Posts

Thank you Grrr :thumbsup:

 

An alternative could be to use mapcar with two separate argument lists, i.e.:

(setq obj (vlax-ename->vla-object (ssname sel (setq idx (1- idx))))
     ls1 (cons obj ls1)
     ls2 (cons (vla-get-color obj) ls2)
)

Then:

(mapcar 'vla-put-color ls1 ls2)

 

Thats right, now I remember! I might need revise again your mapcar & lambda tutorial, incase I forgot something.

I did a big progress from there, the only problem is that very very careful reading is required. :D

 

BTW the recent pause discovery inspired me to write some simple subfunction:

; Example: (PromptPause "\nPaused, press any key to continue.")
(defun PromptPause ( msg )
(and (= 'STR (type msg)) (princ msg) (vl-catch-all-apply 'grread) )
)

(and
(setq e (car (entsel "\nSelect object: ")))
(setq o (vlax-ename->vla-object e))
(setq c (vla-get-Color o))
(not (vla-put-Color o 1))
(PromptPause "\nPaused, press any key to continue.")
(not (vla-put-Color o c))
)

As I remember that once someone asked "How to pause a code?", but I think the answers he got were with using the get*** functions.

Link to comment
Share on other sites

  • Replies 23
  • Created
  • Last Reply

Top Posters In This Topic

  • jim78b

    13

  • Grrr

    4

  • ReMark

    3

  • RobDraw

    2

Top Posters In This Topic

Posted Images

Sorry for bumping this thread, but just found this code from LM (from theswamp) :

(defun c:test ( / col idx sel )
(if
	(and
		(setq sel (ssget "_:L"))
		(setq col (acad_truecolordlg 1))
	)
	(repeat (setq idx (sslength sel))
		(entmod (append (entget (ssname sel (setq idx (1- idx)))) col))
	)
)
(princ)
)

So I thought if he "merged" it with his suggestion here, the end result would be more "complete":

(defun c:tempcolor ( / col idx lst obj sel )
(if 
	(and
		(setq sel (ssget "_:L"))
		(setq col (acad_truecolordlg 1))
	)
	(progn
		(repeat (setq idx (sslength sel))
			(setq obj (vlax-ename->vla-object (ssname sel (setq idx (1- idx))))
				lst (cons (list obj (vla-get-color obj)) lst)
			)
			(vla-put-color obj (cdar col))
		)
		(princ "\nPress any key to exit...")
		(vl-catch-all-apply 'grread)
		(foreach itm lst (apply 'vla-put-color itm))
	)
)
(princ)
)
(vl-load-com) (princ)

Link to comment
Share on other sites

  • 1 year later...

Is it possible to make the color change after i start a command ...example...i make move command select a object or a block and them will color .color that i choosed in my lisp...?

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