Search the Community
Showing results for tags 'replace'.
Found 18 results
Find/replace text in blocks
LeeNichols posted a topic in AutoLISP, Visual LISP & DCLI have a block with about 60 single-line text entities, 40 of which have a place holder character that needs to change based on how the block is used. For example, "~1a" and "~1b" need to change to "P1a" and "P1b", where "~" is the place holder and "P" is the letter for this 1 block. The next instance of the same block will need a different letter. This is not a good application for attributes. I found Lee Mac's LISP c:ReplaceBlockText in this thread using vlax-for, but it appears to work on the block definition and changes the text for every instance of the block in the drawing. I need this to work on 1 selected instance of the block. Any help is appreciated, even if it's a point in the right direction.
Find and Replace, Wildcard not working??
jesset posted a topic in AutoCAD General
xref saved path find and replace: drawing name
dingleboy posted a topic in AutoLISP, Visual LISP & DCLHi guys, Long time reader, seldom if ever poster. I think I've got a good one this time and can't find a solution. I'm seeking to find and replace strings in hundreds of xref paths. It's not the path I need to change, but a string in the name of the drawing. For example: "otl" should be found and replaced with "int" *\PLANS\p_otl_001.dwg -> *\PLANS\p_int_001.dwg *\PLANS\p_otl_002.dwg -> *\PLANS\p_int_002.dwg I can quickly change the reference name using RENAME and the Reference Manager can change all paths, but affects only the file path and not the name of the drawing. REDIR with * wildcards doesn't work either. I've searched for hours for a script that will achieve this but I cannot seem to find one. Has anyone found a solution to this before? (I'll buy you many beers first chance I get.) Using AutoCAD Architecture 2012.
Replace multiple textstring
Zykl0 posted a topic in AutoLISP, Visual LISP & DCLHello, I try to find a lisp that will search and replace text within a user selection. This piece of code that I found on a very old forums on the net do almost exactly what I need. The only issue is I want to replace single word inside sentence and this code replace the word only if it's alone. (defun c:TRANSLATE() (command "cmdecho" "0") (command "_.undo" "begin") (setq mylist (list (list "APPLE" "PEAR") (list "BANANA" "STRAWBERRY") ) ) (setq sset (ssget '((0 . "TEXT")))) (setq i 0) (while (< i (sslength sset)) (setq obj (ssname sset i)) (setq str (cdr (assoc 1 (setq lst (entget obj))))) (princ str) (princ "\n") (foreach item mylist (if (eq str (nth 0 item)) (progn (setq newstr (nth 1 item)) (if newstr (entmod (subst (cons 1 newstr)(assoc 1 lst) lst)) ) ) ) ) (setq i (1+ i)) ) (command "cmdecho" "1") (command "_.undo" "end") ) Can someone modify it to make it work for me? Thank you
Replacing Non-Annotative blocks with Annotative blocks
SpotWesMom posted a topic in AutoCAD 2D Drafting, Object Properties & InterfaceHello! I have found every answer for every AutoCAD question that I have had in the past 9 months at this site and I love it!! Best. cad website. Ever. However, I finally have found something that someone else hasn't posted about yet (I think). My company is in the process of updating the entire block library to be annotative or dynamic (depending on the usage) and it's been wonderful for new projects. The problem comes in when we have to update an existing dwg. When we try to "blockreplace" the new annotative tags for the old non-annotative tags. These tags have attributes, but we have literally not changed anything about the blocks except the "annotativedwg" property within the root block file. When we run blockreplace, the old blocks disappear completely! they're not at a teeny scale or a gigantic scale, they're not on an "off" or "frozen" layer, they just fully go away even if you say "don't purge the old block that is being replaced". I usually don't have a problem "doing my job" and just going through and replacing them individually on the smaller sized projects, but most of our projects have upwards of 700 - 1000 tags per dwg. Slightly tedious as you can imagine, especially since I am addicted to finding newer faster better ways to draw. Any help is greatly appreciated! ~Amanda
kuttik posted a topic in AutoCAD 2D Drafting, Object Properties & InterfaceHello all. Kindly find attached drawing which shows simple reinforcement schedule. I have a problem with Texts which are shown in yellow color.When I click on one of them - for example 1∅16 L=1175 , at the properties area, I see text Contents 1%%O%%C%%O16. When I try to find 1∅16 I can't find anything. I tried searching %%C and Autocad found all of yellow texts. But when I select Replace All with ∅16 value, it becomes 1%%O%%∅%%O16. After that when i make search %%O%% or %%O or O%% ( I tried lots of combinations ) Autocad cant find anything so I cant change any value I have a lisp to use, and i have to find texts which include ∅ ( Char216) but i can't change contents of text. How can I change value of all contents ?? Reinforcement A.dwg
Replacing text in Autocad File using excel data?
rythem_of_the_nig posted a topic in AutoCAD 2D Drafting, Object Properties & InterfaceI have an autocad drawing with so many light fixtures with all different names.Now we have to change all those names, i already have an excel sheet containing two columns with first one containing "name in drawing" and second one containing respective "new name". Is there any way to replace the names in cad file using that excel sheet.i just dont want to do all those thousand rename manually ...please some cad-guru help me
Replacing Layers with other ones
Rubbersnow posted a topic in AutoCAD Drawing Management & OutputHey Guys, I have the following problem. I'm working on HVAC project and after I have almost finished the whole project the managers company sent me new template layers file ,that I should follow. So now my "17_COOL_MEPA_SUP" layer and all of his futures (including color,line thicknes and so on) need to be changed to "10_C_HVAC_S" with other futures (different color,different thicknes). I know that I can rename group of layers by using script file ,but can I totally replace group of layers with another group? P.S. I have 130 drawings ,so the manual method is not an option. HEEEEELLLLPPPPP!!!!
Find & Replace in current layout only
clint0577 posted a topic in AutoLISP, Visual LISP & DCLI have 2 things I'm trying to accomplish here. I need to find the the exact text to replace and only in the current layout. For example. Let's say I need to find "Date" but on the same layout I have "date", "Date" and "Date:". So it needs to be case sensitive also. I was using this but it's not case sensitive and also replaces "date" and "Date:" in all layouts. I just need "Date" in the current layout. ;Find And Replace (defun C:FAR () (setq OldTxt (getstring T "\nEnter the old text: ") NewTxt (getstring T "\nEnter the new text: ")) (setq ss (ssget "x" '((0 . "TEXT,MTEXT")))) (setq i (sslength ss)) (while (not (minusp (setq i (1- i)))) (setq oText (vlax-ename->vla-object (ssname ss i))) (setq Txt (vlax-get-property oText 'TextString)) (if (vl-string-search OldTxt txt) (progn (setq newChg (vl-string-subst NewTxt OldTxt txt)) (vlax-put-property oText 'TextString newchg) (vlax-invoke-method oText 'Update) ) ) ) (princ) )
Search and Replace exploded blocks?
wakeboarder205 posted a topic in AutoCAD 2D Drafting, Object Properties & InterfaceI have enough experience in Civil 3d to know I am 99% sure there is no way to do this, but I thought I would at least ask. We received a drawing in which every single block has been exploded, they are just a bunch of polylines now. The company we received it from says they don't have a drawing with the original blocks...sure... The long and the short of it is that we need to replace every exploded block with our standard blocks. Is there some crazy way to search and replace a pattern of lines or basically, search and replace the exploded blocks. A lisp routine, anything. There are thousands of exploded blocks by the way, thousands. Any ideas from people who have had similar problems would be greatly appreciated. Thanks!
Plaster work appearing on outside
fisher22 posted a topic in Architecture & ADTHi, this is probably really simple but i've just started using CAD so my apologies. I have to design a building as part of a uni project, i've drawn a floor plan with polylines but when i go to replace the polylines with walls, some of the walls have the plaster work on the outside and brickwork inside. Not too sure where im going wrong... thanks in advance for any help.
nth-replace (mergesort's achilles heel)
wishbonesr posted a topic in AutoLISP, Visual LISP & DCLI've completed MergeSort algorithm implementation in Autolisp based on Ellis Dee's vb6 version here: http://www.vbforums.com/showpost.php?p=2909257&postcount=12 The problem is that I need to replace nth atom in the lisp array, and the only way I can currently accomplish this, is by iterating the entire list. This takes, what would be a spectacular sorting algorithm, and destroys it's efficiency by iterating the list nth(log) times. I'm going to try not to muddy the water too much, but here is my nth-replace function based on Michels nth-remove function... (defun nth-replace (n_atom f_list f_n / ) ;replaced the nth element of a list ;n_atom is new atom ;f_list is list to be operated on ;f_n is the index that will be replaced (if (and (numberp f_n) (listp f_list)) (if (and (>= f_n 0) (< f_n (length f_list)) n_atom) (progn (repeat f_n (setq f_list (append (cdr f_list) (list (car f_list)))) ) (setq f_list (append (cdr f_list) (list n_atom))) (repeat (- (length f_list) f_n 1) (setq f_list (append (cdr f_list) (list (car f_list)))) ) ) ) ) f_list );defun I'm not completely new to autolisp, but I'm hoping there's a fundamental function I'm overlooking that can either replace an atom at a certain level, or can return a list up to a certain atom (nth instance), and then I can append my change, and then the latter half of the list.
LISP - Do routine if specific text is found in a specific block attribute
h0okem posted a topic in AutoLISP, Visual LISP & DCLI have a routine that replaces one block with another block based on the block name. I need help making it run only if a specific string of text is found in one of the attributes within the found block. Can someone help? Thanks. (defun c:name () (setvar "attreq" 0) (setq ssblocks (ssget "x" '((0 . "INSERT")))) (if ssblocks (progn (setq lstblockmap (txtfile2lst "C:\\path\\filename.txt" ) ) (setq lstblocks (sel2lst ssblocks)) (foreach enblock lstblocks (setq strblockname (car (getval (setq stroldname (strcase (getval 2 enblock))) lstblockmap ) ) ) (if strblockname (progn (prompt (strcat "****** " strblockname " found.******")) (progn ;;;;;Do more code ) ) (progn (prompt "No block definition, Skipping...") ) ) ) ) ) )
missing content of a file
Rubbersnow posted a topic in AutoCAD Generalsomething strange happened , I had open two files (work file and file to watch from) and somehow after closing AutoCad , the content of the work file is replaced by the content of the other one.It is same with the .bak file . Is there any chance to recover my previous work , somehow to go back in the history of that file? :shock:
"Top Down" Assembly Problem
malindenmoyer posted a topic in SolidWorksI have created a wing assembly using a "top down" approach. Essentially, I have planes spaced accordingly with airfoil profiles on each. I used these sketches as the "skeleton" of my model, with several features driven by the sketches. The problem is I need to delete a spline and replace it with another one, and I know that I will lose all the constraints linked to that original spline. Is there a way to avoid losing all the constraints? (I have tried replacing it, and it throws errors due to the original spline being deleted) I am trying to avoid having to go into each feature and redefine the constraints. Perhaps a solution to this problem would involve changing the name of the new spline to match the original. I have not figured out how to do this (after much research) nor do I know if its possible. Any help/suggestions is greatly appreciated.
PeterPan9720 posted a topic in AutoLISP, Visual LISP & DCLHi to everybody, Is there a way to modify the tools blocks replace available in Autocad Express Tools ?. I try to explain better : - The express tools blocks replaces "all" blocks inside the dwg comparing the name. - I would like to change only selected ones ? Is there a way to have access to express tools blocks replace "macro" and starting from that create another only for replace the selected one ?. Somebody think that could be easier create complete new tools for my issue ? Many thanks for all your support
Find and Replace "#"
brothersjohn posted a topic in AutoCAD Beginners' AreaI am running autocad electrical 2008. I have a set of blocks from a client that has the line numbers as "SHT#01". The idea was do a find and replace "SHT#" with the actual sheet number. The problem is the Find will not find "SHT#" it will find "SHT" and when I put in just "#" it finds numbers. So how do I do this. There are multiple sheets like this. Thanks, brothersjohn
Replace multiple blocks using a table
hosannabizarre posted a topic in AutoLISP, Visual LISP & DCLI have done a fair bit of web scouring to find a good method for replacing multiple blocks. There are some pretty decent vba codes out there for block replacement, the Office Optimum "Replace Block" tool, for instance worked okay, but you have to buy it. I have also found some effective .NET solutions for importing block definitions from another drawing to override the definitions in the current drawing. However I keep wondering if there is a good (free) solution for replacing and redefining large numbers of blocks using lisp. I am sure it must be doable. I know this has been discussed before here, but I haven't seen anything yet which uses a simple customisable table to handle lots of replacements at once (Please chastise me if I'm wrong). There are lots of 'piece meal' type block replacement lisps on offer, which rely on either specifying block names from drop down lists, or selecting blocks on the screen. I want something which handles lots of block exchanges at once. I would ideally like a lisp which allows me to set up a table of existing block names, with the filepath for the replacement block along side it. I would like it to resemble this lisp for renaming blocks (i.e. using a table): (defun c:renameb (/ btable badt) (setq btable '(("OLDNAME#1" . "NEWNAME#1") ("OLDNAME#2" . "NEWNAME#2") ("OLDNAME#3" . "NEWNAME#3") ("OLDNAME#4" . "NEWNAME#4") ("OLDNAME#5" . "NEWNAME#5"))) (foreach b btable (cond ((and (not (tblsearch "BLOCK" (cdr b))) (tblsearch "BLOCK" (car b))) (command "_.RENAME" "_Block" (car b) (cdr b))) ((tblsearch "BLOCK" (cdr b)) (setq badt (cons b badt))))) (and badt (prin1 badt) (alert "Unable To Rename All BLOCKs")) (prin1)) I want a block replacement lisp which uses a table to identify the filepath of the replacement block. I also want the routine to tell AutoCAD to replace the definition of any existing blocks with the same name as the one being brought in. Alanjt notes here that the use of the equals sign in the following line achieves that: (vl-cmdf "_.-insert" (strcat nb "=") nil) I also want to preserve the attribute values in the existing drawing. I want to be able to control the scale of the blocks being brought into the drawing as replacements. I want to ATTSYNC replacement blocks. Marijn incorporated the following in a reply to a thread posted yesterday. See here. (if (tblsearch "BLOCK" "OLDNAMEOFBLOCK") (progn (command "-rename" "b" "OLDNAMEOFBLOCK" "NEWNAMEOFBLOCK") (command "_.-insert" "NEWNAMEOFBLOCK=FILENAME" "y" nil);replaced convert template to new template. (command "_.attsync" "n" "NEWNAMEOFBLOCK") (scl 0.8 "NEWNAMEOFBLOCK");scales block to new scale (blknr13 "NEWNAMEOFBLOCK"); this was command to set a block the a layer. (not included can eb removed) )) This takes care of the ATTSYNC and the scale specification. I'd like the OLDNAMEOFBLOCK and NEWNAMEOFBLOCK to essentially be variables, which draw on a pre-defined table to derive values and then apply the commands. Is this possible? I guess I'd be just as happy to input all the values one by one in an unhealthily long code, but a more streamlined answer would be nice. By the by, Marijn's code aimed to incorporate replacing tag names also, when one block is replaced. Interesting. Haven't tried it out properly yet. I would greatly appreciate some assistance in addressing and integrating the requirements outlined above in one amazing 'table based' lisp. I have already sent a post card to Santa politely asking for this for Christmas, so if I'm unsuccessful here, I always have christmas day as a backup.