TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Lupo76 on March 08, 2012, 08:42:00 AM
-
Hello everyone,
I used the following code to add a reactor object:
(setq collReactor
(vlr-object-reactor (list (vlax-ename->vla-object ogg)) "NAMEAP"
'(
(:vlr-modified . reactor_coll)
(:vlr-objectClosed . reactor_endcoll)
)
)
)
(vlr-pers collReactor)
Now I would like to remove this reactor to some objects, while others do not.
How can I do?
Thanks in advance.
-
Look into the vlr-Remove (http://exchange.autodesk.com/autocad/enu/online-help/browse#WS1a9193826455f5ff1a32d8d10ebc6b7ccc-677d.htm) function. :wink:
-
I'm guessing that you want to remove the entire Object Reactor, but from your comment:
Now I would like to remove this reactor to some objects, while others do not.
You may also want to look into the vlr-owner-remove function too :-)
-
Great point, Lee. :beer:
-
You may also want to look into the vlr-owner-remove function too :-)
I tried to write
(setq ogg (car (entsel)))
(vlr-owner-remove collReactor (vlax-ename->vla-object ogg))
but does not work.
Can you give me some advice?
-
If you can help someone ....
I found this code that does exactly what I ask: :-)
(defun c:remo2 ( / allReactorsLst obj removeLst)
(vl-load-com)
(setq obj (vlax-ename->vla-object (car (entsel))))
(mapcar
'(lambda (a / ownLst)
(setq ownLst (vlr-owners a))
(cond
((and (member obj ownLst) (= (length ownLst) 1))
(vlr-remove a)
)
((member obj ownLst)
(vlr-owner-remove a obj)
)
)
)
(apply 'append (mapcar 'cdr (vlr-reactors :vlr-object-reactor)))
)
;(setq allReactors (apply 'append (mapcar 'cdr (vlr-reactors))))
;(mapcar 'vlr-remove allReactors) ; temporarily disable all reactors
;(vla-delete obj)
;(mapcar 'vlr-add allReactors)
;(princ)
)
I removed the last lines, because the object erased and generated exception.
I had a doubt: first to erase an object from the drawingnecessary to remove the reactor? If yes: why? :oops: