Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Home
Help
Login
Register
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
vlr-owner-remove doesn't work
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: vlr-owner-remove doesn't work (Read 1875 times)
0 Members and 1 Guest are viewing this topic.
Grrr1337
Swamp Rat
Posts: 812
WWW
vlr-owner-remove doesn't work
«
on:
July 03, 2019, 10:39:19 AM »
Hi guys,
I rarely deal with object reactors, so today decided to do some practice by utilising the vlr-owner* functions.. and this got me confused
From the docs :
Removes an object from the list of owners of an object reactor
Manual practice/testing on a object reactor:
Code - Auto/Visual Lisp:
[Select]
_$
(
defun
CB:ObjReactor
(
ownr rtr args
)
(
princ
"
\n
Reaction occured"
)
)
; defun
>>
CB:OBJREACTOR
_$
(
foreach
rtr
(
cdar
(
vlr-reactors
:
VLR-Object-Reactor
)
)
(
if
(
=
"test"
(
vlr-data
rtr
)
)
(
vlr-remove
rtr
)
)
)
>>
nil
_$
(
setq
*
TheReactor
*
(
vlr-object-reactor
(
; Selected a LWPOLYLINE and a CIRCLE
(
lambda
(
/
SS i L
)
(
if
(
setq
SS
(
ssget
"_:L-I"
)
)
(
repeat
(
setq
i
(
sslength
SS
)
)
(
setq
L
(
cons
(
vlax
-
ename
->
vla-object
(
ssname
SS
(
setq
i
(
1-
i
)
)
)
)
L
)
)
)
)
(
reverse
L
)
)
; lambda
)
"test"
(
mapcar
'
(
lambda
(
x
)
(
cons
x 'CB:ObjReactor
)
)
(
vlr-reaction-names
:
VLR-Object-Reactor
)
)
)
; vlr-object-reactor
)
; setq *TheReactor*
>>
#
<
VLR
-
Object
-
Reactor
>
_$
(
vlr-owners
*
TheReactor
*
)
>>
(
#
<
VLA-OBJECT
IAcadLWPolyline 000000ed9a689968
>
#
<
VLA-OBJECT
IAcadCircle 000000edf6e32c18
>
)
_$
(
; Selected an ARC
(
lambda
(
/
SS i
)
(
if
(
setq
SS
(
ssget
"_:L-I"
)
)
(
progn
(
repeat
(
setq
i
(
sslength
SS
)
)
(
vlr-owner-add
*
TheReactor
*
(
vlax
-
ename
->
vla-object
(
ssname
SS
(
setq
i
(
1-
i
)
)
)
)
)
)
(
vlr-owners
*
TheReactor
*
)
)
)
)
; lambda
)
>>
Reaction occured
>>
(
#
<
VLA-OBJECT
IAcadArc 000000ed9da0f528
>
#
<
VLA-OBJECT
IAcadLWPolyline 000000ed9a689968
>
#
<
VLA-OBJECT
IAcadCircle 000000edf6e32c18
>
)
_$
(
; Selected the ARC and the CIRCLE
(
lambda
(
/
SS i
)
(
if
(
setq
SS
(
ssget
"_:L-I"
)
)
(
progn
(
repeat
(
setq
i
(
sslength
SS
)
)
(
vlr-owner-remove
*
TheReactor
*
(
vlax
-
ename
->
vla-object
(
ssname
SS
(
setq
i
(
1-
i
)
)
)
)
)
)
(
vlr-owners
*
TheReactor
*
)
)
)
)
; lambda
)
>>
(
#
<
VLA-OBJECT
IAcadArc 000000ed9da0f528
>
#
<
VLA-OBJECT
IAcadLWPolyline 000000ed9a689968
>
#
<
VLA-OBJECT
IAcadCircle 000000edf6e32c18
>
)
_$
(
vlr-owners
*
TheReactor
*
)
>>
(
#
<
VLA-OBJECT
IAcadArc 000000ed9da0f528
>
#
<
VLA-OBJECT
IAcadLWPolyline 000000ed9a689968
>
#
<
VLA-OBJECT
IAcadCircle 000000edf6e32c18
>
)
_$
(
foreach
x
(
vlr-owners
*
TheReactor
*
)
; Alternative try
(
if
(
member
(
vla-get-ObjectName
x
)
'
(
"AcDbArc"
"AcDbCircle"
)
)
(
vlr-owner-remove
*
TheReactor
*
x
)
)
)
>>
#
<
VLA-OBJECT
IAcadCircle 000000edf6e32c18
>
_$
(
vlr-owners
*
TheReactor
*
)
; the alternative doesn't work -
>>
(
#
<
VLA-OBJECT
IAcadArc 000000ed9da0f528
>
#
<
VLA-OBJECT
IAcadLWPolyline 000000ed9a689968
>
#
<
VLA-OBJECT
IAcadCircle 000000edf6e32c18
>
)
One could try it by himself, I'm with ACAD 2017 BTW.
Logged
(apply ''((a b c)(a b c))
'(
(( f L ) (apply 'strcat (f L)))
(( L ) (if L (cons (chr (car L)) (f (cdr L)))))
(72 101 108 108 111 32 87 111 114 108 100)
)
)
vevo.bg
ribarm
Gator
Posts: 3274
Marko Ribar, architect
WWW
Re: vlr-owner-remove doesn't work
«
Reply #1 on:
July 05, 2019, 04:51:34 AM »
Tested on A2018... The same thing...
Code - Auto/Visual Lisp:
[Select]
_$
(
defun
CB:ObjReactor
(
ownr rtr args
)
(
_
>
(
princ
"
\n
Reaction occured"
)
(
_
>
)
CB:OBJREACTOR
_$
(
foreach
rtr
(
cdar
(
vlr-reactors
:
VLR-Object-Reactor
)
)
(
if
(
=
"test"
(
vlr-data
rtr
)
)
(
vlr-remove
rtr
)
)
)
nil
_$
(
setq
*
TheReactor
*
(
_
>
(
vlr-object-reactor
(
(
_
>
(
; Selected a LWPOLYLINE and a CIRCLE
(
(
(
_
>
(
lambda
(
/
SS i L
)
(
(
(
(
_
>
(
if
(
setq
SS
(
ssget
"_:L-I"
)
)
(
(
(
(
(
_
>
(
repeat
(
setq
i
(
sslength
SS
)
)
(
(
(
(
(
(
_
>
(
setq
L
(
cons
(
vlax
-
ename
->
vla-object
(
ssname
SS
(
setq
i
(
1-
i
)
)
)
)
L
)
)
(
(
(
(
(
(
_
>
)
(
(
(
(
(
_
>
)
(
(
(
(
_
>
(
reverse
L
)
(
(
(
(
_
>
)
; lambda
(
(
(
_
>
)
(
(
_
>
"test"
(
(
_
>
(
mapcar
'
(
lambda
(
x
)
(
cons
x 'CB:ObjReactor
)
)
(
vlr-reaction-names
:
VLR-Object-Reactor
)
)
(
(
_
>
)
; vlr-object-reactor
(
_
>
)
; setq *TheReactor*
#
<
VLR
-
Object
-
Reactor
>
_$
(
vlr-owners
*
TheReactor
*
)
(
#
<
VLA-OBJECT
IAcadLWPolyline 0000028ce2f9f738
>
#
<
VLA-OBJECT
IAcadCircle 0000028ce2f9f138
>
)
_$
(
; Selected an ARC
(
_
>
(
lambda
(
/
SS i
)
(
(
_
>
(
if
(
setq
SS
(
ssget
"_:L-I"
)
)
(
(
(
_
>
(
progn
(
(
(
(
_
>
(
repeat
(
setq
i
(
sslength
SS
)
)
(
(
(
(
(
_
>
(
vlr-owner-add
*
TheReactor
*
(
vlax
-
ename
->
vla-object
(
ssname
SS
(
setq
i
(
1-
i
)
)
)
)
)
(
(
(
(
(
_
>
)
(
(
(
(
_
>
(
vlr-owners
*
TheReactor
*
)
(
(
(
(
_
>
)
(
(
(
_
>
)
(
(
_
>
)
; lambda
(
_
>
)
Reaction occured
(
#
<
VLA-OBJECT
IAcadArc 0000028ce2de18c8
>
#
<
VLA-OBJECT
IAcadLWPolyline 0000028ce2f9f738
>
#
<
VLA-OBJECT
IAcadCircle 0000028ce2f9f138
>
)
_$
(
; Selected the ARC and the CIRCLE
(
_
>
(
lambda
(
/
SS i
)
(
(
_
>
(
if
(
setq
SS
(
ssget
"_:L-I"
)
)
(
(
(
_
>
(
progn
(
(
(
(
_
>
(
repeat
(
setq
i
(
sslength
SS
)
)
(
(
(
(
(
_
>
(
vlr-owner-remove
*
TheReactor
*
(
vlax
-
ename
->
vla-object
(
ssname
SS
(
setq
i
(
1-
i
)
)
)
)
)
(
(
(
(
(
_
>
)
(
(
(
(
_
>
(
vlr-owners
*
TheReactor
*
)
(
(
(
(
_
>
)
(
(
(
_
>
)
(
(
_
>
)
; lambda
(
_
>
)
(
#
<
VLA-OBJECT
IAcadArc 0000028ce2de18c8
>
#
<
VLA-OBJECT
IAcadLWPolyline 0000028ce2f9f738
>
#
<
VLA-OBJECT
IAcadCircle 0000028ce2f9f138
>
)
_$
(
vlr-owners
*
TheReactor
*
)
(
#
<
VLA-OBJECT
IAcadArc 0000028ce2de18c8
>
#
<
VLA-OBJECT
IAcadLWPolyline 0000028ce2f9f738
>
#
<
VLA-OBJECT
IAcadCircle 0000028ce2f9f138
>
)
_$
(
foreach
x
(
vlr-owners
*
TheReactor
*
)
; Alternative try
(
_
>
(
if
(
member
(
vla-get-ObjectName
x
)
'
(
"AcDbArc"
"AcDbCircle"
)
)
(
(
_
>
(
vlr-owner-remove
*
TheReactor
*
x
)
(
(
_
>
)
(
_
>
)
#
<
VLA-OBJECT
IAcadCircle 0000028ce2f9f138
>
_$
(
vlr-owners
*
TheReactor
*
)
; the alternative doesn't work -
(
#
<
VLA-OBJECT
IAcadArc 0000028ce2de18c8
>
#
<
VLA-OBJECT
IAcadLWPolyline 0000028ce2f9f738
>
#
<
VLA-OBJECT
IAcadCircle 0000028ce2f9f138
>
)
_$
Logged
Marko Ribar, d.i.a.
(graduated engineer of architecture)
M.R. on Youtube
ribarm
Gator
Posts: 3274
Marko Ribar, architect
WWW
Re: vlr-owner-remove doesn't work
«
Reply #2 on:
July 05, 2019, 07:27:40 AM »
All I could find out is to reconstruct reactor :
Code - Auto/Visual Lisp:
[Select]
(
defun
CB:ObjReactor
(
owner reactor lstename
)
(
princ
"
\n
Reaction occured"
)
)
(
setq
*
TheReactor
*
(
vlr-object-reactor
(
(
lambda
(
/
SS i L
)
(
if
(
setq
SS
(
ssget
"_:L-I"
)
)
(
repeat
(
setq
i
(
sslength
SS
)
)
(
setq
L
(
cons
(
vlax
-
ename
->
vla-object
(
ssname
SS
(
setq
i
(
1-
i
)
)
)
)
L
)
)
)
)
(
reverse
L
)
)
)
"test"
(
mapcar
'
(
lambda
(
x
)
(
cons
x 'CB:ObjReactor
)
)
(
vlr-reaction-names
:
VLR-Object-Reactor
)
)
)
)
(
princ
"
\n
"
)
(
princ
(
vlr-owners
*
TheReactor
*
)
)
(
defun
_setq
-
reactor
-
vlr-owner-remove
(
reactor owner
/
owners data typ reactions
)
(
setq
owners
(
vlr-owners
reactor
)
)
(
setq
owners
(
vl-remove
owner owners
)
)
(
setq
data
(
vlr-data
reactor
)
)
(
setq
typ
(
vlr
-
type
reactor
)
)
(
if
(
=
(
type
data
)
'str
)
(
setq
reactions
(
vlr-reactions
reactor
)
)
)
(
vlr-remove
reactor
)
(
if
(
=
(
type
data
)
'str
)
(
(
eval
(
read
(
substr
(
vl-prin1-to-string
typ
)
2
)
)
)
owners data reactions
)
(
(
eval
(
read
(
substr
(
vl-prin1-to-string
typ
)
2
)
)
)
owners data
)
)
)
(
setq
*
TheReactor
*
(
_setq
-
reactor
-
vlr-owner-remove
*
TheReactor
*
(
setq
*
owner
*
(
car
(
vlr-owners
*
TheReactor
*
)
)
)
)
)
(
princ
"
\n
"
)
(
princ
(
vlr-owners
*
TheReactor
*
)
)
(
vlr-owner-add
*
TheReactor
*
*
owner
*
)
(
princ
"
\n
"
)
(
princ
(
vlr-owners
*
TheReactor
*
)
)
(
princ
)
So if you firstly selected 3 entities, *TheReactor* should have after calling sub 2 owners, as first one is removed and then at the end global variable *owner* is added with (vlr-owner-add) function which works well...
HTH., M.R.
«
Last Edit: July 05, 2019, 10:20:42 AM by ribarm
»
Logged
Marko Ribar, d.i.a.
(graduated engineer of architecture)
M.R. on Youtube
ribarm
Gator
Posts: 3274
Marko Ribar, architect
WWW
Re: vlr-owner-remove doesn't work
«
Reply #3 on:
July 05, 2019, 10:39:27 AM »
I've updated sub function to be better... No need for callback function as argument... It's just like it should be : reactor and owner as arguments...
Regards, M.R.
Logged
Marko Ribar, d.i.a.
(graduated engineer of architecture)
M.R. on Youtube
Grrr1337
Swamp Rat
Posts: 812
WWW
Re: vlr-owner-remove doesn't work
«
Reply #4 on:
July 06, 2019, 09:18:35 PM »
Thanks for confirming, Marco -
Looks like there are few threads over here, regarding this
vlr-owners-remove
function, where I participated but haven't noticed that this function actually doesn't work.
http://www.theswamp.org/index.php?topic=52995.msg578082#msg578082
http://www.theswamp.org/index.php?topic=52970.msg577851#msg577851
http://www.theswamp.org/index.php?topic=53048.msg578824#msg578824
So for my other test program, I had to substitute my previous code block..
Code - Auto/Visual Lisp:
[Select]
(
; vlr-owner-remove doesn't work - http://www.theswamp.org/index.php?topic=55299.0
(
lambda
(
/
SS rtr
)
(
if
(
and
(
setq
rtr
(
vl-some
(
function
(
lambda
(
x
)
(
if
(
=
rtrnm
(
vlr-data
x
)
)
x
)
)
)
(
cdar
(
vlr-reactors
:
VLR-Object-Reactor
)
)
)
)
(
setq
SS
(
ssget
"_:L-I"
)
)
)
(
(
lambda
(
SS
/
i
)
(
repeat
(
setq
i
(
sslength
SS
)
)
(
vlr-owner-remove
rtr
(
vlax
-
ename
->
vla-object
(
ssname
SS
(
setq
i
(
1-
i
)
)
)
)
)
)
)
; lambda
SS
)
)
; if SS
)
; lambda
)
..with this one..
Code - Auto/Visual Lisp:
[Select]
(
; vlr-owner-remove doesn't work, hence redefine the reactor
(
lambda
(
/
rtr notifiers SS
)
(
if
(
and
(
setq
rtr
(
vl-some
(
function
(
lambda
(
x
)
(
if
(
=
rtrnm
(
vlr-data
x
)
)
x
)
)
)
(
cdar
(
vlr-reactors
:
VLR-Object-Reactor
)
)
)
)
(
setq
notifiers
(
vlr-owners
rtr
)
)
(
setq
SS
(
ssget
"_:L-I"
)
)
)
(
progn
(
foreach
rtr
(
cdar
(
vlr-reactors
:
VLR-Object-Reactor
)
)
(
if
(
=
rtrnm
(
vlr-data
rtr
)
)
(
vlr-remove
rtr
)
)
)
(
vlr-object-reactor
(
vl
-
remove
-
if
'
(
lambda
(
x
)
(
ssmemb
(
vlax
-
vla
-
object
->
ename x
)
SS
)
)
notifiers
)
rtrnm
(
mapcar
'
(
lambda
(
x
)
(
cons
x 'CB:ObjReactor
)
)
(
vlr-reaction-names
:
VLR-Object-Reactor
)
)
)
; vlr-object-reactor
)
; progn
)
; if SS
)
; lambda
)
Basically reconstructing the reactor like you did - although the point is regarding the vlr-owners-remove function.
Logged
(apply ''((a b c)(a b c))
'(
(( f L ) (apply 'strcat (f L)))
(( L ) (if L (cons (chr (car L)) (f (cdr L)))))
(72 101 108 108 111 32 87 111 114 108 100)
)
)
vevo.bg
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
vlr-owner-remove doesn't work