Jump to content

help with reactor


Coder

Recommended Posts

Hello guys .

 

I need to use a reactor to re write the text string as it was inserted with a routine if any user changed this text string .

 

This is my codes and it doesn't work , can anyone help me please ?

 

(defun c:write (/ pnt txtobj)
 (vl-load-com)
    (setq pnt (getpoint "\n text location :"))
     (setq txtobj (entmakex (list '(0 . "TEXT")
                             (cons 10 pnt)
                             (cons 11 pnt)
                             (cons 40 1.0)
                             (cons 1 "Text example")
                       )
             )
     )
     (setq *obj* (vlr-object-reactor
                   (list (vlax-ename->vla-object txtobj))
                   "example-1"
                   '((:vlr-modified . modifytext))
                 )
     )
 (princ)
)

(defun modifytext (noifier reactor paparms /)
 (vla-put-textstring (vlr-data reactor) "Text example")
)

Link to comment
Share on other sites

Your code is not working because (vlr-data reactor) in the case is the string "example-1", it doesn't mean anything.

You have to put another text object as vlr-data, cad don't let you take reactor's owner (as active object) and reactor's data (as passive object) the same object.

You try this:

(defun c:write (/ pnt txtobj)
 (vl-load-com)
    (setq pnt (getpoint "\n text location :"))
     (setq txtobj (entmakex (list '(0 . "TEXT")
                             (cons 10 pnt)
                             (cons 11 pnt)
                             (cons 40 1.0)
                             (cons 1 "Text example")
                       )
             )
     )
    (setq txtobj1 (car (entsel "\nChoose another text:")))
    (setq *obj* (vlr-object-reactor
                   (list (vlax-ename->vla-object txtobj)) 
	    (list (vlax-ename->vla-object txtobj1))
                    '((:vlr-modified . modifytext))
                 )
     )
 (princ)
)

(defun modifytext (notifier reactor paparms /)
 (vla-put-textstring (car (vlr-data reactor)) "Text example rewrote")
)

Link to comment
Share on other sites

What Object Type is reactor, and what does (vlr-data reactor) return?

 

thank you for reply .

I think vlr-data is the data associated with a reactor . i don't know more .

Link to comment
Share on other sites

Your code is not working because (vlr-data reactor) in the case is the string "example-1", it doesn't mean anything.

You have to put another text object as vlr-data, cad don't let you take reactor's owner (as active object) and reactor's data (as passive object) the same object.

You try this:

(defun c:write (/ pnt txtobj)
 (vl-load-com)
    (setq pnt (getpoint "\n text location :"))
     (setq txtobj (entmakex (list '(0 . "TEXT")
                             (cons 10 pnt)
                             (cons 11 pnt)
                             (cons 40 1.0)
                             (cons 1 "Text example")
                       )
             )
     )
    (setq txtobj1 (car (entsel "\nChoose another text:")))
    (setq *obj* (vlr-object-reactor
                   (list (vlax-ename->vla-object txtobj)) 
	    (list (vlax-ename->vla-object txtobj1))
                    '((:vlr-modified . modifytext))
                 )
     )
 (princ)
)

(defun modifytext (notifier reactor paparms /)
 (vla-put-textstring (car (vlr-data reactor)) "Text example rewrote")
)

 

thank you so much for explanations and modifying codes , very helpful reply many thanks .:thumbsup:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...