woodman78 Posted March 27, 2013 Posted March 27, 2013 I have had a request from the guys in our drawing office. We insert Map Tiles to form background mapping. That means searching a paper drawing for the correct number and trawling through directories to find the correct tiles and inserting them. I am thinking of creating a drawing that will have "thumbnails" which would be just a rectangle with the map tile number in it so that when the user selects some "thumbnails" a new drawing is opened and the correct tiles are inserted. I am wondering if anybody has done this or something like it before? Thanks, Brian. Quote
BIGAL Posted March 28, 2013 Posted March 28, 2013 Did it like 20 years ago just create a grid with text lables a very simple under lying map so you know where you are pick text and then run insert correct image, use STRCAT in lisp to add directory to lable name, we had multiple layers of tiles so used a custom side menu to pick style of tile image, block, nottes etc not real code (setq gridder (Entsel "pick grid lable)) do normal pull out gridtext plus work out the insert pt in real worl co0ords based on text insertion point -xinc -yinc (setq gridname (strcat "c:\mydir\images" gridtext)) (command "insertimage" gridname pt 1 1 ) You could do something like auto open up grid dwg pick grid close it and insert image into original dwg without multiple user input. Quote
woodman78 Posted March 28, 2013 Author Posted March 28, 2013 Thanks Bigal, You gave me some ideas. Let me explain a bit more about the setup. Our maps are split into 1:5000, 1:2500, 1:1000. They are in 3 subdirectories of the mapping folder. I don't have permission nor do I wish to change the folder structure of this in any way. I wish to lift the tiles out of it. The files names in each folder are as follows: (see image below). 1:5000 Map tile number, no additions - (example) 5411.dwg 1:2500 Map tile number plus A,B,C or D - (example) 5411-A.dwg 1:1000 Map tile number plus 1 to 25 - (example) 5411-18.dwg (Edit: Each map tile could have a 1:5000, along with several 1:2500 and 1:1000 to complete the full tile and it varies from tile to tile) This is the code I have now: (defun c:Getmaptile (/ bn chk pp bnloc) (setq bn "" chk nil); set block name nil (while (= chk nil) (setq chk (entsel "\nPick a Block: ")) ) (setq pp (cadr chk)) (setq chk (entget (car chk))) (setq bn (cdr (assoc 2 chk))); get block name (setq bnloc (strcat "M:\\os\\Maps\\AutoCAD\\2500\\" bn "-D")) (command "_.-insert" bnloc "0,0,0" "1" "1" "0") (princ) ) This code works in that it will insert the tile as set out in the code and insert it into the current drawing. I need to get the code to search the "M:\\os\\Maps\\AutoCAD\\" directory for all blocks beginning with the four digits from the block "thumbnail" I select in the drawing. But I need to put them in a new drawing...... Can someone help me with how to go on from here? I have tried to create a new drawing based on a template but the code creates the drawing but then reverts to the original drawing... Thanks. Quote
woodman78 Posted March 28, 2013 Author Posted March 28, 2013 Progress in the last hour. I found this link: http://www.cadtutor.net/forum/showthread.php?57051-Use-Lisp-to-search-amp-insert-multiple-drawings-as-blocks. And so I incorporated it into the code and it runs fine with the exception of the new drawing. I need to launch a new drawing and insert the blocks into that.... Also would it be possible to select multiple blocks and insert all the blocks for the those selected.... Anyway, this is what I have.. (defun c:Getmaptile (/ bn chk pp bnloc) (setq bn "" chk nil); set block name nil (while (= chk nil) (setq chk (entsel "\nPick a Block: ")) ) (setq pp (cadr chk)) (setq chk (entget (car chk))) (setq bn (cdr (assoc 2 chk))); get block name ;(setq bnloc (strcat "M:\\os\\Maps\\AutoCAD\\2500\\" bn)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\5000\\" bn "*.dwg"))) (foreach Dwg Drawings (command "_.insert" Dwg "0,0,0" "1" "1" "0") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\2500\\" bn "*.dwg"))) (foreach Dwg Drawings (command "_.insert" Dwg "0,0,0" "1" "1" "0") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\1000\\" bn "*.dwg"))) (foreach Dwg Drawings (command "_.insert" Dwg "0,0,0" "1" "1" "0") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;(command "_.-insert" bnloc "0,0,0" "1" "1" "0") (princ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Function to list files from a wildcard match (defun matchfiles (path / item dir match lst fil files) (setq path (strsplit "," path)) (foreach item path (setq dir (strcat (vl-string-right-trim "\\" (vl-filename-directory item)) "\\") match (substr item (1+ (strlen dir))) lst (vl-directory-files dir match 1) ) (foreach fil lst (setq files (cons (strcat dir fil) files)) ) ) (reverse files) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Function to split a string on a specified character (defun strsplit (c str / lst p n) (setq n 0) (while (setq p (vl-string-search c str n)) (setq lst (cons (substr str (1+ n) (- p n)) lst)) (setq n (1+ p)) ) (if (< n (strlen str)) (setq lst (cons (substr str (1+ n)) lst)) ) (reverse lst) ) Quote
BIGAL Posted March 29, 2013 Posted March 29, 2013 (edited) You will need to go down the script path so you can open a new dwg and keep going, I would use what you have remove "insert" and change to write file insert new dwg etc use ssget rather than entsel then you can pick 1 or more grid lables do another foreach encompassing all the code. Why not text for grid lables ? Same method as blocks Last line of code is SCRIPT TILES (setq fout (open "C:\acadtemp\tiles.scr" "w")) (setvar "filedia" 0) (write-line "new " fout) ; note 2 spaces check for using default dwt etc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\5000\\" bn "*.dwg"))) (foreach Dwg Drawings ;(command "_.insert" Dwg "0,0,0" "1" "1" "0") (setq dwgtile (strcat "_.insert" dwg "0,0,0" "1" "1" "0")) (Write-line dwgtile fout) ) (close fout) ; last line (command "script" "C:\acadtemp\tiles") Edited April 3, 2013 by BIGAL Quote
woodman78 Posted April 2, 2013 Author Posted April 2, 2013 Bigal, Thanks for the help. I am only back in the office today. We have a long holiday weekend in Ireland for Easter. I am trying to figure out how to incorporate what you gave me into the code. I get that the "insert" gets replaced. But what about the script at the end? What script do I need to store at that location? Also how do I use "grid labels" as you suggest? I have never used nor heard of them before and that is why I chose to use blocks.. Thanks. Quote
woodman78 Posted April 2, 2013 Author Posted April 2, 2013 This is what I have Bigal but I am getting an error on loading: (defun c:Getmaptile (/ bn chk pp bnloc) (setq bn "" chk nil); set block name nil (while (= chk nil) (setq chk (ssget "\nPick a Block: ")) ) (setq pp (cadr chk)) (setq chk (entget (car chk))) (setq bn (cdr (assoc 2 chk))); get block name [color="red"](setq fout (open "C:\acadtemp\tiles.scr "w")) (setvar "filedia" 0) (write-line "new " fout) ; note 2 spaces check for using default dwt etc[/color] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\5000\\" bn "*.dwg"))) (foreach Dwg Drawings [color="red"] ;(command "_.insert" Dwg "0,0,0" "1" "1" "0") (setq dwgtile (strcat "_.insert" dwg "0,0,0" "1" "1" "0")) (Write-line dwgtile fout) (close fout) )[/color] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\2500\\" bn "*.dwg"))) (foreach Dwg Drawings [color="red"] ;(command "_.insert" Dwg "0,0,0" "1" "1" "0") (setq dwgtile (strcat "_.insert" dwg "0,0,0" "1" "1" "0")) (Write-line dwgtile fout) (close fout) )[/color] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\1000\\" bn "*.dwg"))) (foreach Dwg Drawings [color="red"] ;(command "_.insert" Dwg "0,0,0" "1" "1" "0") (setq dwgtile (strcat "_.insert" dwg "0,0,0" "1" "1" "0")) (Write-line dwgtile fout) (close fout) )[/color] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (princ) ) [color="red"](command "script" "C:\acadtemp\tiles")[/color] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Function to list files from a wildcard match (defun matchfiles (path / item dir match lst fil files) (setq path (strsplit "," path)) (foreach item path (setq dir (strcat (vl-string-right-trim "\\" (vl-filename-directory item)) "\\") match (substr item (1+ (strlen dir))) lst (vl-directory-files dir match 1) ) (foreach fil lst (setq files (cons (strcat dir fil) files)) ) ) (reverse files) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Function to split a string on a specified character (defun strsplit (c str / lst p n) (setq n 0) (while (setq p (vl-string-search c str n)) (setq lst (cons (substr str (1+ n) (- p n)) lst)) (setq n (1+ p)) ) (if (< n (strlen str)) (setq lst (cons (substr str (1+ n)) lst)) ) (reverse lst) ) Can you have a look please? Thanks. Quote
BIGAL Posted April 3, 2013 Posted April 3, 2013 Mistake by me "C:\acadtemp\tiles.scr "w" missing " "C:\acadtemp\tiles.scr" "w" Fixed above Quote
woodman78 Posted April 3, 2013 Author Posted April 3, 2013 Bigal, I made that change to the code to get this: (defun c:Getmaptile (/ bn chk pp bnloc) (setq bn "" chk nil); set block name nil (while (= chk nil) (setq chk (ssget "\nPick a Block: ")) ) (setq pp (cadr chk)) (setq chk (entget (car chk))) (setq bn (cdr (assoc 2 chk))); get block name (setq fout (open "C:\acadtemp\tiles.scr" "w")) (setvar "filedia" 0) (write-line "new " fout) ; note 2 spaces check for using default dwt etc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\5000\\" bn "*.dwg"))) (foreach Dwg Drawings ;(command "_.insert" Dwg "0,0,0" "1" "1" "0") (setq dwgtile (strcat "_.insert" dwg "0,0,0" "1" "1" "0")) (Write-line dwgtile fout) (close fout) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\2500\\" bn "*.dwg"))) (foreach Dwg Drawings ;(command "_.insert" Dwg "0,0,0" "1" "1" "0") (setq dwgtile (strcat "_.insert" dwg "0,0,0" "1" "1" "0")) (Write-line dwgtile fout) (close fout) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\1000\\" bn "*.dwg"))) (foreach Dwg Drawings ;(command "_.insert" Dwg "0,0,0" "1" "1" "0") (setq dwgtile (strcat "_.insert" dwg "0,0,0" "1" "1" "0")) (Write-line dwgtile fout) (close fout) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (princ) ) (command "script" "C:\acadtemp\tiles") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Function to list files from a wildcard match (defun matchfiles (path / item dir match lst fil files) (setq path (strsplit "," path)) (foreach item path (setq dir (strcat (vl-string-right-trim "\\" (vl-filename-directory item)) "\\") match (substr item (1+ (strlen dir))) lst (vl-directory-files dir match 1) ) (foreach fil lst (setq files (cons (strcat dir fil) files)) ) ) (reverse files) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Function to split a string on a specified character (defun strsplit (c str / lst p n) (setq n 0) (while (setq p (vl-string-search c str n)) (setq lst (cons (substr str (1+ n) (- p n)) lst)) (setq n (1+ p)) ) (if (< n (strlen str)) (setq lst (cons (substr str (1+ n)) lst)) ) (reverse lst) ) Whenever I try to run it I get the following error: GETM ; error: bad point argument Any ideas what this could be? Quote
jammie Posted April 3, 2013 Posted April 3, 2013 Hi woodman78, The source of the error message is from this line (setq chk (ssget "\nPick a Block: ")) You'll need to use entsel instead if ssget in this case Regards jammie Quote
woodman78 Posted April 3, 2013 Author Posted April 3, 2013 Thanks Jammie, but even when I do set it to "entsel" I get the following: Command: GETMAPTILE Pick a Block: new _.insertM:\os\Maps\AutoCAD\2500\6301-A.dwg0,0,0110 ; error: bad argument type: streamp nil Bigal said that entsel can only be used to select 1 block whereas ssget needs to be used to select multiple. I need to select multiple blocks. How do I incorporate ssget correctly into the code? Quote
woodman78 Posted April 3, 2013 Author Posted April 3, 2013 Jammie, I don't know if I have placed the code for calling the script in the correct place or not. Could you have a look? Thanks. Quote
neophoible Posted April 3, 2013 Posted April 3, 2013 Hi woodman78, The source of the error message is from this line (setq chk (ssget "\nPick a Block: ")) You'll need to use entsel instead if ssget in this case Regards jammie Well, jammie is right that the statement won't work as is, but using ssget is OK, as BigAl suggests; it just doesn't accept a msg. Simply do your prompting outside of ssget. Smth like this: (prompt "\nPick Block(s)...") (setq chk (ssget)) Quote
woodman78 Posted April 3, 2013 Author Posted April 3, 2013 Thanks Neophoible, I added that and got this error message: ; error: bad argument type: consp <Selection set: 144d> Does that mean it isn't forming the selection set? Do I need to set anything else before using the prompt that way? Quote
neophoible Posted April 3, 2013 Posted April 3, 2013 Sorry, I was not trying to go through the code, just noting that it's OK to use ssget. The "problem" you will have is that handling a set of entities is not the same as handling a single entity. You will need to look at how selection sets work. It isn't that hard, but you will find that you need to loop through the set and handle each entity. In most cases, it is better to make a subroutine that handles a single entity and then call that subroutine for each member in the set. It can make your program clearer, keep it more organized, make it easier to debug, etc. The entities are numbered in the selection set, so you just set up a counter and work through them that way. Read up on it, then ask, if you have any questions about it. The standard place to start is with the AutoLISP Developer's Guide. It starts on page 74 in the AutoCAD 2013 PDF version, but should also be available on-line (see link below). There are probably some other good places to check out this topic as well. I just mention it as a starting point. Hope this helped. http://exchange.autodesk.com/autocad/enu/online-help/browse#WS1a9193826455f5ff561db57a12bd50eabde-7fdb.htm Quote
BIGAL Posted April 4, 2013 Posted April 4, 2013 a couple of examples (setq blockselection (ssget "_X" (list (cons 0 "INSERT") ))) ; select all blocks in dwg (setq bname "myblock") (setq blockselection (ssget "_X" (list (cons 0 "INSERT") (cons 2 bname)))) ; select all blocks named bname in dwg (setq blockselection (ssget (list (cons 0 "INSERT") ))) ; I will pick the selection but again blocks only also add cons 2 if you like (setq howmany (sslength blockselection)) ; how many blocks in selection set you can have only 1 its ok. (setq whichone (ssname blockselection X)) ; X is a number starting at 0 with last number = howmany-1 (setq x 0) (repeat howmany (princ (ssname blockselection x)) ; do something here (setq X (+ x 1)) ) Quote
neophoible Posted April 4, 2013 Posted April 4, 2013 FYI, because you declare them local here (defun c:Getmaptile (/ bn chk pp bnloc) you do not need to initialize your variables to nil, nor do you have to declare a type. So, you can eliminate the line (setq bn "" chk nil); set block name nil You can use something like the following loop to get your set (while (not (and (princ "Select block(s)...") (setq BlockSet (ssget (list (cons 0 "INSERT")))) ) ) ) BIGAL has more to offer here, especially regarding ways to streamline your set. Be sure to add to your local variables list whatever variable name you use for the block set. You don’t want a bunch of unneeded selection sets taking up memory. Quote
woodman78 Posted April 5, 2013 Author Posted April 5, 2013 Thanks guys, but I don't understand coding well at all. I can't get my head around that stuff to do with selection sets so I'm gonna leave it off. I have to go back to basics that I have some hope of understanding. I have decided to accept that the use can select one block and have all the map tiles for that main tile come in. The problem I have with this is that if I use a block to select the map tile to be inserted then that block is defined in the drawing and so the actual map tile cannot be inserted. One way I have been looking into is putting a letter at the end of the block and then when it is selected read the block name and remove the letter. I have looked into this and I can't make head nor tail of where I am going... The other thing I wished to do is to copy the blocks that are inserted to a new drawing....I thought that would be fairly straight forward but it appears not.. I would appreciate help with this please... Thanks. (defun c:Getmaptile (/ bn chk pp bnloc) (setq chk (entsel "\nPick a Block: ")) (setq pp (cadr chk)) (setq chk (entget (car chk))) (setq bn (cdr (assoc 2 chk))); get block name ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\5000\\" bn "*.dwg"))) (foreach Dwg Drawings (command "_.insert" Dwg "0,0,0" "1" "1" "0") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\2500\\" bn "*.dwg"))) (foreach Dwg Drawings (command "_.insert" Dwg "0,0,0" "1" "1" "0") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\1000\\" bn "*.dwg"))) (foreach Dwg Drawings (command "_.insert" Dwg "0,0,0" "1" "1" "0") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (princ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Function to list files from a wildcard match (defun matchfiles (path / item dir match lst fil files) (setq path (strsplit "," path)) (foreach item path (setq dir (strcat (vl-string-right-trim "\\" (vl-filename-directory item)) "\\") match (substr item (1+ (strlen dir))) lst (vl-directory-files dir match 1) ) (foreach fil lst (setq files (cons (strcat dir fil) files)) ) ) (reverse files) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Function to split a string on a specified character (defun strsplit (c str / lst p n) (setq n 0) (while (setq p (vl-string-search c str n)) (setq lst (cons (substr str (1+ n) (- p n)) lst)) (setq n (1+ p)) ) (if (< n (strlen str)) (setq lst (cons (substr str (1+ n)) lst)) ) (reverse lst) ) Quote
woodman78 Posted April 5, 2013 Author Posted April 5, 2013 Hi all, I have been playing around with Bigal's earlier code to use a script to open a new drawing and copy the map tiles into it. But I don't know if I am missing something. Do I need to create the file "C:\acadtemp\tiles.scr"? And if so what needs to go into it? (defun c:Getmaptile (/ bn chk pp bnloc) (setq chk (entsel "\nPick a Block: ")) (setq pp (cadr chk)) (setq chk (entget (car chk))) (setq bn (cdr (assoc 2 chk))); get block name [color="red"](setq fout (open "C:\acadtemp\tiles.scr" "w")) (setvar "filedia" 0) (write-line "new " fout) ; note 2 spaces check for using default dwt etc[/color] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\5000\\" bn "*.dwg"))) (foreach Dwg Drawings [color="red"] ;(command "_.insert" Dwg "0,0,0" "1" "1" "0") (setq dwgtile (strcat "_.insert" dwg "0,0,0" "1" "1" "0")) (Write-line dwgtile fout) ) (close fout) ; last line (command "script" "C:\acadtemp\tiles")[/color] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\2500\\" bn "*.dwg"))) (foreach Dwg Drawings (command "_.insert" Dwg "0,0,0" "1" "1" "0") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\1000\\" bn "*.dwg"))) (foreach Dwg Drawings (command "_.insert" Dwg "0,0,0" "1" "1" "0") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (princ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Function to list files from a wildcard match (defun matchfiles (path / item dir match lst fil files) (setq path (strsplit "," path)) (foreach item path (setq dir (strcat (vl-string-right-trim "\\" (vl-filename-directory item)) "\\") match (substr item (1+ (strlen dir))) lst (vl-directory-files dir match 1) ) (foreach fil lst (setq files (cons (strcat dir fil) files)) ) ) (reverse files) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Function to split a string on a specified character (defun strsplit (c str / lst p n) (setq n 0) (while (setq p (vl-string-search c str n)) (setq lst (cons (substr str (1+ n) (- p n)) lst)) (setq n (1+ p)) ) (if (< n (strlen str)) (setq lst (cons (substr str (1+ n)) lst)) ) (reverse lst) ) Thanks, I'd like to move this on. Quote
woodman78 Posted April 5, 2013 Author Posted April 5, 2013 Ok so I am still trying with the SSGET. This is what I have so far from above but I am wondering if I create a set with multiple blocks do I then need another loop inside that that will cycle through the block names and insert all blocks for each name? (defun c:Getmaptile (/ bn chk pp bnloc blockset) (while (not (and (princ "Select block(s)...") (setq chk (ssget (list (cons 0 "INSERT")))) )) ;(setq chk (entsel "\nPick a Block: ")) (setq pp (cadr chk)) (setq chk (entget (car chk))) (setq bn (cdr (assoc 2 chk))); get block name ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\5000\\" bn "*.dwg"))) (foreach Dwg Drawings (command "_.insert" Dwg "0,0,0" "1" "1" "0") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\2500\\" bn "*.dwg"))) (foreach Dwg Drawings (command "_.insert" Dwg "0,0,0" "1" "1" "0") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Drawings (matchfiles (strcat "M:\\os\\Maps\\AutoCAD\\1000\\" bn "*.dwg"))) (foreach Dwg Drawings (command "_.insert" Dwg "0,0,0" "1" "1" "0") ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (princ) ) Sub-routines omitted. Thanks. 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.