Author Topic: Error in reactor  (Read 1872 times)

0 Members and 1 Guest are viewing this topic.

Patrick_35

  • Guest
Error in reactor
« on: November 04, 2008, 05:43:04 AM »
Hello

I do not understand why when I change the value by consulting a reactor, it does not work and I have an error message, whereas if I do it manually, it works correctly?

With the reactor
Code: [Select]
(defun reacteur_ajouter_cdc(rea data / ent pro)
  (and (setq ent (vlax-ename->vla-object (cadr data)))
(eq (vla-get-objectname ent) "AcDbBlockReference")
(eq (vla-get-isdynamicblock ent) :vlax-true)
(member (strcase (vla-get-effectivename ent) T)
'( "0-lf-reseaux-cfa-casse"
"0-lf-reseaux-cfa-coude"
"0-lf-reseaux-cfa-droit1"
"0-lf-reseaux-cfa-droit2"
"0-lf-reseaux-cfa-reduc"
"0-lf-reseaux-cfa-te-croix"
)
)
Patrick_Taille_Cdc
    (foreach pro (vlax-invoke ent 'getdynamicblockproperties)
      (if (eq (vla-get-propertyname pro) "Consultation")
(if (member (itoa Patrick_Taille_Cdc) (vlax-get pro 'allowedvalues))
  (vla-put-value pro (itoa Patrick_Taille_Cdc))
  (princ "\nLa taille du Chemin de cābles ne correspond pas aux paramčtres de Consultation.")
)
      )
    )
  )
  (princ)
)

(defun c:cdc(/)
  (initget 3)
  (and (setq Patrick_Taille_Cdc (getint "\nIndiquez la taille du chemin de cābles : "))
(not Patrick_Ajouter_Cdc)
    (setq Patrick_Ajouter_Cdc (vlr-acdb-reactor nil (list (cons :vlr-objectappended (function reacteur_ajouter_cdc)))))
  )
  (princ)
)

Manually
Code: [Select]
(setq ent (vlax-ename->vla-object (car (entsel))))
(setq pro (nth 6 (vlax-invoke ent 'getdynamicblockproperties)))
(vla-put-value pro (itoa Patrick_Taille_Cdc))

Thanks

@+

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Error in reactor
« Reply #1 on: November 04, 2008, 11:08:25 AM »
It could be that the object is still open for write by the editor.  If that is the case, then you have to add another reactor, a command ended reactor to do all the work.  The first reactor will create the second one, and the second one will do the work, and clean up itself, so that you only have one reactor floating around in the drawing.  This might be of some help [ http://www.theswamp.org/index.php?topic=15557.0 ].
Tim

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

Please think about donating if this post helped you.

Patrick_35

  • Guest
Re: Error in reactor
« Reply #2 on: November 04, 2008, 12:06:51 PM »
Thanks T.Willey

I had not thought of.

It's a pity for multiple copies, but it's better than nothing.

Code: [Select]
(defun reacteur_ajouter_cdc(rea data / ent pro)
  (and (setq ent (vlax-ename->vla-object (cadr data)))
(eq (vla-get-objectname ent) "AcDbBlockReference")
(eq (vla-get-isdynamicblock ent) :vlax-true)
(member (strcase (vla-get-effectivename ent) T)
'( "0-lf-reseaux-cfa-casse"
"0-lf-reseaux-cfa-coude"
"0-lf-reseaux-cfa-droit1"
"0-lf-reseaux-cfa-droit2"
"0-lf-reseaux-cfa-reduc"
"0-lf-reseaux-cfa-te-croix"
)
)
Patrick_Taille_Cdc
    (foreach pro (vlax-invoke ent 'getdynamicblockproperties)
      (if (eq (vla-get-propertyname pro) "Consultation")
(if (member (itoa Patrick_Taille_Cdc) (vlax-get pro 'allowedvalues))
  (setq liste_object_reacteur_cdc (cons pro liste_object_reacteur_cdc))
;   (vla-put-value pro (itoa Patrick_Taille_Cdc))
  (princ "\nLa taille du Chemin de cābles ne correspond pas aux paramčtres de Consultation.")
)
      )
    )
  )
  (princ)
)

(defun debut_command_cdc(rea cde / pro)
  (setq liste_object_reacteur_cdc nil)
)

(defun arret_command_cdc(rea cde)
  (and liste_object_reacteur_cdc
    (foreach pro liste_object_reacteur_cdc
      (vla-put-value pro (itoa Patrick_Taille_Cdc))
    )
  )
  (setq liste_object_reacteur_cdc nil)
  (princ)
)

(defun c:cdc(/)
  (initget 3)
  (and (setq Patrick_Taille_Cdc (getint "\nIndiquez la taille du chemin de cābles : "))
(not Patrick_Ajouter_Cdc)
    (setq Patrick_Ajouter_Cdc (vlr-acdb-reactor nil (list (cons :vlr-objectappended (function reacteur_ajouter_cdc)))))
    (vlr-editor-reactor nil (list (cons :vlr-commandWillStart (function debut_command_cdc))
  (cons :vlr-commandcancelled (function arret_command_cdc))
  (cons :vlr-commandfailed    (function arret_command_cdc))
  (cons :vlr-commandEnded     (function arret_command_cdc))
    )
    )
  )
  (princ)
)

@+

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Error in reactor
« Reply #3 on: November 04, 2008, 12:19:54 PM »
You're welcome Patrick.  It shouldn't be too bad for multiple copies since you only change them after the whole command is finished.
Tim

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

Please think about donating if this post helped you.

Patrick_35

  • Guest
Re: Error in reactor
« Reply #4 on: November 04, 2008, 03:32:30 PM »
Yes, but it is a pity not to see the changes during for copies

@+