Author Topic: Vport Object Reactor  (Read 2596 times)

0 Members and 1 Guest are viewing this topic.

Marco Jacinto

  • Newt
  • Posts: 47
Vport Object Reactor
« on: October 04, 2007, 10:48:51 AM »
Hi all,
I'm triying to watch a viewport modification, what I want is whenever the Vport is modified if the vport is locked change the color to bylayer, if it's not, then change it to cyan (an idea from this forum BTW).

I want a reactor cause a have a combobox and a button in OpenDCL in which I want to reflect this change, but I haven't found a way to know when the object modofication is finished.

I'm using an object reactor for the modified event, and inside this a command reactor, but the problem arises when you change the vport in the properties pallete, which doesn't trigger a command reactor, and also have a lisp wich toggle the display status fur the current vport.

Any one have a clue, how can I solve this???

Code: [Select]
(SETQ ssvp
       (SSGET "X"
      '((0 . "VIEWPORT") (-4 . ">") (69 . 1))
       )
)

(REPEAT (SETQ ct (SSLENGTH ssvp))
  (SETQ objlst (CONS (VLAX-ENAME->VLA-OBJECT (SSNAME ssvp (SETQ ct (1- ct))))
     objlst
       )
  )
)

(SETQ VportLckReactor
       (VLR-OBJECT-REACTOR
objlst
"Vport Locked Reactor"
'((:VLR-MODIFIED . VportisModified))
       )
)

(DEFUN VportisModified (notifier-object reactor-object parameter-list /)
  (IF (= tmpReaccmdr nil)
    (SETQ tmpReaccmdr
   (VLR-COMMAND-REACTOR
     nil
     '((:VLR-COMMANDENDED . Vlocked))
   )
    )
  )
  (SETQ reactorinfo notifier-object)
)

(DEFUN Vlocked (owner lst)
  (IF tmpReaccmdr
    (PROGN
      (VLR-REMOVE tmpReaccmdr)
      (SETQ tmpReaccmdr nil)
    )
  )
  (VLR-REMOVE VportLckReactor)
  (IF (= (VLA-GET-DISPLAYLOCKED reactorinfo) :VLAX-TRUE)
    (VLA-PUT-COLOR reactorinfo ACBYLAYER)
    (VLA-PUT-COLOR reactorinfo ACCYAN)
  )
  (VLR-ADD VportLckReactor)
  (SETQ reactorinfo nil)
)

I'm using ACAD 2006...

Saludos
Marco jacinto

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Vport Object Reactor
« Reply #1 on: October 04, 2007, 10:59:26 AM »
You're code works Marco, you just don't see it until you regen.  It won't show the correct color unless you do a regen in command, as I tried (vla-Update VpObj) and (vla-Regen ActiveDoc) and neither updated the color, but if you use command regen it will show the correct color.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Marco Jacinto

  • Newt
  • Posts: 47
Re: Vport Object Reactor
« Reply #2 on: October 04, 2007, 03:44:16 PM »
Thx Tim, this was so easy that couln't see the solution...

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Vport Object Reactor
« Reply #3 on: October 04, 2007, 03:45:11 PM »
Thx Tim, this was so easy that couln't see the solution...

Happens all the time.  :wink:  You're welcome Marco.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Marco Jacinto

  • Newt
  • Posts: 47
Re: Vport Object Reactor
« Reply #4 on: October 06, 2007, 12:56:56 PM »
Tim, I thought that  have solved my problem, but it actually is not, because the modified event doen't actually modify the Vport, what actually does the change in the color is the next command issued, because there is a command Reactor available, which does't care about the command name that fires it.

So I'm again in the same point...I've already search through the code Luis posted, but haven't find something that can help, maybe I didn't watched carefully.

Saludos
Marco Jacinto

LE

  • Guest
Re: Vport Object Reactor
« Reply #5 on: October 06, 2007, 01:29:05 PM »
Tim, I thought that  have solved my problem, but it actually is not, because the modified event doen't actually modify the Vport, what actually does the change in the color is the next command issued, because there is a command Reactor available, which does't care about the command name that fires it.

So I'm again in the same point...I've already search through the code Luis posted, but haven't find something that can help, maybe I didn't watched carefully.

Saludos
Marco Jacinto

Marco;

No se si encontraste este ejemplo:

http://www.theswamp.org/index.php?topic=9441.msg137293#msg137293

En el puedes manipular los viewports, remueve placeview [(wcmatch (strcase (car params)) "PLACEVIEW")
] y prueba si te puede servir - solo convierte la lista de enames a vla-object y modifica los/el viewport(s)  :)



Edit:
Marco,

Creo que no revise ese ejemplo que puse arriba, voy a tratar de ver si lo puedo modificar - tengo ya un buen rato de no meterme en lisp o reactores.... si tengo algo, lo subo aqui.

« Last Edit: October 06, 2007, 02:01:06 PM by Luis Esquivel »

Marco Jacinto

  • Newt
  • Posts: 47
Re: Vport Object Reactor
« Reply #6 on: October 06, 2007, 02:18:48 PM »
Gracias Luis,

Luis el codigo que me seņalas, me es util al momento de agregar el vport, pero no al modificarlo.

El problema que tengo, es que el reactor que se ejecuta al modificar el Vport, no me permite modificar el mismo vport, ya que me indica "el objeto fue el que notifico al reactor." Trate usando commandended, pero este metodo no se ejecuta al cambiar el estado del vport mediante la paleta de propiedades.

He pensado colocar un reactor que se ejecute al cambiar un diccionario, en el cual colocaria el nombre del vport modificado. El agregar el vport al diccionario lo ejecutaria en la funcion de regreso a la modificacion de vport, con lo cual pienso no habria problema en modificar desde ahi el vport.

Que opinas, es mucha vuelta???

Saludos amigo
Marco Jacinto

LE

  • Guest
Re: Vport Object Reactor
« Reply #7 on: October 06, 2007, 02:56:38 PM »
Haber, prueba con esto, le falta cuando se llama a PLACEVIEW (que es un comando interno - lo removi tal como esta en el link que te di, tu deberas de colocarlo de nuevo) - espero te sirva:

Code: [Select]
;; by default turn the ability ON
(if (or (eq (getenv "RunPlaceViewLayer") nil)
        (eq (getenv "RunPlaceViewLayer") ""))
  (setenv "RunPlaceViewLayer" "1"))

(if (SETQ ssvp (SSGET "X" '((0 . "VIEWPORT") (-4 . ">") (69 . 1))))
  (REPEAT (SETQ ct (SSLENGTH ssvp))
    (SETQ objlst (CONS (VLAX-ENAME->VLA-OBJECT (SSNAME ssvp (SETQ ct (1- ct)))) objlst))))

(defun reactor-editor  (reactor params)
  (if (eq (getenv "RunPlaceViewLayer") "1")
    (progn
      (if (not (wcmatch
                 (getvar "cmdnames")
                 "UNDO,U,REDO,OOPS,STYLE,COPYCLIP,COPYBASE,CUTCLIP"))
        (progn
          (if objlst
            (progn (if posible_viewport_enames
                     (setq objlst
                            (append
                              objlst
                              (mapcar 'vlax-ename->vla-object posible_viewport_enames))))
                   (mapcar '(lambda (vp)
                              (IF (and (not (vlax-erased-p vp))
                                       (= (VLA-GET-DISPLAYLOCKED vp) :VLAX-TRUE))
                                (VLA-PUT-COLOR vp ACBYLAYER)
                                (if (not (vlax-erased-p vp))
                                  (VLA-PUT-COLOR vp ACCYAN))))
                           objlst)
                   (setq posible_viewport_enames nil)))))
      (setq posible_viewport_enames nil))))

(defun acdb-objectappended  (reactor params)
  (if
    (and
      (eq (getenv "RunPlaceViewLayer") "1")
      (not
        (wcmatch
          (getvar "cmdnames")
          "UNDO,U,REDO,OOPS,STYLE,COPYCLIP,COPYBASE,CUTCLIP,NEW,QNEW,OPEN,*LAYOUT*,MOVE,COPY,*STRETCH*")))
     (cond ((and params
                 (entget (cadr params))
                 (eq (cdadr (entget (cadr params))) "VIEWPORT")
                 (not (vl-position (cadr params) posible_viewport_enames)))
            (setq posible_viewport_enames (cons (cadr params) posible_viewport_enames))))))

(if (not dwiz_editor_reactor)
  (setq dwiz_editor_reactor
         (vlr-set-notification
           (vlr-editor-reactor
             "editor"
             '((:vlr-commandended . reactor-editor)
               (:vlr-commandcancelled . reactor-editor)))
           'active-document-only)))

(if (not dwiz_acdb_reactor)
  (setq dwiz_acdb_reactor
         (vlr-set-notification
           (vlr-acdb-reactor
             "acdb"
             '((:vlr-objectappended . acdb-objectappended)))
           'active-document-only)))

(princ)

LE

  • Guest
Re: Vport Object Reactor
« Reply #8 on: October 06, 2007, 03:22:37 PM »
Acerca de monitorear mediante la paleta de propiedades, yo usaba en reactorswiz una funcion que revisaba las variables: AUPREC,AUNITS,LUNITS

Dentro de el evento :vlr-sysvarchanged - pero termine por simplemente eliminarlo, por que me causo muchos problemas ya que ese evento se dispara sin control.... recuerda que los reactores de visual lisp asi como en arx no se puede hacer todo.... tienen limitaciones - por eso estos cuates usan en los field's que solo cuando se llama a regen se actualizen - asi se evitan problemas.


Suerte!