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

reactors and objects with fields

4 REPLIES 4
Reply
Message 1 of 5
markruys2
486 Views, 4 Replies

reactors and objects with fields

i am trying to add a reactor, where if the object i move or copy is s a block of a certain name,

then i would like to run updatefield on the last object (being copied) or the object being moved.

any leads, examples will be greatly appreciated. commandended on copy or move

TIA

4 REPLIES 4
Message 2 of 5
dbroad
in reply to: markruys2

This is not a direct answer to your question but illustrates the process. Fields will typically update on a regen. If you trigger a regen after the object has been modified (at a commandend event for example), then the field will report the change correctly.
;;Illustration of how to use an object reactor to trigger a field update.
;;Preparation:  Draw a line and add an object field tracking the line's length
;;Load the program and choose the line.
;;Grip edit, move, or copy the line.  Watch the alerts and the field update.
(vl-load-com)
(if oreact (vlr-remove oreact)) ;remove reactor if already existing
(if creact (vlr-remove creact)) ;ditto

(setq oreact (vlr-object-reactor nil nil '((:vlr-modified . prepare)))) ;object reactor
(setq creact (vlr-command-reactor nil '((:vlr-commandended . trigger))));command reactor

(setq ob (vlr-owner-add oreact (vlax-ename->vla-object (car (entsel)))));add owner

;callback to set trigger
(defun prepare (o r l)
  (alert "prepare")
  (vlr-data-set creact t))

;;callback to trigger regen
(defun trigger (r cl)
  (if (vlr-data r)
    (progn
      (alert "trigger")
      (vla-regen(vla-get-activedocument(vlax-get-acad-object)) acallviewports)
      (vlr-data-set r nil))))
    

 

Architect, Registered NC, VA, SC, & GA.
Message 3 of 5
markruys2
in reply to: dbroad

i guess i am looking for a vla- function or a workarround of the UPDATEFIELD command,

using vla-regen is too time consuming on a large drawing, when the user is copying or moving objects

thanks

m

Message 4 of 5
dbroad
in reply to: markruys2

You should be able to modify the code  to update the field of an individual object.  I'm not sure why you would need to do it though.  No matter how large my drawings, regens are nearly instantaneous.  In the code posted, no matter how many tracked objects were changed, there would only be one regen.  Only when tracked objects were changed would the regens trigger.

 

Why do you need the field results to be up-to-date constantly?  Is this an online game of sorts?

Architect, Registered NC, VA, SC, & GA.
Message 5 of 5
markruys2
in reply to: dbroad

i use them for elevation indicator symbols, when the user copies or moves a symbol, (or grip move)

the the user should immediately see the value of the new y-coordinate, otherwise it is confusing,

thus the need for a regen at every move or copy ( and i still do not know how to do it while inside the copy

command). at initial insert i use the command UPDATEfield, which is instantaneous, a regen is not..

thanks for your interest

m

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

Post to forums  

”Boost