|
|
|
Last edited by BlackBox; 2013-08-28 at 06:31 PM.
"How we think determines what we do, and what we do determines what we get."
Sincpac C3D ~ Autodesk Exchange Apps
Computer Specs:
Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000
Could you post a sample drawing?
"How we think determines what we do, and what we do determines what we get."
Sincpac C3D ~ Autodesk Exchange Apps
Computer Specs:
Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000
Sorry, I'm really short on time right now... So this brute-force sample will have to do for now (undo supported)... I'll come back to refine it later.
HTH
... Example from command line:Code:(vl-load-com) (defun c:FIND+ (/ *error* _ReplaceString pattern newString acDoc oBlocks objectName blockDef ) (defun *error* (msg) (if acDoc (vla-endundomark acDoc) ) (cond ((not msg)) ; Normal exit ((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit) ((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it ) (princ) ) (defun _ReplaceString (obj) (if (wcmatch (vla-get-textstring obj) pattern) (vla-put-textstring obj newString) ) ) (if (and (setq pattern (getstring T "\nEnter string pattern to search for: ") ) (setq newString (getstring T "\nEnter new string: ")) ) (progn (vla-startundomark (setq acDoc (vla-get-activedocument (vlax-get-acad-object))) ) (setq oBlocks (vla-get-blocks acDoc)) (foreach y '(modelspace paperspace) (vlax-for x (vlax-get acDoc y) (cond ((= "AcDbBlockReference" (setq objectName (vla-get-objectname x)) ) (if (and (= "AcDbBlockReference" (vla-get-objectname x)) (= :vlax-true (vla-get-hasattributes x)) (setq blockDef (vla-item oBlocks (vla-get-effectivename x) ) ) ) (foreach att (vlax-invoke x 'getattributes) (vlax-for item blockDef (if (= "AcDbAttributeDefinition" (vla-get-objectname item) ) (progn (if (= (vla-get-tagstring att) (vla-get-tagstring item) ) (_ReplaceString att) ) ) ) ) ) ) ) ((wcmatch objectName "AcDbMText,AcDbText") (_ReplaceString x) ) ) ) ) ) ) (*error* nil) )
Code:Command: find+ Enter string pattern to search for: EL. * Enter new string: EL. SEE PLAN Command:
Last edited by BlackBox; 2013-08-28 at 09:12 PM.
"How we think determines what we do, and what we do determines what we get."
Sincpac C3D ~ Autodesk Exchange Apps
Computer Specs:
Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000
While BlackBox's code skills are impressive, for those that don't want to mess with a lisp routine and use the built-in find/replace...
Thought I would post something mildly helpful for my first post...
It is not a bug. The reason that the wild card isn't working, is that there is no "end" to the search string.
For example, if you had a mtext paragraph (or line of text for that matter) that stated:
"...blah, blah blah modEL. some more text etc, etc...."
the EL. * replace would overwrite EVERYTHING after [modEL. ] even if what followed happened to be hundreds of characters long, and we don't want it to work like that (except in the OP's specific case for this specific drawing that doesn't have any other occurrence of "EL. ")
To find/replace the elevation instead of adding to the string:
Find: EL. *" <---(add the inch mark to give the wild card and "ending")
Replace: EL. SEE PLAN
(Found text = EL. 100'-0" , Modified text = EL. SEE PLAN)
So to clarify; in the EL.[space][wildcard] search, the [wildcard] isn't really doing anything, but adding the inch mark - EL.[space][wildcard]["] - finds strings that adhere to EL. *[whatever is here]".
Hope that makes sense..
First of all.... Welcome to AUGI and congrats on your first post!
Second of all.. HOLY CR@P!, thanks!
Is this a new thing?
I have done this lots and lots of times before with a simple "*" wild-card and it has worked well, at least with lower versions of AutoCAD.
According to 'HELP the asterisk is supposed to match any string, so it's assumed that (EL. *) would be selecting and replacing everything after EL.<space>.
Is there anywhere this is documented so I/we can find out more?
Thanks.
That is kind of you to say, reidcharley... In deed, welcome to AUGI, and congrats on your first post!
Hoping that I had simply been overlooking the built-in functionality, I tried it (your suggestion of EL. *") on the sample drawing tedg uploaded here, and I was unsuccessful (see pics attached)... What version(s) are you using that this methodology is successful?
Cheers
Last edited by BlackBox; 2013-08-29 at 12:39 PM.
"How we think determines what we do, and what we do determines what we get."
Sincpac C3D ~ Autodesk Exchange Apps
Computer Specs:
Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000
Last edited by tedg; 2013-08-29 at 01:47 PM. Reason: TESTED, ADDED SCREEN SHOT
"How we think determines what we do, and what we do determines what we get."
Sincpac C3D ~ Autodesk Exchange Apps
Computer Specs:
Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000
Thanks -- that makes sense.
I'll cordially disagree though, with the statement that it's not a bug. It may be working as designed, but it's still a bug inasmuch as it does NOT work as expected, nor is it consistent with other uses of the '*' as a wildcard character that I've encountered in 30 years. Invariably the * has meant 'from here on to the end'. that end may be a 'end of line', end of string, or a predefined delimiter (eg the period in a dos filename).
so: "the EL. * replace would overwrite EVERYTHING after [modEL. ] even if what followed happened to be hundreds of characters long, and we don't want it to work like that "
is incorrect -- as I _do_ want and expect it to work like that. I can see advantages to having an ending character, but in the case of No Ending Character being supplied, the asterix should be a wcmatch the remainder of the string.