Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Redraw with Highlight color?

6 REPLIES 6
Reply
Message 1 of 7
mid-awe
1247 Views, 6 Replies

Redraw with Highlight color?

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.

6 REPLIES 6
Message 2 of 7
mid-awe
in reply to: mid-awe

Ok, I think I have something that'll do:
(vla-put-color (vlax-ename->vla-object (HANDENT en)) 1)
& to return to the blylayer color:
(vla-put-color (vlax-ename->vla-object (HANDENT en)) 256)
Message 3 of 7
Lee_Mac
in reply to: mid-awe

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)

 

Message 4 of 7
mid-awe
in reply to: Lee_Mac

Thanks Lee.

The "pushing & popping the DBMOD" is a new one to me. Never heard of that. I'll check it out.

Thank again.
Message 5 of 7
Lee_Mac
in reply to: mid-awe

You're most welcome as always mid-awe - its always nice to find out something new Smiley Happy

Message 6 of 7
doni49
in reply to: Lee_Mac


@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




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 7 of 7
Lee_Mac
in reply to: doni49


@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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost