Jump to content

Implode.Lsp Modification (Requesting help)


onzki

Recommended Posts

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 8))

)

(command "_block" BNAME "0,0" SLCT "")

(command

"_insert" BNAME "0,0" "" "" ""

)

)

Link to comment
Share on other sites

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 "" "" "")
 )

Link to comment
Share on other sites

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 by asos2000
Link to comment
Share on other sites

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.

qb.png

 

 

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" ).

Link to comment
Share on other sites

@ 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! :)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...