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:
LISP to insert block and rename
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: LISP to insert block and rename (Read 610 times)
0 Members and 1 Guest are viewing this topic.
like_citrus
Newt
Posts: 114
LISP to insert block and rename
«
on:
May 15, 2022, 10:51:06 PM »
Hi, is there a LISP anyone has to insert a block from another drawing and rename it with a suffix, to differentiate from the original block.
Something like Open, Select file, Paste, Rename with suffix.
Logged
mhupp
Bull Frog
Posts: 234
Re: LISP to insert block and rename
«
Reply #1 on:
May 16, 2022, 03:04:46 PM »
For importing blocks
http://www.lee-mac.com/steal.html
This is what i use to rename blocks.
Code - Auto/Visual Lisp:
[Select]
;;----------------------------------------------------------------------------;;
;; Add Prefix/Suffix to Block Name
(
defun
C:BLKRENAME
(
/
blklst SS blk lst c a n
)
(
vl-load-com
)
(
setq
blklst
(
vla-get-Blocks
(
vla-get-activedocument
(
vlax-get-acad-object
)
)
)
)
(
prompt
"
\n
Select Block(s) or Enter To Rename All"
)
(
if
(
or
(
setq
ss
(
ssget
'
(
(
0
.
"INSERT"
)
)
)
)
(
setq
ss
(
ssget
"_X"
'
(
(
0
.
"INSERT"
)
)
)
)
)
(
foreach
e
(
vl
-
remove
-
if
'
listp
(
mapcar
'
cadr
(
ssnamex
ss
)
)
)
(
setq
blk
(
cdr
(
assoc
2
(
entget
e
)
)
)
)
;Get Block Name
(
if
(
not
(
vl-position
blk lst
)
)
;If Block Name is not in List Add
(
setq
lst
(
cons
blk lst
)
)
)
)
)
(
setq
c
0
)
;Count
(
initget
"Prefix Suffix"
)
(
setq
rep
(
cond
(
(
getkword
"
\n
Specify your aim [Prefix/Suffix] :"
)
)
(
"Suffix"
)
)
)
(
cond
(
(
=
rep
"Prefix"
)
(
setq
prfx
(
getstring
"
\n
Enter Prefix: "
)
)
(
foreach
n lst
(
vla-put-Name
(
vla-item
blklst n
)
(
strcat
prfx n
)
)
(
setq
c
(
1+
c
)
)
)
)
(
(
=
rep
"Suffix"
)
(
setq
sufx
(
getstring
"
\n
Enter Suffix: "
)
)
(
foreach
n lst
(
vla-put-Name
(
vla-item
blklst n
)
(
strcat
n sufx
)
)
(
setq
c
(
1+
c
)
)
)
)
)
(
prompt
(
strcat
"
\n
"
(
rtos
c
2
0
)
" Block(s) Renamed"
)
)
(
princ
)
)
Logged
like_citrus
Newt
Posts: 114
Re: LISP to insert block and rename
«
Reply #2 on:
May 16, 2022, 07:45:47 PM »
Thanks for sending this. I'll look into it soon.
Logged
ScottMC
Newt
Posts: 160
Re: LISP to insert block and rename
«
Reply #3 on:
May 17, 2022, 08:57:23 AM »
Check out this persons helpful library.
http://www.lee-mac.com/copyblock.html
Logged
like_citrus
Newt
Posts: 114
Re: LISP to insert block and rename
«
Reply #4 on:
May 17, 2022, 08:03:24 PM »
Thanks, will do.
Logged
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
LISP to insert block and rename