Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Member
ericwhitmore
Posts: 4
Registered: ‎05-11-2012
Message 1 of 8 (370 Views)
Accepted Solution

Quick block

370 Views, 7 Replies
05-11-2012 09:06 AM

I have migrated o a new office and I am looking for a Lisp routine that used to make Blocks in-place instantly.  he name of the block doesn't matter, but it can't be an anonymous block (I already have that routine!)

 

Does anyone have this lisp routine they could share?  Basically, you run the Lisp command, select whatever you want and it instantly transforms your selection into a randomly named block.  I think I got this routine off of a Hot Tip Harry website a LONG time ago.

 

HELP!

Distinguished Mentor
_Tharwat
Posts: 599
Registered: ‎07-02-2010
Message 2 of 8 (366 Views)

Re: Quick block

05-11-2012 09:32 AM in reply to: ericwhitmore

Things like this .... ?

 

(defun c:Test (/ selectionset insertionpoint number Blockname)
  ;;; Tharwat 11. May. 2012 ;;
  (if (and (setq selectionset (ssget "_:L"))
           (setq insertionpoint (getpoint "\n Specify insertion point :"))
      )
    (progn
      (setq number    1
            Blockname (strcat "MyBlock" (itoa number))
      )
      (while (tblsearch "BLOCK" Blockname)
        (setq Blockname
               (strcat "MyBlock" (itoa (setq number (1+ number))))
        )
      )
      (command "_.-Block" Blockname insertionpoint selectionset ""
              )
    )
    (princ)
  )
  (princ)
)

 

____________________________________________________
Get learn and learn and practice , to become experienced guy .
Member
ericwhitmore
Posts: 4
Registered: ‎05-11-2012
Message 3 of 8 (364 Views)

Re: Quick block

05-11-2012 09:37 AM in reply to: _Tharwat

Almost!  I ran this lisp and it deletes the original content, but I just want to convert a selection to a named block, in place, without having to reinsert it.

 

THANK YOU FOR YOUR HELP!

Distinguished Mentor
_Tharwat
Posts: 599
Registered: ‎07-02-2010
Message 4 of 8 (360 Views)

Re: Quick block

05-11-2012 09:43 AM in reply to: ericwhitmore

With the adds of command call insert , we will re-insert the same block name in its chosen insertion point . :smileyvery-happy:

 

Try and tell me back ..

 

(defun c:Test (/ selectionset insertionpoint number Blockname)
  ;;; Tharwat 11. May. 2012 ;;
  (if (and (setq selectionset (ssget "_:L"))
           (setq insertionpoint (getpoint "\n Specify insertion point :"))
      )
    (progn
      (setq number    1
            Blockname (strcat "MyBlock" (itoa number))
      )
      (while (tblsearch "BLOCK" Blockname)
        (setq Blockname
               (strcat "MyBlock" (itoa (setq number (1+ number))))
        )
      )
      (command "_.-Block" Blockname insertionpoint selectionset "")
      (command "_.-insert" Blockname insertionpoint "" "" "")
    )
    (princ)
  )
  (princ)
)

 

____________________________________________________
Get learn and learn and practice , to become experienced guy .
Member
ericwhitmore
Posts: 4
Registered: ‎05-11-2012
Message 5 of 8 (353 Views)

Re: Quick block

05-11-2012 09:57 AM in reply to: _Tharwat

Perfect!!!  Way to go!

*Expert Elite*
Kent1Cooper
Posts: 5,363
Registered: ‎09-13-2004
Message 6 of 8 (351 Views)

Re: Quick block

05-11-2012 09:58 AM in reply to: ericwhitmore

ericwhitmore wrote:

.... Basically, you run the Lisp command, select whatever you want and it instantly transforms your selection into a randomly named block.  I think I got this routine off of a Hot Tip Harry website a LONG time ago.

....


This is from Hot Tip Harry's website [Cadalyst] -- might it be the one?  It doesn't name it randomly, though.  And I didn't download it and try it.  But it came up when I searched for "quick block":

 

http://cadtips.cadalyst.com/standard-blocks/quick-blocks

Kent Cooper
Distinguished Mentor
_Tharwat
Posts: 599
Registered: ‎07-02-2010
Message 7 of 8 (351 Views)

Re: Quick block

05-11-2012 09:58 AM in reply to: ericwhitmore

ericwhitmore wrote:

Perfect!!!  Way to go!


Enjoy it . :smileywink:

 

Tharwat

____________________________________________________
Get learn and learn and practice , to become experienced guy .
Member
ericwhitmore
Posts: 4
Registered: ‎05-11-2012
Message 8 of 8 (347 Views)

Re: Quick block

05-11-2012 10:06 AM in reply to: Kent1Cooper

Thanks, this really helps!

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.