Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
*Expert Elite*
cbenner
Posts: 3,132
Registered: ‎04-06-2010
Message 1 of 9 (362 Views)
Accepted Solution

Patchwork quilt to burst block by name

362 Views, 8 Replies
09-06-2013 10:47 AM

I've pieced this code together from about 4 different sources here in this forum, but I know I don't have it together quite right yet.  It's close... when I load it, however, instead of finding the block by name, it gives me "Select objects".  As soon as I pick the block it executes the burst.  But I can do that much without a program.  Can you gurus help me see what I am missing.

 

(I've got some books on the way to help me learn this stuff... I swear!)

 

(defun c:burev (/ ss old-echo item)
  (setq old-echo (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (if (setq ss (ssget "_x" '((0 . "INSERT")(2 . "E-REVTABLE"))))
(defun c:bu()
(c:burst)
)
(princ)
)
    (foreach item (mapcar 'cadr (ssnamex ss))
      (c:bu)
      )
    )
  (setq ss nil)
  (setvar "CMDECHO" old-echo)
  (princ)
)

ChrisB

ADSK_Expert_Elite_Icon_S_Color_Blk.png

Please use Mark Solutions!.Accept as Solution &Give Kudos!Kudos to further enhance the value of these forums. Thank you! :smileyhappy:

http://cbennertipstricks.blogspot.com/


   

*Expert Elite*
hmsilva
Posts: 2,639
Registered: ‎12-17-2004
Message 2 of 9 (359 Views)

Re: Patchwork quilt to burst block by name

09-06-2013 11:25 AM in reply to: cbenner

Chris,

 

one simpler way

(defun c:burev (/ ss)
  (if (setq ss (ssget "_x" '((0 . "INSERT")(2 . "MyBlk"))))
    (progn
    (sssetfirst nil ss)
    (c:burst)
    );; progn
    )
 (princ)
 );; burev

HTH

Henrique

*Expert Elite*
hmsilva
Posts: 2,639
Registered: ‎12-17-2004
Message 3 of 9 (351 Views)

Re: Patchwork quilt to burst block by name

09-06-2013 12:00 PM in reply to: cbenner

And change "Myblk" to your block name...

 

Henrique

 

 

*Expert Elite*
cbenner
Posts: 3,132
Registered: ‎04-06-2010
Message 4 of 9 (325 Views)

Re: Patchwork quilt to burst block by name

09-07-2013 08:09 AM in reply to: cbenner
Henrique,
Thanks for this, I've tried it out with my block Ben, but it still takes me to a "select objects" prompt instead of just acting on the named block.
ChrisB

ADSK_Expert_Elite_Icon_S_Color_Blk.png

Please use Mark Solutions!.Accept as Solution &Give Kudos!Kudos to further enhance the value of these forums. Thank you! :smileyhappy:

http://cbennertipstricks.blogspot.com/


   

*Expert Elite*
Lee_Mac
Posts: 1,107
Registered: ‎12-29-2009
Message 5 of 9 (318 Views)

Re: Patchwork quilt to burst block by name

09-07-2013 09:46 AM in reply to: cbenner

Hi Chris,

 

I believe you will only be able to supply the BURST command with an implied selection if PICKFIRST=1 on your system, else the ssget function is expecting a selection to be made following function evaluation and does not accept implied selections.

 

With PICKFIRST=1, the following will burst all standard (non-dynamic) blocks with block name equal to 'Ben' residing in the current layout (much the same as that which Henrique has posted earlier):

 

(defun c:burev ( / s )
    (if (setq s (ssget "_X" '((0 . "INSERT") (2 . "Ben"))))
        (progn
            (sssetfirst nil s)
            (c:burst)
        )
    )
    (princ)
)

 

If you were instead looking to burst references of this attributed block in all layouts, whilst also ignoring invisible attributes and using a much faster program, you might be interested in my Burst Upgraded program, which you could call with the following code (again, providing that PICKFIRST=1):

 

(defun c:burev ( / s )
    (if (setq s (ssget "_X" '((0 . "INSERT") (2 . "Ben"))))
        (progn
            (sssetfirst nil s)
            (c:iburst)
        )
    )
    (princ)
)

 

I hope this helps,

 

Lee

Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)
Expert Elite
With Mathematics there is the possibility of perfect rigour, so why settle for less?
*Expert Elite*
hmsilva
Posts: 2,639
Registered: ‎12-17-2004
Message 6 of 9 (317 Views)

Re: Patchwork quilt to burst block by name

09-07-2013 09:47 AM in reply to: cbenner

cbenner wrote:
Henrique,
Thanks for this, I've tried it out with my block Ben, but it still takes me to a "select objects" prompt instead of just acting on the named block.

You're welcome, Chris

 

The code shouldn't ask to select objects, should only select the blocks with the name "???", and if the if the blocks exist
they are selected and gripped, then just run the burst routine...

Is it possible to share with us a sample dwg with your block?

 

EDIT:

And as Lee already said, ensures that PICKFIRST is 1 or

(defun c:burev (/ pfst ss)
  (if (setq ss (ssget "_x" '((0 . "INSERT")(2 . "MyBlk"))))
    (progn
      (setq pfst (getvar 'PICKFIRST))
      (setvar 'PICKFIRST 1)
      (sssetfirst nil ss)
      (c:burst)
      (setvar 'PICKFIRST pfst)
    );; progn
    )
 (princ)
 );; burev

 

HTH

Henrique

*Expert Elite*
cbenner
Posts: 3,132
Registered: ‎04-06-2010
Message 7 of 9 (257 Views)

Re: Patchwork quilt to burst block by name

09-09-2013 06:44 AM in reply to: hmsilva

Henrique and Lee,

 

Thank you both.  The "pickfirst" was the culprit.  You can tell I don't do much Acad these days.

 

Anyway this works nicely now.  Thank you both.

 

 

ChrisB

ADSK_Expert_Elite_Icon_S_Color_Blk.png

Please use Mark Solutions!.Accept as Solution &Give Kudos!Kudos to further enhance the value of these forums. Thank you! :smileyhappy:

http://cbennertipstricks.blogspot.com/


   

*Expert Elite*
hmsilva
Posts: 2,639
Registered: ‎12-17-2004
Message 8 of 9 (255 Views)

Re: Patchwork quilt to burst block by name

09-09-2013 06:45 AM in reply to: cbenner

You're welcome, Chris

Glad I could help

 

Henrique

*Expert Elite*
Lee_Mac
Posts: 1,107
Registered: ‎12-29-2009
Message 9 of 9 (249 Views)

Re: Patchwork quilt to burst block by name

09-09-2013 06:49 AM in reply to: cbenner

You're welcome Chris! :smileyhappy:

Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)
Expert Elite
With Mathematics there is the possibility of perfect rigour, so why settle for less?

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

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 to get help installing your software.

Ask the Community