Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor
coachball8
Posts: 119
Registered: ‎03-12-2004
Message 1 of 17 (177 Views)

(setq e (entget (car (entsel)))) question

177 Views, 16 Replies
05-27-2004 03:56 AM
I need to select a block, then iterate thru the sub-entities to change all the mtext to a different layer. I can get
(setq d (assoc 8 e))
(setq e2 (subst '(8 . "mylayer") d e1))
(entmod e2), however, I can't seem to figure out to isolate the mtext. Another option would be to use nentsel and be able to select all the text at once, but nentsel doesn't allow me to do that. What's the best way to accomplish this? TIA
Distinguished Contributor
BillZ
Posts: 4,707
Registered: ‎12-12-2003
Message 2 of 17 (177 Views)

Re: (setq e (entget (car (entsel)))) question

05-27-2004 04:16 AM in reply to: coachball8
I don't know who posted this.

;9/11/02
;to find nested entities in block in a drawing;
;
;
;
;
(defun getNestedEnts (name / rtn)
(setq ename (tblobjname "block" name))
(while ename
(if (/= (cdr (assoc 0 (entget ename))) "INSERT")
(setq rtn (cons ename rtn))
(setq inn (cons ename inn))
)
(setq ename (entnext ename))
)
(reverse rtn)
)

I used it once and it seemed to work.

Bill I changed the description as it was a copy form another program.
Message was edited by: BillZ
Distinguished Contributor
coachball8
Posts: 119
Registered: ‎03-12-2004
Message 3 of 17 (177 Views)

Re: (setq e (entget (car (entsel)))) question

05-27-2004 04:33 AM in reply to: coachball8
Thanks Bill. I saw this post and tried it this way, but on line one I get an "error: bad argument type: stringp nil". Couldn't really figure out what the problem was with it, so I tried some other methods. Can't seem to get there. It's probably really simple once I see how it's done. Any other suggestions?
*Jamie Duncan
Message 4 of 17 (177 Views)

Re: (setq e (entget (car (entsel)))) question

05-27-2004 04:42 AM in reply to: coachball8
If it's mtext, then you must use the block name and do a tblsearch/tblnext thing, see comments and hints in following lisp (defun c:fixents (/ ss1 temp ent1 looper entdat bnm ctr enttyp bl_list) (command ".layer" "t" "0" "un" "0" "s" "0" "") (setq ss1 (ssadd) looper T ctr 0) (while looper (prompt "\nSelect Entities to set to Bylayer for Colour and Linetype: ");;;revise this (setq ss1 (ssget));;;revise this to filter for inserts (if ss1 (setq looper nil)) ) (repeat (sslength ss1) (setq ent1 (ssname ss1 ctr) entdat (entget ent1) enttyp (cdr (assoc 0 entdat))) (if (= enttyp "INSERT") (progn (setq bl_list (list (cdr (assoc 2 entdat)))) (foreach bnm bl_list (jddfixablock bnm) ) ) (progn (setq entdat (subst (cons 62 256)(assoc 62 entdat) entdat) entdat (subst (cons 6 "Bylayer")(assoc 6 entdat) entdat) ) (entmod entdat)(entupd ent1) ) ) (setq ctr (+ ctr 1)) ) (princ) ) (defun jddfixablock (bname / enam1 end1) (setq enam1 (tblobjname "block" bname)) (while (setq enam1 (entnext enam1)) (setq end1 (entget enam1) ;;;step thru block def ;;;put your test for mtext here ;;; end1 (subst (cons 62 256)(assoc 62 end1) end1)) ;;; end1 (subst (cons 6 "Bylayer")(assoc 6 end1) end1)) end1 (subst (cons 8 "0")(assoc 8 end1) end1)) ;;;make this the layer you want ) (entmod end1) ;;;end of mtext test ;;; if your block def contains an insert - get the block name of the insert and add it to our block name list (if (= (cdr (assoc 0 (entget enam1))) "INSERT")(setq bl_list (append bl_list (list (cdr (assoc 2 (entget ent1))))))) ) ) HTH Jamie Duncan "coachball8" wrote in message news:11304391.1085655427886.JavaMail.jive@jiveforum2.autodesk.com... > I need to select a block, then iterate thru the sub-entities to change all the mtext to a different layer. I can get > (setq d (assoc 8 e)) > (setq e2 (subst '(8 . "mylayer") d e1)) > (entmod e2), however, I can't seem to figure out to isolate the mtext. Another option would be to use nentsel and be able to select all the text at once, but nentsel doesn't allow me to do that. What's the best way to accomplish this? TIA
Distinguished Contributor
BillZ
Posts: 4,707
Registered: ‎12-12-2003
Message 5 of 17 (177 Views)

Re: (setq e (entget (car (entsel)))) question

05-27-2004 05:01 AM in reply to: coachball8
Works here.

(load "getNestedEnts")
(getNestedEnts "NameOfBlock")

Returns a list of enames with the block ename first.

But I don't have any really complex blocks to test.
What's in the blocks you are refering to?

Bill
Distinguished Contributor
coachball8
Posts: 119
Registered: ‎03-12-2004
Message 6 of 17 (177 Views)

Re: (setq e (entget (car (entsel)))) question

05-27-2004 05:07 AM in reply to: coachball8
It's just a rev block. Lines and text. Built on layer 0, inserted on the correct layer for the lines. The text is required to be on a different layer. I'd like to change the text layer with click of a toolbar button, if possible. We can't build the block on the correct layers, because different divisions of the company have different layer tables. However, we all use the same blocks, stored on a server. Just trying to save a few mouse clicks.
Distinguished Contributor
BillZ
Posts: 4,707
Registered: ‎12-12-2003
Message 7 of 17 (177 Views)

Re: (setq e (entget (car (entsel)))) question

05-27-2004 05:25 AM in reply to: coachball8
Well I just tried it again on a block that has 25 circles, lines and 3d faces and got the list just fine.

Can you post what your lisp looks like so someone may tell you what might be wrong?

Bill
Distinguished Contributor
coachball8
Posts: 119
Registered: ‎03-12-2004
Message 8 of 17 (177 Views)

Re: (setq e (entget (car (entsel)))) question

05-27-2004 05:28 AM in reply to: coachball8
I got it to work......I wasn't adding the block name at the command line. DUH! Thanks for the help, Bill. Long week. I'm ready for a vacation.
Distinguished Contributor
BillZ
Posts: 4,707
Registered: ‎12-12-2003
Message 9 of 17 (177 Views)

Re: (setq e (entget (car (entsel)))) question

05-27-2004 05:42 AM in reply to: coachball8
You're welcome.

Enjoy your vacation.

Bill
*Jürg Menzi
Message 10 of 17 (177 Views)

Re: (setq e (entget (car (entsel)))) question

05-27-2004 06:03 AM in reply to: coachball8
coachball8 You can't modify Block Inserts, you have to change the Block Reference: (defun BlkMod (Nme Lay / BlkTbl CurEnt EntLst) (setq BlkTbl (tblobjname "BLOCK" Nme) CurEnt (cdr (assoc -2 (entget BlkTbl))) ) (while (setq CurEnt (entnext CurEnt)) (setq EntLst (entget CurEnt)) (if (eq (cdr (assoc 0 EntLst)) "MTEXT") (entmod (subst (cons 8 Lay) (assoc 8 EntLst) EntLst ) ) ) ) (entupd BlkTbl) (command "_.REGEN") (princ) ) Use: (BlkMod "MyBlockName" "NewLayer") Cheers -- Juerg Menzi MENZI ENGINEERING GmbH, Switzerland http://www.menziengineering.ch
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.