Object Reactor

Discussion in 'AutoCAD' started by Rudy Tovar, Nov 15, 2004.

  1. Rudy Tovar

    Rudy Tovar Guest

    I thought, I'd save some reading or studying time.

    I know how to apply an object reactor, but how about making persistant when
    the file is closed and reopend, then monitoring ERASE to deactivate reactor.

    Following the docs, and I've been busy with other things other than
    reactors.

    Here's what I've been playing with...

    (vl-load-com)

    (setq acadDocument (vla-get-ActiveDocument (vlax-get-acad-object)))

    (setq mSpace (vla-get-ModelSpace acadDocument))

    (setq mycircle (vla-addCircle mSpace (vlax-3d-point '(3.0 3.0 0.0)) 2.0))

    (setq circleReactor (vlr-object-reactor (list myCircle)
    "Circle Reactor" '(:)vlr-modified . print-radius))))

    (vlr-owner-add circleReactor mycircle)



    (defun print-radius (notifier-object reactor-object parameter-list)
    (vl-load-com)
    (cond
    (
    (vlax-property-available-p
    notifier-object
    "Radius"
    )
    (princ "The radius is ")
    (princ (vla-get-radius notifier-object))
    )
    )
    )


    (setq circleReactor (vlr-object-reactor
    (list myCircle) "Radius size" '(:)vlr-modified . print-radius))))

    ;(vlr-pers circleReactor)

    (defun CleanReactors ()
    (mapcar 'vlr-remove-all
    ':)VLR-AcDb-reactor
    :VLR-Editor-reactor
    :VLR-Linker-reactor
    :VLR-Object-reactor
    )
    )
    )
     
    Rudy Tovar, Nov 15, 2004
    #1
  2. Rudy Tovar

    SpeedCAD Guest

    Hi...

    When you make a persistent, is necesary that it is loaded the callback function. In this case the print-radius function...

    What do you want???

    Un saludo de SpeedCAD... :D
    CHILE
    FORO: http://www.hispacad.com
     
    SpeedCAD, Nov 16, 2004
    #2
  3. Rudy Tovar

    Rudy Tovar Guest

    Example of composition for either?
     
    Rudy Tovar, Nov 16, 2004
    #3
  4. Rudy Tovar

    LUCAS Guest

    ;;Attention--By SpeedCad
    ;;When you make a persistent, is necesary that it is loaded
    ;;the callback function. In this case the print-radius function...
    (vl-load-com)
    (defun C:TT (/ ACADDOCUMENT MSPACE MYCIRCLE)
    (setq ACADDOCUMENT (vla-get-activedocument (vlax-get-acad-object)))
    (setq MSPACE (vla-get-modelspace ACADDOCUMENT))
    (setq
    MYCIRCLE (vla-addcircle
    MSPACE
    (vlax-3d-point (getpoint "\nCenterpoint: "))
    2.0
    )
    )
    (vlr-pers (vlr-object-reactor
    (list MYCIRCLE)
    "Circle Reactor"
    '(:)vlr-modified . PRINT-RADIUS))
    )
    )
    (mapcar
    'vlax-release-object
    (list ACADDOCUMENT MSPACE)
    )
    (princ)
    )

    (defun PRINT-RADIUS (NOTIFIER-OBJECT REACTOR-OBJECT PARAMETER-LIST)
    (vl-load-com)
    (cond
    ((and (not (vlax-erased-p NOTIFIER-OBJECT))
    (vlax-property-available-p
    NOTIFIER-OBJECT
    "Radius"
    )
    )
    (princ "\nThe radius is ")
    (princ (vla-get-radius NOTIFIER-OBJECT))
    (princ "\n")
    )
    )
    )
     
    LUCAS, Nov 16, 2004
    #4
  5. Rudy Tovar

    Rudy Tovar Guest

    Thank you Lucas...I haven't had the time to test it out, so give me a few
    hours...in the mean time....Does this address the issue that if a drawing is
    closed, and reopened, that the object will remain persistant?

    Also, does this run clean should the object be erased?
     
    Rudy Tovar, Nov 16, 2004
    #5
  6. Rudy Tovar

    LUCAS Guest

    Does this address the issue that if a drawing is closed, and reopened, that
    the object will remain persistant?

    ->Yes(loaded the callback function. In this case the print-radius
    function...)


    Also, does this run clean should the object be erased?

    ->Yes
     
    LUCAS, Nov 17, 2004
    #6
  7. Rudy Tovar

    LUCAS Guest

    ;;fix for undo---earse
    (defun PRINT-RADIUS (NOTIFIER-OBJECT REACTOR-OBJECT PARAMETER-LIST)
    (vl-load-com)
    (cond
    ((and (not (vlax-erased-p NOTIFIER-OBJECT))
    (vlax-read-enabled-p ;fix for undo---earse
    NOTIFIER-OBJECT
    )
    (vlax-property-available-p
    NOTIFIER-OBJECT
    "Radius"
    )
    )
    (princ "\nThe radius is ")
    (princ (vla-get-radius NOTIFIER-OBJECT))
    (princ "\n")
    )
    )
    )
     
    LUCAS, Nov 17, 2004
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.