Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

using autocad reactor but function does not execute chprop command

6 REPLIES 6
Reply
Message 1 of 7
ddecker56
960 Views, 6 Replies

using autocad reactor but function does not execute chprop command

I started by using the function (vlr-acdb-reactor "FixLastEntity" '((:vlr-ObjectAppended . fixlastentity)))

The purpose was to have a function that would change the layer or other properties of the last created entity.

 

If I were to change the entity by using lisp to change the entities list and use entmod, Autocad would crash.

 

I then tried to use the command line. It seemed to execute the command, but the entitiy did not change.

 

If I were to copy paste the command from the lisp file to the command line, it works just fine.

 

anybody have any ideas?

 

 

Thanks

 

6 REPLIES 6
Message 2 of 7
Moshe-A
in reply to: ddecker56

Decker Hi,

 

in the callback function (of reactors) you can not use (command) function

instead you should use ActiveX functions (vlax-xxxxx)

 

Moshe

 

Message 3 of 7
ddecker56
in reply to: Moshe-A

Thanks for the input. I have reconfigured the lisp but now i am having another problem, maybe 2.

 

I start with a clean file

load the lisp

when i create an entitiy, it seems to want to execute but I get the error " VL-DATA#<VLR-AcDb-Reactor>no function definition:"

and I get the error 13 times

 

like this

Dimension text = 15'-10 5/16"#<VLR-AcDb-Reactor>no function definition: VL-DATA#<VLR-AcDb-Reactor>no function definition: VL-DATA#<VLR-AcDb-Reactor>no function definition: VL-DATA#<VLR-AcDb-Reactor>no function definition: VL-DATA#<VLR-AcDb-Reactor>no function definition: VL-DATA#<VLR-AcDb-Reactor>no function definition: VL-DATA#<VLR-AcDb-Reactor>no function definition: VL-DATA#<VLR-AcDb-Reactor>no function definition: VL-DATA#<VLR-AcDb-Reactor>no function definition: VL-DATA#<VLR-AcDb-Reactor>no function definition: VL-DATA#<VLR-AcDb-Reactor>no function definition: VL-DATA#<VLR-AcDb-Reactor>no function definition: VL-DATA#<VLR-AcDb-Reactor>no function definition: VL-DATA

 

here is a portion of the lisp...

 

;setup and initialize the reactor
;

;load reactor functions
(vl-load-com)

; remove existing reactors
(vlr-remove-all)

;setup reactor
(vlr-acdb-reactor "Entity Update" '((:vlr-objectAppended . appobjupdate)))


(defun appobjupdate (CallingReactor CommandInfo / ObjType)

; (princ (strcat "\nSymbol Name: " (vl-symbol-name (vlr-type CallingReactor)))<------even though I am using some downloaded code this fails on load
 (princ (strcat "\nReactor Data&colon; " (vl-data CallingReactor)))
 (princ (strcat "\nCallBack List: " (car (vlr-reactions CallingReactor))))
; (princ (strcat "\nEvent Reactor: " (vl-symbol-name (vlr-type CallingReactor)))<------even though I am using some downloaded code this fails on load
 (princ (strcat "\nCallBack Function: " (cdr(car (vlr-reactions CallingReactor)))))

; (setq ObjType (vlax-get-property EntName 'ObjectName))<------even though I am using some downloaded code this fails on load
 (princ (strcat "\n" ObjType))

 

what am I doing wrong???

 

Thanks

 

D

Message 4 of 7
Moshe-A
in reply to: ddecker56

 

i'm sorry i now getting what you after...

 

to change an object property right after it added to the database is a tricky proccess

 

1. define (install) a database reactor

 

2. on (mos:OnObjectAppended) callback function you only save the ename of the object just appended

    (modifing the object there will result an error cause autocad has opened it only for read)

   

    here comes the trick...define a command reactor there that get's fire as soon the command that added the object is ended

  

3. on (mos:OnCommandEnded ) callback function you can modify the object properties freely there at the end

    the command reactor is disabled and do some cleanup of global variables

 

    careful: the layer you want to move the last object should be exist before you set it to the object  

 

 

Chesrs

Moshe

 

 

 

(defun mos:OnCommandEnded (Reactor cmd^ / AcDbObject)
 (if (eq (vlr-data Reactor) "OnCommandEnded")
  (progn
   (setq AcDbObject (vlax-ename->vla-object *ename*))
   (vlax-put-property AcDbObject 'layer "my layer")
   (vlax-release-object AcDbObject)
  )
 )
  
 ; disable reactor
 (vlr-remove *cmdReactor*)
 (setq *cmdReactor* nil)
 (setq *ename* nil)
)


(defun mos:OnObjectAppended (Reactor data^)
 (setq *ename* (cadr data^))

 ; install command reactor
 (if (not *cmdReactor*)
  (setq *cmdReactor* (vlr-command-reactor "OnCommandEnded" '((:vlr-commandEnded . mos:OnCommandEnded))))
 )
)

       

; install database reactor
(if (not *acdbReactor*)
 (setq *acdbReactor* (vlr-acdb-reactor "" '((:vlr-objectModified . mos:OnObjectAppended))))
)



 

 

 

Message 5 of 7
ddecker56
in reply to: Moshe-A

Thanks, now all i have to do is understand it.

Thanks you.

D

Message 6 of 7
ddecker56
in reply to: Moshe-A

another question. What is the function of the mos prefix in the defun statement.

I have not seen this before and I have programming in Autocad off and on for a few decades.

Message 7 of 7
Moshe-A
in reply to: ddecker56

Decker,

 

the 'mos:' is noting but a prefix to functions name

 

alot of time i found my self using the same functions with slightly differences and to avoid

running over i set a new uniqe prefix name especialy when using reactors and callback functions

 

 

Moshe

 

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

Post to forums  

Autodesk Design & Make Report

”Boost