Hi all,
I have need for a simple visual-aid that can change the color of model space mleaders & be visible to the user through a paperspace viewport. I don't want the change to be permenant; it's only to help the user find the mleader while working within the main function.
I tried (REDRAW (HANDENT en) 3), but the highlighting doesn't seem to be visible (dashed line @ totally different scale). And so, my mleader is set to color by layer & I was thinking that could be easily changed to-&-fro. Although if it is possible to highlight the mleader by changing it's color rather than the dashes with the redraw mode 3 then no need for rewriting any code.
Is there a sysvar or something that I can do to get an obvious color change?
Thanks for any help.
I'm not aware of your exact situation, but in general when performing an action that shouldn't modify the drawing (such as visual feedback) I would recommend storing the original colour, and resetting it afterwards so that the drawing remains unchanged.
You might also consider pushing & popping the DBMOD system variable so that the change is not registered by the drawing, e.g.:
(setq obj (vlax-ename->vla-object (handent en)) tmp (vla-get-color obj) ) (acad-push-dbmod) (vla-put-color obj acred) ;; ... Your code here ... (vla-put-color obj tmp) (acad-pop-dbmod)
You're most welcome as always mid-awe - its always nice to find out something new
@Lee_Mac wrote:.....I would recommend storing the original colour, and resetting it afterwards so that the drawing remains unchanged.......
Lee,
How do you prevent the change from being made permanent if something happens that causes the code to crash before the color is reset after the work is done?
Don Ireland
Engineering Design Technician
@doni49 wrote:
@Lee_Mac wrote:.....I would recommend storing the original colour, and resetting it afterwards so that the drawing remains unchanged.......
Lee,
How do you prevent the change from being made permanent if something happens that causes the code to crash before the color is reset after the work is done?
Hi doni,
You should include the color resetting expression (with sufficient error trapping) inside the error handler function to reset the color change if an error occurs, e.g.:
(defun c:test ( / *error* col ent obj ) (defun *error* ( msg ) (if (and (= 'int (type col)) (= 'vla-object (type obj)) ) (vla-put-color obj col) ) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\nError: " msg)) ) (princ) ) (if (setq ent (car (entsel))) (progn (setq obj (vlax-ename->vla-object ent) col (vla-get-color obj) ) (vla-put-color obj acred) (getstring "\nPress Enter to continue, press Esc to force error...") (vla-put-color obj col) ) ) (princ) ) (vl-load-com)
Note that the error trapping within the *error* function is required to account for if the user presses Esc before an object is selected and hence before the symbols 'obj' & 'col' are defined.
Lee