Jadeous Posted March 30, 2009 Posted March 30, 2009 I have this lsp I use to renumber the text attribute in a block I use. I love the way the Lsp works. Problem is that it only allows me to change one block attribute at a time. I would like to be able to change several at once. Please help. renum.lsp Quote
uddfl Posted March 30, 2009 Posted March 30, 2009 What do you mean by several at once? Like selecting a group of blocks with a window? If that's what you want to do, how would the program know the order of the numbers? Quote
Jadeous Posted March 30, 2009 Author Posted March 30, 2009 I would need it to behave much in the same way as the Renumber Command. I would like to have the option to either select one at atime in a specific order or groups at random. Quote
Lee Mac Posted March 30, 2009 Posted March 30, 2009 Give this a shot - very quickly modded ~ errors expected (defun c:renum (/ oldPref oldSuf oldStart curText curStr vlaObj keepText) (vl-load-com) (defun TTC_Paste (pasteStr keepText / sslst vlaObj) (if (setq ss (ssget)) (progn (setq sslst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))) (foreach ent sslst (cond ((= "DIMENSION" (cdr (assoc 0 (entget ent)))) (setq vlaObj (vlax-ename->vla-object ent) oldStat (vla-get-Measurement vlaObj)) (if keepText (if (= (vla-get-TextOverride vlaObj) "") (setq pasteStr (strcat pasteStr (rtos oldStat (vla-get-UnitsFormat vlaObj) (vla-get-PrimaryUnitsPrecision vlaObj)))) (setq pasteStr (strcat pasteStr (vla-get-TextOverride vlaObj))))) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-TextOverride (list vlaObj pasteStr))) (princ "\n Can't paste. Object may be on locked layer. "))) ; end condition #1 ((= "ACAD_TABLE" (cdr (assoc 0 (entget ent)))) (setq vlaObj (vlax-ename->vla-object ent)) (if keepText (setq pasteStr (strcat pasteStr (vla-get-TextString vlaobj)))) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-TextString (list vlaObj pasteStr))) (princ "\nError. Can't paste text. ") (entupd ent))) ; end condition # 2 ((= "INSERT" (cdr (assoc 0 (entget ent)))) (princ "\nCan't paste to block's DText or MText. ")) ; end condition #3 ((member (cdr (assoc 0 (entget ent))) '("TEXT" "MTEXT" "ATTRIB" "ATTDEF")) ; end and (setq vlaObj (vlax-ename->vla-object ent)) (if keepText (setq pasteStr (strcat pasteStr (vla-get-TextString vlaobj)))) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-TextString (list vlaObj pasteStr))) (princ "\nError. Can't pase text. "))) ; end condition #4 (T (princ "\nCan't paste. Invalid object. ")) ; end condition #5 )) T) ; end progn nil) ; end if ) ;_TTC_PASTE (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (vla-StartUndoMark aDoc) (if (not rnm:Pref) (setq rnm:Pref "")) (if (not rnm:Suf) (setq rnm:Suf "")) (if (not rnm:Start) (setq rnm:Start 1)) (setq oldPref rnm:Pref oldSuf rnm:Suf oldStart rnm:Start) ; end setq (setq rnm:Pref (getstring T (strcat "\nType prefix: : "))) (if (= "" rnm:Pref) (setq rnm:Pref oldPref)) (if (= " " rnm:Pref) (setq rnm:Pref "")) (setq rnm:Suf (getstring T (strcat "\nType suffix: : "))) (if (= "" rnm:Suf) (setq rnm:Suf oldSuf)) ;(if(= " " rnm:Suf)(setq rnm:Suf "")) (setq rnm:Start (getint (strcat "\nEnter start number (itoa rnm:Start) ">: "))) (if (null rnm:Start) (setq rnm:Start oldStart)) (initget "Yes No Ä Quote
Jadeous Posted March 30, 2009 Author Posted March 30, 2009 This is what it told me. I need to change only the attribute inside the block (the middle number) I will attach the block I am using. Open then explode once. Points Block.dwg Quote
Lee Mac Posted March 30, 2009 Posted March 30, 2009 I don't see how you could be getting that return, when the phrase " No Viewports Found " Doesn't feature in the LISP you are running - sounds like a previous LISP's error definition to me. I had only looked at it quickly - will take another look. EDIT; could you post the drawing in 2000 format please - only using '04 here Quote
Lee Mac Posted March 30, 2009 Posted March 30, 2009 I know what the problem is - the LISP uses nentsel to provide information about the attributes and attribute definitions, or text, if selected within a block. This information cannot be readily obtained using an ssget method without some more coding. Quote
Jadeous Posted March 31, 2009 Author Posted March 31, 2009 The " No Viewports Found " was not due to the command. It was from the command just after that renum command. I just scrolled up to the renum sequence. Here is the block in ACAD 2000 ACAD-2000-Points Block.dwg Quote
Jadeous Posted March 31, 2009 Author Posted March 31, 2009 Yes. The "renum" lisp I currently use offers the option to add a suffix and a preffix or both. The current block I am working with have a preffix and no suffix. I never know when I'll need one or the other. Quote
Lee Mac Posted March 31, 2009 Posted March 31, 2009 Yes. The "renum" lisp I currently use offers the option to add a suffix and a preffix or both. The current block I am working with have a preffix and no suffix. I never know when I'll need one or the other. The only reason I ask is that I very much doubt that you will be able to "tweak" that LISP for multiple selection, without just re-writing it completely. As I have probably mentioned earlier, the LISP uses an nentsel method to select the entities and so certain information is obtained upon user selection - this information cannot be retrieved as easily with a selection set method of entity selection. I was considering just writing a similar LISP for you - which is why I asked the question. Do you just want to increase the number in the Attribute, or is it something more? Quote
Jadeous Posted March 31, 2009 Author Posted March 31, 2009 I use a lisp that you helped me with before to populate points with this block. They come out in numeric order. Once I have placed the blocks, people need to erase or add to the set of blocks I already did. This creates either missing numers or I need to add more. So, Finding the highest numbered block can be a pain and renumbering from a certain number foward equally sucks. I would much rather preffer to select all and tell them to renumber. This would be a sure method to prevent like or missing numbers. Quote
Lee Mac Posted April 1, 2009 Posted April 1, 2009 I use a lisp that you helped me with before to populate points with this block. They come out in numeric order. Once I have placed the blocks, people need to erase or add to the set of blocks I already did. This creates either missing numers or I need to add more. So, Finding the highest numbered block can be a pain and renumbering from a certain number foward equally sucks. I would much rather preffer to select all and tell them to renumber. This would be a sure method to prevent like or missing numbers. I may be missing something crucial here, but can't you just use the LISP you used to populate the points in the first place (the one I helped you on), to re-populate the blocks? Quote
Jadeous Posted April 1, 2009 Author Posted April 1, 2009 I find that It is easier to adjust a few rather than readjust many. As the job I am on progresses I cannot change the blocks that have already been refferenced. In a cooridor that contains 250 blocks, the crew may have already built stands using the blocks a refference up to say number 215. I cannot go back erase the blocks and repopulate the points. Due to the radom nature of the populating lisp, the numbering pattern may change. Now I would not have the correct numbers to match theirs. So if i was asked to change the remaining 35 blocks by adding or deleting some of them, they would now be out of sequence. My current method would be the use my current renum lisp to select each remaining blocks attribute in turn to change them be in numeric order. Also another problem is that I do not always have the original points dwg to repopulate, I will only have the blocks dwg. Our blocks are kept in a separate dwg from the main dwg. Like I said, I love the nature of my current lisp. I only wish to add the multiple option. Quote
Jadeous Posted April 6, 2009 Author Posted April 6, 2009 Still need help on this one. Any takers? Quote
Lee Mac Posted April 6, 2009 Posted April 6, 2009 Just wrote this one quickly - may be what you are after: (defun c:reNum (/ dCars tmpVars ss att) (setq dVars '(sNum inNum Pref Suff)) (mapcar '(lambda (x y) (or (boundp x) (set x y))) dVars '(1 1 "" "")) (setq tmpVars (list (getreal (strcat "\nSpecify Starting Number <" (rtos sNum 2 2) ">: ")) (getreal (strcat "\nSpecify Increment <" (rtos inNum 2 2) ">: ")) (getstring t (strcat "\nSpecify Prefix <" (if (eq "" Pref) "-None-" Pref) ">: ")) (getstring t (strcat "\nSpecify Suffix <" (if (eq "" Suff) "-None-" Suff) ">: ")))) (mapcar '(lambda (x y) (or (or (not x) (eq "" x)) (set y x))) tmpVars dVars) (while (not ss) (princ "\nSelect Blocks to ReNumber... ") (setq ss (ssget '((0 . "INSERT") (66 . 1))))) (foreach blk (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (setq att (entnext blk)) (while (not (eq "SEQEND" (cdadr (setq aLst (entget att))))) (if (eq "POINT" (cdr (assoc 2 aLst))) (entmod (subst (cons 1 (strcat Pref (rtos sNum) Suff)) (assoc 1 aLst) aLst))) (setq att (entnext att))) (setq sNum (+ sNum inNum))) (command "_regenall") (princ)) Quote
Jadeous Posted April 6, 2009 Author Posted April 6, 2009 That didn't work Lee. Maybe the problem lays in the section of the whole block instead of just the Attribute in the center of the block. My original lisp only worked when I would select the attribute not the whole block itself. So I'm guessing that if their was a way to window select only the attribute, this would easier to solve. Just to be clear. In the block I am reffering to, amoung the three lines of text in the block, only the center text is an atrribute. the other lines, top and bottom, are only Dtext. Quote
Lee Mac Posted April 6, 2009 Posted April 6, 2009 That didn't work Lee. Maybe the problem lays in the section of the whole block instead of just the Attribute in the center of the block. My original lisp only worked when I would select the attribute not the whole block itself. So I'm guessing that if their was a way to window select only the attribute, this would easier to solve. Just to be clear. In the block I am reffering to, amoung the three lines of text in the block, only the center text is an atrribute. the other lines, top and bottom, are only Dtext. My apologies mate - left an old attribute name in it. -- code updated Quote
Jadeous Posted December 8, 2009 Author Posted December 8, 2009 Hello. I have revisited this thread due to the fact that this Lisp does not work in ACAD 2008, only 2006. Also I still am not able to renumber multiple blocks with attributes at once. As it is now (in ACAD-2006), the Lisp requires that I must highlight the attribute itself without touching any other part of the block, otherwise the command will end. My ideal Lisp would work in ACAD-2008, and enable me to window select multiple blocks at once to be renumbered. I like the basic structure of my existing lisp. I just need a few tweaks to it. And thank you Lee Mac for providing me with the original Lisp. In the thread above is the "renum.lsp" and the ACAD-2000-Points Block dwg. Thank you for any help. Quote
ILoveMadoka Posted December 9, 2009 Posted December 9, 2009 Can someone explain this?? (initget "Yes No Ä�* Íåò _Yes No Yes No") I'm very confused!! thx! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.