Freerefill Posted May 12, 2009 Share Posted May 12, 2009 ... you've vla-put-TextString'ed them all. Working on a LISP which will allow you edit the text nested in a block. I'll post it on here once I'm pleased with its functionality, but there's one piece of the puzzle I'm missing. The only information I have is that, in AutoCAD 2009, you were able to edit text within a block, but still allowed to only edit within a selection. My LISP will allow you edit the text, but the alteration is made for all blocks. Now, easiest thing to do is just edit the block name as well, yeah? That way, only one, unique entity gets altered (as per the single item selection functionality that the LISP currently has). But, I'm wondering, is there a better way that doesn't use the block name? A certain commando pointed out that if I change the name but have to re-insert the block, the edited block will not get replaced, as it is now called something else. Bottom line is, if one were to edit a block, in what ways would one edit it such that all other instances of the block would -not- get altered? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 12, 2009 Share Posted May 12, 2009 Could you not alter the attribute values using an Entmod method? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 12, 2009 Share Posted May 12, 2009 Or even something like this? [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:edAtt [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] ent[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ent [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]nentsel[/color][/b] [b][color=#ff00ff]"\nSelect Attribute: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=#ff00ff]"ATTRIB"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]0[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] ent[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-put-Textstring[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-ename->vla-object[/color][/b] ent[b][color=RED])[/color][/b] [b][color=#ff00ff]"It Works"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] Quote Link to comment Share on other sites More sharing options...
Freerefill Posted May 12, 2009 Author Share Posted May 12, 2009 Could you not alter the attribute values using an Entmod method? I didn't go down that road because I felt like I needed the added functionality of Visual LISP to make the whole thing work, but I will take another look into it. Also, whilst I'm at it, is there a way to update a VBA entity, much like one would use (entupd)? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 12, 2009 Share Posted May 12, 2009 I didn't go down that road because I felt like I needed the added functionality of Visual LISP to make the whole thing work, but I will take another look into it. Also, whilst I'm at it, is there a way to update a VBA entity, much like one would use (entupd)? I know very very little of VBA... someone else will have to answer that one.. Quote Link to comment Share on other sites More sharing options...
Freerefill Posted May 12, 2009 Author Share Posted May 12, 2009 Alright, just tried it and the entmod method has the same results: makes the appropriate change exactly like it should, but the entity doesn't change until the drawing is refreshed. Here's the code I used, you can see for yourself: (defun c:trr( / ) ;(vla-put-TextString (vlax-ename->vla-object (car (nentsel))) " ") (setq ent (car (nentsel))) (setq entlst (entget ent)) (setq entlst (subst (cons 1 " ") (assoc 1 entlst) entlst)) (entmod entlst) (entupd ent) ) The option for VLA is there as well, just commented out. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 12, 2009 Share Posted May 12, 2009 A quote from the ACAD help: Note If entupd is used on a nested entity (an entity within a block) or on a block that contains nested entities, some of the entities might not be regenerated. To ensure complete regeneration, you must invoke the REGEN command. Quote Link to comment Share on other sites More sharing options...
Freerefill Posted May 12, 2009 Author Share Posted May 12, 2009 awww man.. that sucks! You know, I had the same problem with my LISP games and GRREAD... I'm not sure what it was, but something returned by GRREAD was held on to, and I needed to regen the entire drawing in order to clear it so that it would accept another or nil input.. There really needs to be more flexibility with REGEN. It seems like it's either all or nothing, and that's odd for AutoCAD. What if I just wanted to regen blocks? Oh well.. I guess it'll be fine for now, until I find another solution. Thanks, Lee ^^ Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 12, 2009 Share Posted May 12, 2009 (redraw) is quicker, but I am not sure it will perform as well as "regenall" Quote Link to comment Share on other sites More sharing options...
Freerefill Posted May 13, 2009 Author Share Posted May 13, 2009 Tried "redraw", no dice, didn't update the altered text. "Regenall" would work but "regen" would be faster. (entmod)/(entupd) doesn't work. I tried using the "Refresh" and "Reload" ActiveX methods, but I've never used methods before so my failure in that attempt didn't entirely close that avenue. "Purge" and (gc) didn't work, not sure why they would but hey, worth the attempt. One thing that did work, though, was copying and pasting the block. That's such a hack method, but all things considered, faster than trying to regen a huge drawing with multiple layout tabs just so you can make one alteration to a titleblock. Alls that leaves is finding a way to edit a nested text entity within a block without altering every instance of said block. Honestly, I'm not entirely against creating a unique block name. But, if I must, then how does AutoCAD do it? Suppose you copy and paste as block, the block has a unique name. What formula does AutoCAD use to produce such a name? Quote Link to comment Share on other sites More sharing options...
ronjonp Posted May 13, 2009 Share Posted May 13, 2009 [quote name=.... Alls that leaves is finding a way to edit a nested text entity within a block without altering every instance of said block. Honestly' date=' I'm not entirely against creating a unique block name. But, if I must, then how does AutoCAD do it? Suppose you copy and paste as block, the block has a unique name. What formula does AutoCAD use to produce such a name?[/quote] You either use attributes (I'd recommend) or some sort of dynamic block. I know of no other way to achieve this. Why would you want a different block name for each text instance? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 13, 2009 Share Posted May 13, 2009 You either use attributes (I'd recommend) or some sort of dynamic block. I know of no other way to achieve this. Why would you want a different block name for each text instance? I'd be inclined to agree with Ron in this instance -- attributes are the easiest way to achieve this. Quote Link to comment Share on other sites More sharing options...
Freerefill Posted May 13, 2009 Author Share Posted May 13, 2009 AutoCAD 2009 allowed the user to edit a piece of text within a single instance of a single block. I know that sort of necessity does not crop up often, but it does, and I'd like to re-create it without having to re-create the block with an editable attribute in place of said text. Also, I don't know anything about dynamic blocks ^^' Quote Link to comment Share on other sites More sharing options...
ronjonp Posted May 13, 2009 Share Posted May 13, 2009 AutoCAD 2009 allowed the user to edit a piece of text within a single instance of a single block. I know that sort of necessity does not crop up often, but it does, and I'd like to re-create it without having to re-create the block with an editable attribute in place of said text. Also, I don't know anything about dynamic blocks ^^' I've never seen this behavior with blocks. Do you have a drawing that has an example? Quote Link to comment Share on other sites More sharing options...
Freerefill Posted May 13, 2009 Author Share Posted May 13, 2009 I've never seen this behavior with blocks. Do you have a drawing that has an example? Unfortunately not, the block text replace and Google geo-location tools were the only thing I liked about 2009, and the cons outweighed the pros.. so I went back to 2008. I'm not sure if anyone here is still using 2009. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted May 13, 2009 Share Posted May 13, 2009 Just noticed you are using Map 3D 2008 ... that's probably the reason I've never seen this as I use vanilla AutoCAD '09. Quote Link to comment Share on other sites More sharing options...
Freerefill Posted May 13, 2009 Author Share Posted May 13, 2009 The find and replace for text within blocks and (I just found out) external references should be a feature in AutoCAD 2009 and AutoCAD LT 2009. Try searching for text using "FIND" and look for more options. I recall there's a check-box there that will specify blocks. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted May 13, 2009 Share Posted May 13, 2009 I just tried that and it redefined the block (as it should). Quote Link to comment Share on other sites More sharing options...
Freerefill Posted May 13, 2009 Author Share Posted May 13, 2009 Hm.. I see.. well then my LISP does exactly the same thing, and mission (unknowingly) accomplished. I suppose, then, it would be an added functionality to set it as a unique block. Thanks for correcting me, Ron ^^ It's been a while since I've used 2009. Quote Link to comment Share on other sites More sharing options...
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.