onzki Posted October 28, 2010 Share Posted October 28, 2010 Hi Everyone, Below is a code that I always use to quickly block/group objects (opposite to explode). I got it from the internet long time ago, courtesy of Mr. Dennis Kiracofe. I tried to contact the author for formality but my Google search have been a dead end. My intended modification is to add a prompt prior to or after the selection to specify a block name, e.g. "Type block name". Sorry, I am new to lisp. I am also trying to understand the code per line and modify on my own but those "rtos","strcat" "CDATEX" gave me some head ache, I got lost in the short sequence haha. Thanks very much. : ) ------------------ ; IMPLODE.LSP Implode ©1996, Dennis Kiracofe ; changes ^v^ CAD Studio (defun C:IMP (/ SLCT CDATE BNAME) (setvar "cmdecho" 0) (princ "\nSelect items to IMPLODE: ") (setq SLCT (ssget)) (setq CDATEX (rtos (getvar "cdate") 2 9) BNAME (strcat (substr CDATEX 10 ) ) (command "_block" BNAME "0,0" SLCT "") (command "_insert" BNAME "0,0" "" "" "" ) ) Quote Link to comment Share on other sites More sharing options...
asos2000 Posted October 28, 2010 Share Posted October 28, 2010 Give this one a try (defun C:IMP (/ SLCT CDATE BNAME) (setvar "cmdecho" 0) (princ "\nSelect items to IMPLODE: ") (setq SLCT (ssget)) (setq BName (getstring "\nWhat is block name? ")) (setq BP (getpoint "\n Insertion Point:")) (command "_block" BNAME BP SLCT "") (command "_insert" BNAME BP "" "" "") ) Quote Link to comment Share on other sites More sharing options...
asos2000 Posted October 28, 2010 Share Posted October 28, 2010 (edited) And this one for multiple insertion (defun C:IMP (/ SSel BN BP BP2) (setvar "cmdecho" 0) (princ "\nSelect items to IMPLODE: ") (setq SSel (ssget)) (setq BN (getstring "\nWhat is block name? ")) (setq BP (getpoint "\nBase Point of Block:")) (command "_block" BN BP SSel "") (while (setq BP2 (getpoint "\n Insertion Point of Block:")) (command "_insert" BN BP2 "" "" "")) ) And this one for keeping the origial objects (defun C:IMP (/ SSel BN BP BP2) (setvar "cmdecho" 0) (princ "\nSelect items to IMPLODE: ") (setq SSel (ssget)) (setq BN (getstring "\nWhat is block name? ")) (setq BP (getpoint "\nBase Point of Block:")) (command "_block" BN BP SSel "") (command "_insert" BN BP "" "" "") (command "Explode" "l") (while (setq BP2 (getpoint "\n Insertion Point of Block:")) (command "_insert" BN BP2 "" "" "")) ) Edited October 28, 2010 by asos2000 Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 28, 2010 Share Posted October 28, 2010 If you are just making random blocks (with random insertion points), who cares what they're named. You can actually make quick anonymous blocks by selecting the objects you want, holding the right-click down and dragging the objects. From there you will receive a prompt to move, copy, paste as block. eg. However, if you are going to specify the name, you need to consider checking to make sure the name is valid (use snvalid function) and make sure the block name doesn't already exist (tblsearch "BLOCK" ). Quote Link to comment Share on other sites More sharing options...
onzki Posted October 30, 2010 Author Share Posted October 30, 2010 @ Asos2000- Thanks! These are more than I requested. It worked well, Very helpful! @alanjt- I never knew it exist.. it's very quick. Thanks for sharing! 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.