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:
Move insert point of selected blocks to nearest polyline end point
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: Move insert point of selected blocks to nearest polyline end point (Read 2288 times)
0 Members and 1 Guest are viewing this topic.
jtm2020hyo
Newt
Posts: 198
Move insert point of selected blocks to nearest polyline end point
«
on:
February 12, 2020, 01:53:38 AM »
1) I need to select some blocks and move then to the nearest end point of selected polyline.
2) I need to select some polyline and move theirs end points to the nearest selected block insert point.
This is possible?
Logged
https://www.patreon.com/jtm2020hyo
ribarm
Gator
Posts: 3225
Marko Ribar, architect
WWW
Re: Move insert point of selected blocks to nearest polyline end point
«
Reply #1 on:
February 12, 2020, 04:24:01 AM »
Here, try this routine :
Code - Auto/Visual Lisp:
[Select]
(
defun
c:stretch
-
move
-
blks
-
lws
(
/
ssblks sslws ch dpl spl lwx dm d np npl k lwxn pl p
)
(
while
(
or
(
prompt
"
\n
Select block INSERT references on unlocked layer(s)..."
)
(
not
(
setq
ssblks
(
ssget
"_:L"
'
(
(
0
.
"INSERT"
)
)
)
)
)
)
(
prompt
"
\n
Empty sel. set..."
)
)
(
while
(
or
(
prompt
"
\n
Select LWPOLYLINES on unlocked layer(s)..."
)
(
not
(
setq
sslws
(
ssget
"_:L"
'
(
(
0
.
"LWPOLYLINE"
)
)
)
)
)
)
(
prompt
"
\n
Empty sel. set..."
)
)
(
initget
1
"Stretch Move"
)
(
setq
ch
(
getkword
"
\n
Stretch LWPOLYLINE vertices to nearest BLOCKS or move BLOCKS to nearest LWPOLYLINE vertices [Stretch/Move] : "
)
)
(
if
(
=
ch
"Stretch"
)
(
progn
(
setq
dpl
(
apply
'
append
(
mapcar
'
(
lambda
(
x
)
(
mapcar
'
cdr
(
vl
-
remove
-
if
'
(
lambda
(
y
)
(
/=
(
car
y
)
10
)
)
x
)
)
)
(
mapcar
'
entget
(
vl
-
remove
-
if
'
listp
(
mapcar
'
cadr
(
ssnamex
ssblks
)
)
)
)
)
)
)
(
foreach
lw
(
vl
-
remove
-
if
'
listp
(
mapcar
'
cadr
(
ssnamex
sslws
)
)
)
(
setq
spl
(
mapcar
'
(
lambda
(
x
)
(
trans
(
list
(
car
x
)
(
cadr
x
)
(
cdr
(
assoc
38
lwx
)
)
)
lw
0
)
)
(
mapcar
'
cdr
(
vl
-
remove
-
if
'
(
lambda
(
x
)
(
/=
(
car
x
)
10
)
)
(
setq
lwx
(
entget
lw
)
)
)
)
)
)
(
foreach
p spl
(
setq
dm 1e
+
99
)
(
foreach
pp dpl
(
if
(
<
(
setq
d
(
distance
p pp
)
)
dm
)
(
setq
dm d np pp
)
)
)
(
setq
npl
(
cons
np npl
)
)
)
(
setq
npl
(
reverse
npl
)
)
(
setq
npl
(
mapcar
'
(
lambda
(
x
)
(
trans
x
0
lw
)
)
npl
)
)
(
setq
k
-
1
)
(
foreach
x lwx
(
if
(
=
(
car
x
)
10
)
(
setq
lwxn
(
append
lwxn
(
list
(
cons
10
(
nth
(
setq
k
(
1+
k
)
)
npl
)
)
)
)
)
(
setq
lwxn
(
append
lwxn
(
list
x
)
)
)
)
)
(
entupd
(
cdr
(
assoc
-
1
(
entmod
lwxn
)
)
)
)
(
setq
npl
nil
lwxn
nil
)
)
)
(
progn
(
foreach
lw
(
vl
-
remove
-
if
'
listp
(
mapcar
'
cadr
(
ssnamex
sslws
)
)
)
(
setq
pl
(
mapcar
'
(
lambda
(
x
)
(
trans
(
list
(
car
x
)
(
cadr
x
)
(
cdr
(
assoc
38
lwx
)
)
)
lw
0
)
)
(
mapcar
'
cdr
(
vl
-
remove
-
if
'
(
lambda
(
x
)
(
/=
(
car
x
)
10
)
)
(
setq
lwx
(
entget
lw
)
)
)
)
)
)
(
setq
dpl
(
append
pl dpl
)
)
)
(
foreach
blk
(
vl
-
remove
-
if
'
listp
(
mapcar
'
cadr
(
ssnamex
ssblks
)
)
)
(
setq
dm 1e
+
99
)
(
foreach
pp dpl
(
if
(
<
(
setq
d
(
distance
(
if
(
null
p
)
(
setq
p
(
cdr
(
assoc
10
(
entget
blk
)
)
)
)
p
)
pp
)
)
dm
)
(
setq
dm d np pp
)
)
)
(
setq
p
nil
)
(
entupd
(
cdr
(
assoc
-
1
(
entmod
(
subst
(
cons
10
np
)
(
assoc
10
(
entget
blk
)
)
(
entget
blk
)
)
)
)
)
)
)
)
)
(
princ
)
)
M.R.
Logged
Marko Ribar, d.i.a.
(graduated engineer of architecture)
M.R. on Youtube
jtm2020hyo
Newt
Posts: 198
Re: Move insert point of selected blocks to nearest polyline end point
«
Reply #2 on:
February 12, 2020, 10:14:14 PM »
awesome. thanks a lot.
how can I mark your answer as a solution?
«
Last Edit: February 12, 2020, 10:19:41 PM by jtm2018hyo
»
Logged
https://www.patreon.com/jtm2020hyo
jtm2020hyo
Newt
Posts: 198
Re: Move insert point of selected blocks to nearest polyline end point
«
Reply #3 on:
August 20, 2020, 06:44:43 PM »
this post is related:
https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/mass-move-block-to-nearest-polyline/m-p/9667727/highlight/true#M402999
maybe help to someone.
Logged
https://www.patreon.com/jtm2020hyo
Pad
Bull Frog
Posts: 342
Re: Move insert point of selected blocks to nearest polyline end point
«
Reply #4 on:
July 30, 2021, 02:16:16 PM »
Thanks Ribarm.
That helped me out a lot today!
P
Logged
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Move insert point of selected blocks to nearest polyline end point