jake77777 Posted September 26, 2010 Posted September 26, 2010 Hopefully someone can help me with this one..I really don't know how to properly format the path..Hopefully that's the only problem with this code to bring in a block containing all my multi lines and automatically deleting it from the drawing..leaving the references for the mlines..Any help is GREATLY appreciated! (defun c:fildel (/ bdef blk ss tmp uss) (vl-load-com) (or *fil:del* (setq *fil:del* "All")) (setq bdef (getvar "linetypes")) (while (progn (setq blk (getstring t (strcat "\nSpecify Block Name : "))) (cond ((eq "" blk) (setq blk bdef) nil) ((not (snvalid blk)) (princ "\n** Invalid Block Name **")) ((not (tblsearch "BLOCK" blk)) (princ "\n** Block Not Found in Drawing **")) (t nil)))) ; Exit Loop (if (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 blk)))) (progn (princ (strcat "\nDrawing Contains " (rtos (sslength ss) 2 0) " Blocks with Name: " blk)) (initget "All Selection") (or (not (setq tmp (getkword (strcat "\nDelete [A]ll or election? : ")))) (setq *fil:del* tmp)) (cond ((eq *fil:del* "Selection") (while (not uss) (setq uss (ssget (list (cons 0 "INSERT") (cons 2 blk))))) (setq ss uss))) (mapcar 'entdel (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))) (princ)) Quote
Lee Mac Posted September 26, 2010 Posted September 26, 2010 Coincidentally, this looks strikingly similar... http://www.cadtutor.net/forum/showthread.php?37414-Lisp-for-filtering-certain-blocks-and-delete-them&p=247387&viewfull=1#post247387 Quote
jake77777 Posted September 26, 2010 Author Posted September 26, 2010 Thanks for the heads up Lee! (defun c:fildel (/ bdef blk ss tmp uss) (vl-load-com) (or *fil:del* (setq *fil:del* "All")) (setq bdef (getvar "linetypes")) (while (progn (setq blk (getstring t (strcat "\nSpecify Block Name <" C:\\Users\\Michael\\Desktop\\linetypes\\ ">: "))) (cond ((eq "" blk) (setq blk bdef) nil) ((not (snvalid blk)) (princ "\n** Invalid Block Name **")) ((not (tblsearch "BLOCK" blk)) (princ "\n** Block Not Found in Drawing **")) (t nil)))) ; Exit Loop (if (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 blk)))) (progn (princ (strcat "\nDrawing Contains " (rtos (sslength ss) 2 0) " Blocks with Name: " blk)) (initget "All Selection") (or (not (setq tmp (getkword (strcat "\nDelete [A]ll or [s]election? <" *fil:del* "> : ")))) (setq *fil:del* tmp)) (cond ((eq *fil:del* "Selection") (while (not uss) (setq uss (ssget (list (cons 0 "INSERT") (cons 2 blk))))) (setq ss uss))) (mapcar 'entdel (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))) (princ)) Quote
Lee Mac Posted September 26, 2010 Posted September 26, 2010 Hopefully that's the only problem with this code to bring in a block containing all my multi lines and automatically deleting it from the drawing..leaving the references for the mlines.. That is not what I wrote my code to do BTW... Quote
Cad64 Posted September 26, 2010 Posted September 26, 2010 Coincidentally, this looks strikingly similar... Wow! That's quite a coincidence. Quote
jake77777 Posted September 26, 2010 Author Posted September 26, 2010 Since discovering lisps yesterday I've been on a nonstop mission to discover the most helpful ones for our firm..I probably need a rest after missing the purpose for that last code considering they don't have much in common at all!. Are you able to point me in the right direction on this one at all..I've created 10 multilines that we use all the time..Instead of importing a block of them in each drawing then deleting it after..do you think there could possibly be a solution with code? Thanks Lee. Quote
jake77777 Posted September 26, 2010 Author Posted September 26, 2010 thanks lee but not too much of an option for us..All of our CAD drawings are from the architects/designers/bldrs. Sorry for not including the credits on that code..I've kinda gotten lost in all these codes I've been testing out. But thank you! Quote
Lee Mac Posted September 26, 2010 Posted September 26, 2010 If you were to go down the block route, would you be inserting many blocks? Or just one? Quote
Lee Mac Posted September 26, 2010 Posted September 26, 2010 Quick example for a single block: (defun c:ImportRef ( / _Insert f ) (vl-load-com) ;; © Lee Mac 2010 (defun _Insert ( space block point ) (if (not (vl-catch-all-error-p (setq result (vl-catch-all-apply 'vla-insertblock (list space (vlax-3D-point point) block 1. 1. 1. 0.) ) ) ) ) result ) ) (if (setq f (getfiled "Select Block" "" "dwg" 16)) (vla-delete (_Insert (if (or (eq AcModelSpace (vla-get-ActiveSpace (setq doc (vla-get-ActiveDocument (vlax-get-acad-object) ) ) ) ) (eq :vlax-true (vla-get-MSpace doc)) ) (vla-get-ModelSpace doc) (vla-get-PaperSpace doc) ) f '(0. 0. 0.) ) ) ) (princ) ) Could be made really simple using a command call but wth... Quote
jake77777 Posted September 27, 2010 Author Posted September 27, 2010 Thanks Lee, I'm pretty sure I have the path written incorrectly..Can you offer any more knowledge to a newb! I've found a lot of good lisps since starting my search yesterday.. Though I have an idea of maybe 5-10 potential lisp ideas our firm could incorporate that are more specific in nature. (ie.automatic break/trim lisp to trim a fnd footing line (dashed line) when using our footing block (a 16" solid square with a 30" dashed square around it) Is there anyway I could send you a list of these potential lisps and see what you can do? I'm not sure if your a strictly pro bono codesman but if not we could work out something through payapal for time. If your interested you can email me at michael82982@msn.com. If you are and can spare your time form these freeloaders could you post a "snippet" of your email to know which email to look for. I just created that account so I wouldn't have to worry about spam but will check on it the next few days. I realize your a busy man answering 10,759 questions so no biggie if you can't! Sure I could look around. Thanks for your help! (defun c:ImportRef ( / _Insert f ) (vl-load-com) ;; © Lee Mac 2010 (defun _Insert ( space block point ) (if (not (vl-catch-all-error-p (setq result (vl-catch-all-apply 'vla-insertblock (list space (vlax-3D-point point) block 1. 1. 1. 0.) ) ) ) ) result ) ) (if (setq f (getfiled "Select Block" "c:/Program Files/AutoCAD 2007/Support/linetypes/" "dwg" 16)) (vla-delete (_Insert (if (or (eq AcModelSpace (vla-get-ActiveSpace (setq doc (vla-get-ActiveDocument (vlax-get-acad-object) ) ) ) ) (eq :vlax-true (vla-get-MSpace doc)) ) (vla-get-ModelSpace doc) (vla-get-PaperSpace doc) ) f '(0. 0. 0.) ) ) ) (princ) ) Quote
jake77777 Posted September 27, 2010 Author Posted September 27, 2010 ..oh yes, all the linetypes are in a single .dwg file Quote
jake77777 Posted September 27, 2010 Author Posted September 27, 2010 That email was michael82982@hotmail.com not msn.com Quote
David Bethel Posted September 27, 2010 Posted September 27, 2010 Maybe: (defun SetBlkTbl (n) (if (and (not (tblsearch "BLOCK" n)) (findfile (strcat n ".DWG"))) (progn (command "_.INSERT" n) (command) n))) -David Quote
alanjt Posted September 27, 2010 Posted September 27, 2010 This may be of interest... http://www.cadtutor.net/forum/showthread.php?52690-Multi-Leader-LISP Quote
alanjt Posted September 27, 2010 Posted September 27, 2010 That email was ********@hotmail.com not msn.com Spammer Time!!! Quote
Tiger Posted September 27, 2010 Posted September 27, 2010 A sidenote. The drawings that we have the most issues with are ones where folks have taken a drawing from another source and just continued on it and added stuff of their own. I always say to all my sheeps.. er, co-workers that always, always start a new drawing from our template (with our styles for everything) and import/attach/copy-paste what you need from the other drawings. It prevents soo many issues from arising that I have to spend hours figuring out or redoing in the end. Quote
jake77777 Posted September 27, 2010 Author Posted September 27, 2010 That's exactly what I was looking for Alan! I remember reviewing that post too..think the conversation in it took my attention more. Spammer time! Haha None yet, actually no emails at all. But I guess it wouldn't be fair to extend my offer to all the Lisp geniuses out there...There's a max of 7 lisps Id be looking for (still need to put them together) but I could give screenshots and detailed description of what we could use. I don't think they should be extremely complicated.. If any are too complicated or very difficult..no problem at all. I figured it'd be easier to just make a list of the lisps I couldn't find or change myself rather than making a bunch of posts begging for code. And the input you guys provide is certainly worth a few pesos! Thanks again for that code. 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.