Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Block replacement in an attribute

15 REPLIES 15
Reply
Message 1 of 16
Anonymous
136 Views, 15 Replies

Block replacement in an attribute

IS there a way to replace a block in an attribute not just globally but
by selecting which one I want? Once selected I would be able to select
a different block for replacement. Would someone have this in a lisp or
vba setup?

Thank Ed
15 REPLIES 15
Message 2 of 16
Anonymous
in reply to: Anonymous

(defun c:name(/ e v)
(setq e(entget(car(entsel"\nSelect block: ")
v(getstring T" new name: ")
e(subst(cons 2 v)(assoc 2 e)e)
)
(entmod e)
(entupd(cdr(assoc -1 e)))
(princ)
)

?

Ed Matthews wrote in message
news:3BD8729F.2010904@wmsenginc.com...
> IS there a way to replace a block in an attribute not just globally but
> by selecting which one I want? Once selected I would be able to select
> a different block for replacement. Would someone have this in a lisp or
> vba setup?
>
> Thank Ed
>
Message 3 of 16
Anonymous
in reply to: Anonymous

Matthews thanks for the routine. I keep getting the message :
error: malformed list on input, when loading.

matthew wrote:

> (defun c:name(/ e v)
> (setq e(entget(car(entsel"\nSelect block: ")
> v(getstring T" new name: ")
> e(subst(cons 2 v)(assoc 2 e)e)
> )
> (entmod e)
> (entupd(cdr(assoc -1 e)))
> (princ)
> )
>
> ?
>
> Ed Matthews wrote in message
> news:3BD8729F.2010904@wmsenginc.com...
>
>>IS there a way to replace a block in an attribute not just globally but
>>by selecting which one I want? Once selected I would be able to select
>>a different block for replacement. Would someone have this in a lisp or
>>vba setup?
>>
>>Thank Ed
>>
>>
>
>
Message 4 of 16
Anonymous
in reply to: Anonymous

He must write to fast, just forgot some parens...no big deal...

(defun c:name (/ e v)
(setq e (entget (car (entsel "\nSelect block: ")))
v (getstring T " new name: ")
e (subst (cons 2 v) (assoc 2 e) e)
)
(entmod e)
(entupd (cdr (assoc -1 e)))
(princ)
)
Message 5 of 16
Anonymous
in reply to: Anonymous

Lius I appreciate it. Question: Is there a way to make it so you can
select more than one or window before you pick a block?


Luis Esquivel wrote:

> He must write to fast, just forgot some parens...no big deal...
>
> (defun c:name (/ e v)
> (setq e (entget (car (entsel "\nSelect block: ")))
> v (getstring T " new name: ")
> e (subst (cons 2 v) (assoc 2 e) e)
> )
> (entmod e)
> (entupd (cdr (assoc -1 e)))
> (princ)
> )
>
>
>
>
Message 6 of 16
Anonymous
in reply to: Anonymous

Try this I did not tested, but I guess is in the right track... good luck
-Luis

"Ed Matthews"
> Lius I appreciate it. Question: Is there a way to make it so you can
> select more than one or window before you pick a block?
>

(defun name (e v)
(setq ;;e (entget (car (entsel "\nSelect block: ")))
;;v (getstring T " new name: ")
e
(subst (cons 2 v) (assoc 2 e) e)
)
(entmod e)
(entupd (cdr (assoc -1 e)))
;;; (princ)
)

(defun C:MNAME (/ ss lth cont v)
;;; (ssget '((0 . "INSERT") (-4 . "&=") (66 . 1))) ; or more eficient use
this...
(setq ss (ssget '((66 . 1) (0 . "INSERT")))
lth (sslength ss)
cont 0
v (getstring T "\n \n \nNew name: ")
)
(while (<= cont (- lth 1))
(name (ssname ss cont) v)
(setq cont (1+ cont))
)
(princ)
)
Message 7 of 16
Anonymous
in reply to: Anonymous

Luis all works to this point. After selecting objects and then asked
for "New Name" block name is entered and error messege:
bad argument type: listp

I do appreciate all of your help

Thanks Ed

Luis Esquivel wrote:

> Try this I did not tested, but I guess is in the right track... good luck
> -Luis
>
> "Ed Matthews"
>
>>Lius I appreciate it. Question: Is there a way to make it so you can
>>select more than one or window before you pick a block?
>>
>>
>
> (defun name (e v)
> (setq ;;e (entget (car (entsel "\nSelect block: ")))
> ;;v (getstring T " new name: ")
> e
> (subst (cons 2 v) (assoc 2 e) e)
> )
> (entmod e)
> (entupd (cdr (assoc -1 e)))
> ;;; (princ)
> )
>
> (defun C:MNAME (/ ss lth cont v)
> ;;; (ssget '((0 . "INSERT") (-4 . "&=") (66 . 1))) ; or more eficient use
> this...
> (setq ss (ssget '((66 . 1) (0 . "INSERT")))
> lth (sslength ss)
> cont 0
> v (getstring T "\n \n \nNew name: ")
> )
> (while (<= cont (- lth 1))
> (name (ssname ss cont) v)
> (setq cont (1+ cont))
> )
> (princ)
> )
>
>
>
>
Message 8 of 16
Anonymous
in reply to: Anonymous

Maybe I understood what you are looking for... 🙂

(defun name (e v)
(setq

lst
(subst (cons 2 v) (assoc 2 (entget e)) (entget e))
)
(entmod lst)
(entupd (cdr (assoc -1 lst)))
)

(defun C:RBLOCKS (/ ss lth cont v)
(prompt "\nSelect block(s) to replace... ")
(setq ss (ssget '((66 . 1) (0 . "INSERT")))
lth (sslength ss)
cont 0
v (car (entsel "\nSelect target block: "))
)
(while (<= cont (- lth 1))
(name (ssname ss cont) (cdr (assoc 2 (entget v))))
(setq cont (1+ cont))
)
(princ)
)
Message 9 of 16
Anonymous
in reply to: Anonymous

Luis, that was it. I do appreciate it very much. Forgive, but I have to
ask. My blocks are at different scales, is there a routine you might
have that could scale all blocks selected at one time?
Thnks for everything
Ed

Luis Esquivel wrote:

> Maybe I understood what you are looking for... 🙂
>
> (defun name (e v)
> (setq
>
> lst
> (subst (cons 2 v) (assoc 2 (entget e)) (entget e))
> )
> (entmod lst)
> (entupd (cdr (assoc -1 lst)))
> )
>
> (defun C:RBLOCKS (/ ss lth cont v)
> (prompt "\nSelect block(s) to replace... ")
> (setq ss (ssget '((66 . 1) (0 . "INSERT")))
> lth (sslength ss)
> cont 0
> v (car (entsel "\nSelect target block: "))
> )
> (while (<= cont (- lth 1))
> (name (ssname ss cont) (cdr (assoc 2 (entget v))))
> (setq cont (1+ cont))
> )
> (princ)
> )
>
>
>
Message 10 of 16
Anonymous
in reply to: Anonymous

just to add to that, only the blocks need scaling not the text with it

Ed Matthews wrote:

> Luis, that was it. I do appreciate it very much. Forgive, but I have to
> ask. My blocks are at different scales, is there a routine you might
> have that could scale all blocks selected at one time?
> Thnks for everything
> Ed
>
> Luis Esquivel wrote:
>
>> Maybe I understood what you are looking for... 🙂
>>
>> (defun name (e v)
>> (setq
>>
>> lst
>> (subst (cons 2 v) (assoc 2 (entget e)) (entget e))
>> )
>> (entmod lst)
>> (entupd (cdr (assoc -1 lst)))
>> )
>>
>> (defun C:RBLOCKS (/ ss lth cont v)
>> (prompt "\nSelect block(s) to replace... ")
>> (setq ss (ssget '((66 . 1) (0 . "INSERT")))
>> lth (sslength ss)
>> cont 0
>> v (car (entsel "\nSelect target block: "))
>> )
>> (while (<= cont (- lth 1))
>> (name (ssname ss cont) (cdr (assoc 2 (entget v))))
>> (setq cont (1+ cont))
>> )
>> (princ)
>> )
>>
>>
>>
>
Message 11 of 16
Anonymous
in reply to: Anonymous

this is the AutoCAD command for that..
ATTREDEF


Redefines a block and updates associated attributes

Command line: attredef

Enter the name of the block you wish to redefine:

Select objects for new block:

Select objects:

Insertion base point of new block: Specify a point

New attributes assigned to existing block references use their default
values. Old attributes in the new block definition retain their old values.
AutoCAD deletes any old attributes that are not included in the new block
definition.


--
A2Ki, SurvCad CES, Win98 se
Remove NO SPAM from my email address to email

Jonathan J. Baker
R&R Engineers-Surveyors, Inc.
Denver, Colorado
_________________________
"Ed Matthews" wrote in message
news:3BD8729F.2010904@wmsenginc.com...
> IS there a way to replace a block in an attribute not just globally but
> by selecting which one I want? Once selected I would be able to select
> a different block for replacement. Would someone have this in a lisp or
> vba setup?
>
> Thank Ed
>
Message 12 of 16
Anonymous
in reply to: Anonymous

i found a lisp called bsc that will do that...

(DEFUN aaej (aae@ / aaeQ)
(INITGET 128 "About Select")
(SETQ aaeQ (GETKWORD "\nSelect/: "))
(COND ((= aaeQ "About") (ALERT aae@) (aaej aae@))
((= aaeQ "Select") (SETQ aaeQ (aael)))
((NULL aaeQ) NIL)
((NOT (TBLSEARCH "BLOCK" aaeQ))
(ALERT (STRCAT "Block \"" aaeQ "\" is not defined."))
(aaej aae@)
)
(T aaeQ)
)
)
(DEFUN aael (/ aae&)
(SETVAR "errno" 0)
(SETQ aae& (ENTSEL (STRCAT "\nSelect block: ")))
(COND ((= (GETVAR "errno") 7) (aael))
((NULL aae&) NIL)
(T (aae1 aae&))
)
)
(DEFUN aae1 (aae& / aae# aae0 aae$)
(SETQ aae0 (CAR aae&))
(SETQ aae# (ENTGET aae0))
(SETQ aae$ (CDR (ASSOC 0 aae#)))
(SETQ aaeQ (CDR (ASSOC 2 aae#)))
(IF (NOT (EQ aae$ "INSERT"))
(PROGN (ALERT "Requires a block selection.") (aael))
(PROGN (PROMPT (STRCAT "\nBlock name: " aaeQ)) aaeQ)
)
)
(DEFUN aaeO (aaeQ / aae|)
(INITGET "Yes No ")
(SETQ aae| (GETKWORD "\nScale blocks globally? : "))
(IF (= aae| "No")
(SSGET (LIST (CONS 2 aaeQ)))
(SSGET "X" (LIST (CONS 2 aaeQ)))
)
)
(DEFUN aae% (aae?j / aaejj)
(IF (= aae?j "Relative")
(PROGN (INITGET "Absolute Relative" 7)
(SETQ aaejj (GETREAL "\nAbsolute/: "))
)
(PROGN (INITGET "Absolute Relative" 7)
(SETQ aaejj (GETREAL "\nRelative/: "))
)
)
(COND ((= aaejj "Absolute") (aae% "Absolute"))
((= aaejj "Relative") (aae% "Relative"))
(T (LIST aae?j aaejj))
)
)
(DEFUN aae@j (aaeQj aaelj / aae# aae0 aae&j aae?j aae1j aae#j aae0j
aae$j)
(SETQ aae?j (CAR aaeQj))
(SETQ aae0j (CADR aaeQj))
(SETQ aae&j (SSLENGTH aaelj)
aae#j aae&j
)
(WHILE (> aae&j 0)
(SETQ aae&j (1- aae&j))
(SETQ aae0 (SSNAME aaelj aae&j))
(SETQ aae# (ENTGET aae0))
(SETQ aae1j (CDR (ASSOC 10 aae#)))
(SETQ aae$j (CDR (ASSOC 41 aae#)))
(IF (= aae?j "Relative")
(COMMAND "_.scale" aae0 "" "_none" aae1j aae0j)
(COMMAND "_.scale" aae0 "" "_none" aae1j (/ aae0j aae$j))
)
)
(PROMPT (STRCAT "\nBlock(s) scaled: " (ITOA aae#j)))
)
(DEFUN aaeOj (aae@ /)
(IF (/= aae@ "Function cancelled")
(PRINC aae@)
)
(SETQ *ERROR* aae|j)
(IF aae%j
(SETVAR "highlight" aae%j)
)
(COMMAND "_.undo" "_end")
(SETVAR "cmdecho" 1)
(PRINC)
)
(DEFUN C:BSC (/ aaeQ aae@ aae|j aaeQj aaelj)
(SETVAR "cmdecho" 0)
(COMMAND "_.undo" "_group")
(SETQ aae|j *ERROR*
*ERROR* aaeOj
)
(SETQ aae@ (STRCAT "Block Scale Version 5.1\n"
"Copyright"
(CHR 169)
" 1992-98 PowerLISP Solutions\n"
"All rights reserved.\n\n"
"Visit our web site at:\n"
"http://www.powerlisp.com"
)
)
(SETQ aaeQ (aaej aae@))
(IF aaeQ
(PROGN (SETQ aaeQj (aae% "Relative"))
(SETQ aaelj (aaeO aaeQ))
(IF aaelj
(aae@j aaeQj aaelj)
(ALERT "No objects found.")
)
)
)
(SETQ *ERROR* aae|j)
(COMMAND "_.undo" "_end")
(SETVAR "cmdecho" 1)
(PRINC)
)
(PRINC)

--
A2Ki, SurvCad CES, Win98 se
Remove NO SPAM from my email address to email

Jonathan J. Baker
R&R Engineers-Surveyors, Inc.
Denver, Colorado
_________________________
"Ed Matthews" wrote in message
news:3BD894FE.9060107@wmsenginc.com...
> Luis, that was it. I do appreciate it very much. Forgive, but I have to
> ask. My blocks are at different scales, is there a routine you might
> have that could scale all blocks selected at one time?
> Thnks for everything
> Ed
>
> Luis Esquivel wrote:
>
> > Maybe I understood what you are looking for... 🙂
> >
> > (defun name (e v)
> > (setq
> >
> > lst
> > (subst (cons 2 v) (assoc 2 (entget e)) (entget e))
> > )
> > (entmod lst)
> > (entupd (cdr (assoc -1 lst)))
> > )
> >
> > (defun C:RBLOCKS (/ ss lth cont v)
> > (prompt "\nSelect block(s) to replace... ")
> > (setq ss (ssget '((66 . 1) (0 . "INSERT")))
> > lth (sslength ss)
> > cont 0
> > v (car (entsel "\nSelect target block: "))
> > )
> > (while (<= cont (- lth 1))
> > (name (ssname ss cont) (cdr (assoc 2 (entget v))))
> > (setq cont (1+ cont))
> > )
> > (princ)
> > )
> >
> >
> >
>
Message 13 of 16
Anonymous
in reply to: Anonymous

How do you start the command?

Jon Baker wrote:

> i found a lisp called bsc that will do that...
>
> (DEFUN aaej (aae@ / aaeQ)
> (INITGET 128 "About Select")
> (SETQ aaeQ (GETKWORD "\nSelect/: "))
> (COND ((= aaeQ "About") (ALERT aae@) (aaej aae@))
> ((= aaeQ "Select") (SETQ aaeQ (aael)))
> ((NULL aaeQ) NIL)
> ((NOT (TBLSEARCH "BLOCK" aaeQ))
> (ALERT (STRCAT "Block \"" aaeQ "\" is not defined."))
> (aaej aae@)
> )
> (T aaeQ)
> )
> )
> (DEFUN aael (/ aae&)
> (SETVAR "errno" 0)
> (SETQ aae& (ENTSEL (STRCAT "\nSelect block: ")))
> (COND ((= (GETVAR "errno") 7) (aael))
> ((NULL aae&) NIL)
> (T (aae1 aae&))
> )
> )
> (DEFUN aae1 (aae& / aae# aae0 aae$)
> (SETQ aae0 (CAR aae&))
> (SETQ aae# (ENTGET aae0))
> (SETQ aae$ (CDR (ASSOC 0 aae#)))
> (SETQ aaeQ (CDR (ASSOC 2 aae#)))
> (IF (NOT (EQ aae$ "INSERT"))
> (PROGN (ALERT "Requires a block selection.") (aael))
> (PROGN (PROMPT (STRCAT "\nBlock name: " aaeQ)) aaeQ)
> )
> )
> (DEFUN aaeO (aaeQ / aae|)
> (INITGET "Yes No ")
> (SETQ aae| (GETKWORD "\nScale blocks globally? : "))
> (IF (= aae| "No")
> (SSGET (LIST (CONS 2 aaeQ)))
> (SSGET "X" (LIST (CONS 2 aaeQ)))
> )
> )
> (DEFUN aae% (aae?j / aaejj)
> (IF (= aae?j "Relative")
> (PROGN (INITGET "Absolute Relative" 7)
> (SETQ aaejj (GETREAL "\nAbsolute/: "))
> )
> (PROGN (INITGET "Absolute Relative" 7)
> (SETQ aaejj (GETREAL "\nRelative/: "))
> )
> )
> (COND ((= aaejj "Absolute") (aae% "Absolute"))
> ((= aaejj "Relative") (aae% "Relative"))
> (T (LIST aae?j aaejj))
> )
> )
> (DEFUN aae@j (aaeQj aaelj / aae# aae0 aae&j aae?j aae1j aae#j aae0j
> aae$j)
> (SETQ aae?j (CAR aaeQj))
> (SETQ aae0j (CADR aaeQj))
> (SETQ aae&j (SSLENGTH aaelj)
> aae#j aae&j
> )
> (WHILE (> aae&j 0)
> (SETQ aae&j (1- aae&j))
> (SETQ aae0 (SSNAME aaelj aae&j))
> (SETQ aae# (ENTGET aae0))
> (SETQ aae1j (CDR (ASSOC 10 aae#)))
> (SETQ aae$j (CDR (ASSOC 41 aae#)))
> (IF (= aae?j "Relative")
> (COMMAND "_.scale" aae0 "" "_none" aae1j aae0j)
> (COMMAND "_.scale" aae0 "" "_none" aae1j (/ aae0j aae$j))
> )
> )
> (PROMPT (STRCAT "\nBlock(s) scaled: " (ITOA aae#j)))
> )
> (DEFUN aaeOj (aae@ /)
> (IF (/= aae@ "Function cancelled")
> (PRINC aae@)
> )
> (SETQ *ERROR* aae|j)
> (IF aae%j
> (SETVAR "highlight" aae%j)
> )
> (COMMAND "_.undo" "_end")
> (SETVAR "cmdecho" 1)
> (PRINC)
> )
> (DEFUN C:BSC (/ aaeQ aae@ aae|j aaeQj aaelj)
> (SETVAR "cmdecho" 0)
> (COMMAND "_.undo" "_group")
> (SETQ aae|j *ERROR*
> *ERROR* aaeOj
> )
> (SETQ aae@ (STRCAT "Block Scale Version 5.1\n"
> "Copyright"
> (CHR 169)
> " 1992-98 PowerLISP Solutions\n"
> "All rights reserved.\n\n"
> "Visit our web site at:\n"
> "http://www.powerlisp.com"
> )
> )
> (SETQ aaeQ (aaej aae@))
> (IF aaeQ
> (PROGN (SETQ aaeQj (aae% "Relative"))
> (SETQ aaelj (aaeO aaeQ))
> (IF aaelj
> (aae@j aaeQj aaelj)
> (ALERT "No objects found.")
> )
> )
> )
> (SETQ *ERROR* aae|j)
> (COMMAND "_.undo" "_end")
> (SETVAR "cmdecho" 1)
> (PRINC)
> )
> (PRINC)
>
> --
> A2Ki, SurvCad CES, Win98 se
> Remove NO SPAM from my email address to email
>
> Jonathan J. Baker
> R&R Engineers-Surveyors, Inc.
> Denver, Colorado
> _________________________
> "Ed Matthews" wrote in message
> news:3BD894FE.9060107@wmsenginc.com...
>
>>Luis, that was it. I do appreciate it very much. Forgive, but I have to
>>ask. My blocks are at different scales, is there a routine you might
>>have that could scale all blocks selected at one time?
>>Thnks for everything
>>Ed
>>
>>Luis Esquivel wrote:
>>
>>
>>>Maybe I understood what you are looking for... 🙂
>>>
>>>(defun name (e v)
>>> (setq
>>>
>>> lst
>>> (subst (cons 2 v) (assoc 2 (entget e)) (entget e))
>>> )
>>> (entmod lst)
>>> (entupd (cdr (assoc -1 lst)))
>>>)
>>>
>>>(defun C:RBLOCKS (/ ss lth cont v)
>>> (prompt "\nSelect block(s) to replace... ")
>>> (setq ss (ssget '((66 . 1) (0 . "INSERT")))
>>> lth (sslength ss)
>>> cont 0
>>> v (car (entsel "\nSelect target block: "))
>>> )
>>> (while (<= cont (- lth 1))
>>> (name (ssname ss cont) (cdr (assoc 2 (entget v))))
>>> (setq cont (1+ cont))
>>> )
>>> (princ)
>>>)
>>>
>>>
>>>
>>>
>
>
Message 14 of 16
Anonymous
in reply to: Anonymous

BSC

--
A2Ki, SurvCad CES, Win98 se
Remove NO SPAM from my email address to email

Jonathan J. Baker
R&R Engineers-Surveyors, Inc.
Denver, Colorado
_________________________
"Ed Matthews" wrote in message
news:3BD898AF.20009@wmsenginc.com...
> How do you start the command?
>
> Jon Baker wrote:
>
> > i found a lisp called bsc that will do that...
> >
> > (DEFUN aaej (aae@ / aaeQ)
> > (INITGET 128 "About Select")
> > (SETQ aaeQ (GETKWORD "\nSelect/: "))
> > (COND ((= aaeQ "About") (ALERT aae@) (aaej aae@))
> > ((= aaeQ "Select") (SETQ aaeQ (aael)))
> > ((NULL aaeQ) NIL)
> > ((NOT (TBLSEARCH "BLOCK" aaeQ))
> > (ALERT (STRCAT "Block \"" aaeQ "\" is not defined."))
> > (aaej aae@)
> > )
> > (T aaeQ)
> > )
> > )
> > (DEFUN aael (/ aae&)
> > (SETVAR "errno" 0)
> > (SETQ aae& (ENTSEL (STRCAT "\nSelect block: ")))
> > (COND ((= (GETVAR "errno") 7) (aael))
> > ((NULL aae&) NIL)
> > (T (aae1 aae&))
> > )
> > )
> > (DEFUN aae1 (aae& / aae# aae0 aae$)
> > (SETQ aae0 (CAR aae&))
> > (SETQ aae# (ENTGET aae0))
> > (SETQ aae$ (CDR (ASSOC 0 aae#)))
> > (SETQ aaeQ (CDR (ASSOC 2 aae#)))
> > (IF (NOT (EQ aae$ "INSERT"))
> > (PROGN (ALERT "Requires a block selection.") (aael))
> > (PROGN (PROMPT (STRCAT "\nBlock name: " aaeQ)) aaeQ)
> > )
> > )
> > (DEFUN aaeO (aaeQ / aae|)
> > (INITGET "Yes No ")
> > (SETQ aae| (GETKWORD "\nScale blocks globally? : "))
> > (IF (= aae| "No")
> > (SSGET (LIST (CONS 2 aaeQ)))
> > (SSGET "X" (LIST (CONS 2 aaeQ)))
> > )
> > )
> > (DEFUN aae% (aae?j / aaejj)
> > (IF (= aae?j "Relative")
> > (PROGN (INITGET "Absolute Relative" 7)
> > (SETQ aaejj (GETREAL "\nAbsolute/: "))
> > )
> > (PROGN (INITGET "Absolute Relative" 7)
> > (SETQ aaejj (GETREAL "\nRelative/: "))
> > )
> > )
> > (COND ((= aaejj "Absolute") (aae% "Absolute"))
> > ((= aaejj "Relative") (aae% "Relative"))
> > (T (LIST aae?j aaejj))
> > )
> > )
> > (DEFUN aae@j (aaeQj aaelj / aae# aae0 aae&j aae?j aae1j aae#j aae0j
> > aae$j)
> > (SETQ aae?j (CAR aaeQj))
> > (SETQ aae0j (CADR aaeQj))
> > (SETQ aae&j (SSLENGTH aaelj)
> > aae#j aae&j
> > )
> > (WHILE (> aae&j 0)
> > (SETQ aae&j (1- aae&j))
> > (SETQ aae0 (SSNAME aaelj aae&j))
> > (SETQ aae# (ENTGET aae0))
> > (SETQ aae1j (CDR (ASSOC 10 aae#)))
> > (SETQ aae$j (CDR (ASSOC 41 aae#)))
> > (IF (= aae?j "Relative")
> > (COMMAND "_.scale" aae0 "" "_none" aae1j aae0j)
> > (COMMAND "_.scale" aae0 "" "_none" aae1j (/ aae0j aae$j))
> > )
> > )
> > (PROMPT (STRCAT "\nBlock(s) scaled: " (ITOA aae#j)))
> > )
> > (DEFUN aaeOj (aae@ /)
> > (IF (/= aae@ "Function cancelled")
> > (PRINC aae@)
> > )
> > (SETQ *ERROR* aae|j)
> > (IF aae%j
> > (SETVAR "highlight" aae%j)
> > )
> > (COMMAND "_.undo" "_end")
> > (SETVAR "cmdecho" 1)
> > (PRINC)
> > )
> > (DEFUN C:BSC (/ aaeQ aae@ aae|j aaeQj aaelj)
> > (SETVAR "cmdecho" 0)
> > (COMMAND "_.undo" "_group")
> > (SETQ aae|j *ERROR*
> > *ERROR* aaeOj
> > )
> > (SETQ aae@ (STRCAT "Block Scale Version 5.1\n"
> > "Copyright"
> > (CHR 169)
> > " 1992-98 PowerLISP Solutions\n"
> > "All rights reserved.\n\n"
> > "Visit our web site at:\n"
> > "http://www.powerlisp.com"
> > )
> > )
> > (SETQ aaeQ (aaej aae@))
> > (IF aaeQ
> > (PROGN (SETQ aaeQj (aae% "Relative"))
> > (SETQ aaelj (aaeO aaeQ))
> > (IF aaelj
> > (aae@j aaeQj aaelj)
> > (ALERT "No objects found.")
> > )
> > )
> > )
> > (SETQ *ERROR* aae|j)
> > (COMMAND "_.undo" "_end")
> > (SETVAR "cmdecho" 1)
> > (PRINC)
> > )
> > (PRINC)
> >
> > --
> > A2Ki, SurvCad CES, Win98 se
> > Remove NO SPAM from my email address to email
> >
> > Jonathan J. Baker
> > R&R Engineers-Surveyors, Inc.
> > Denver, Colorado
> > _________________________
> > "Ed Matthews" wrote in message
> > news:3BD894FE.9060107@wmsenginc.com...
> >
> >>Luis, that was it. I do appreciate it very much. Forgive, but I have to
> >>ask. My blocks are at different scales, is there a routine you might
> >>have that could scale all blocks selected at one time?
> >>Thnks for everything
> >>Ed
> >>
> >>Luis Esquivel wrote:
> >>
> >>
> >>>Maybe I understood what you are looking for... 🙂
> >>>
> >>>(defun name (e v)
> >>> (setq
> >>>
> >>> lst
> >>> (subst (cons 2 v) (assoc 2 (entget e)) (entget e))
> >>> )
> >>> (entmod lst)
> >>> (entupd (cdr (assoc -1 lst)))
> >>>)
> >>>
> >>>(defun C:RBLOCKS (/ ss lth cont v)
> >>> (prompt "\nSelect block(s) to replace... ")
> >>> (setq ss (ssget '((66 . 1) (0 . "INSERT")))
> >>> lth (sslength ss)
> >>> cont 0
> >>> v (car (entsel "\nSelect target block: "))
> >>> )
> >>> (while (<= cont (- lth 1))
> >>> (name (ssname ss cont) (cdr (assoc 2 (entget v))))
> >>> (setq cont (1+ cont))
> >>> )
> >>> (princ)
> >>>)
> >>>
> >>>
> >>>
> >>>
> >
> >
>
Message 15 of 16
Anonymous
in reply to: Anonymous

Here is, now you can add more of your own and make it better, good luck...
-Luis

(defun name (e v sc)
(foreach f (list 2 41 42 43)
(entupd
(cdr
(assoc -1
(entmod
(subst (cons f
(if (= 2 f)
v
sc
)
)
(assoc f (entget e))
(entget e)
)
)
)
)
)
)
)

(defun C:RBLOCKS (/ ss lth cont v sc)
(prompt "\nSelect block(s) to replace... ")
(setq ss (ssget '((66 . 1) (0 . "INSERT")))
lth (sslength ss)
cont 0
v (car (entsel "\nSelect target block: "))
sc (getreal "\nScale factor: ")
)
(if (not sc)
(setq sc 1.0)
)
(while (<= cont (- lth 1))
(name (ssname ss cont) (cdr (assoc 2 (entget v))) sc)
(setq cont (1+ cont))
)
(princ)
)

(princ)
Message 16 of 16
Anonymous
in reply to: Anonymous

"Jon Baker"
> i found a lisp called bsc that will do that...
>
> (DEFUN aaej (aae@ / aaeQ)
> (INITGET 128 "About Select")
> (SETQ aaeQ (GETKWORD "\nSelect/: "))
> (COND ((= aaeQ "About") (ALERT aae@) (aaej aae@))
> ((= aaeQ "Select") (SETQ aaeQ (aael)))
> ((NULL aaeQ) NIL)
> ((NOT (TBLSEARCH "BLOCK" aaeQ))
> (ALERT (STRCAT "Block \"" aaeQ "\" is not defined."))
> (aaej aae@)
> )
> (T aaeQ)
> )
> )
> (DEFUN aael (/ aae&)
> (SETVAR "errno" 0)
> (SETQ aae& (ENTSEL (STRCAT "\nSelect block: ")))
> (COND ((= (GETVAR "errno") 7) (aael))
> ((NULL aae&) NIL)
> (T (aae1 aae&))
> )
> )
> (DEFUN aae1 (aae& / aae# aae0 aae$)
> (SETQ aae0 (CAR aae&))
> (SETQ aae# (ENTGET aae0))
> (SETQ aae$ (CDR (ASSOC 0 aae#)))
> (SETQ aaeQ (CDR (ASSOC 2 aae#)))
> (IF (NOT (EQ aae$ "INSERT"))
> (PROGN (ALERT "Requires a block selection.") (aael))
> (PROGN (PROMPT (STRCAT "\nBlock name: " aaeQ)) aaeQ)
> )
> )
> (DEFUN aaeO (aaeQ / aae|)
> (INITGET "Yes No ")
> (SETQ aae| (GETKWORD "\nScale blocks globally? : "))
> (IF (= aae| "No")
> (SSGET (LIST (CONS 2 aaeQ)))
> (SSGET "X" (LIST (CONS 2 aaeQ)))
> )
> )
> (DEFUN aae% (aae?j / aaejj)
> (IF (= aae?j "Relative")
> (PROGN (INITGET "Absolute Relative" 7)
> (SETQ aaejj (GETREAL "\nAbsolute/: "))
> )
> (PROGN (INITGET "Absolute Relative" 7)
> (SETQ aaejj (GETREAL "\nRelative/: "))
> )
> )
> (COND ((= aaejj "Absolute") (aae% "Absolute"))
> ((= aaejj "Relative") (aae% "Relative"))
> (T (LIST aae?j aaejj))
> )
> )
> (DEFUN aae@j (aaeQj aaelj / aae# aae0 aae&j aae?j aae1j aae#j aae0j
> aae$j)
> (SETQ aae?j (CAR aaeQj))
> (SETQ aae0j (CADR aaeQj))
> (SETQ aae&j (SSLENGTH aaelj)
> aae#j aae&j
> )
> (WHILE (> aae&j 0)
> (SETQ aae&j (1- aae&j))
> (SETQ aae0 (SSNAME aaelj aae&j))
> (SETQ aae# (ENTGET aae0))
> (SETQ aae1j (CDR (ASSOC 10 aae#)))
> (SETQ aae$j (CDR (ASSOC 41 aae#)))
> (IF (= aae?j "Relative")
> (COMMAND "_.scale" aae0 "" "_none" aae1j aae0j)
> (COMMAND "_.scale" aae0 "" "_none" aae1j (/ aae0j aae$j))
> )
> )
> (PROMPT (STRCAT "\nBlock(s) scaled: " (ITOA aae#j)))
> )
> (DEFUN aaeOj (aae@ /)
> (IF (/= aae@ "Function cancelled")
> (PRINC aae@)
> )
> (SETQ *ERROR* aae|j)
> (IF aae%j
> (SETVAR "highlight" aae%j)
> )
> (COMMAND "_.undo" "_end")
> (SETVAR "cmdecho" 1)
> (PRINC)
> )
> (DEFUN C:BSC (/ aaeQ aae@ aae|j aaeQj aaelj)
> (SETVAR "cmdecho" 0)
> (COMMAND "_.undo" "_group")
> (SETQ aae|j *ERROR*
> *ERROR* aaeOj
> )
> (SETQ aae@ (STRCAT "Block Scale Version 5.1\n"
> "Copyright"
> (CHR 169)
> " 1992-98 PowerLISP Solutions\n"
> "All rights reserved.\n\n"
> "Visit our web site at:\n"
> "http://www.powerlisp.com"
> )
> )
> (SETQ aaeQ (aaej aae@))
> (IF aaeQ
> (PROGN (SETQ aaeQj (aae% "Relative"))
> (SETQ aaelj (aaeO aaeQ))
> (IF aaelj
> (aae@j aaeQj aaelj)
> (ALERT "No objects found.")
> )
> )
> )
> (SETQ *ERROR* aae|j)
> (COMMAND "_.undo" "_end")
> (SETVAR "cmdecho" 1)
> (PRINC)
> )
> (PRINC)

Code critic (for a this one only):

To many lines for a very simple task...

Luis Esquivel
ArqCOM Software
www.arqcom.com.mx

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

Post to forums  

Autodesk Design & Make Report

”Boost