burst block with script

burst block with script

Anonymous
Not applicable
3,882 Views
17 Replies
Message 1 of 18

burst block with script

Anonymous
Not applicable

I need a script that will burst a specific block by name. Is this possible? I tried to use this but it didn't quite work

 

( Command "burst" (SSGET "X" '((0 . "INSERT") (2 . "PCS Border Info_22X34" ))) "" )
0 Likes
Accepted solutions (1)
3,883 Views
17 Replies
Replies (17)
Message 2 of 18

ВeekeeCZ
Consultant
Consultant

If your blocks are NOT dynamic, then try this.

 

(progn (sssetfirst nil (SSGET "X" '((0 . "INSERT") (2 . "PCS Border Info_22X34" )))) (c:burst))

BURST is Express Tools command - it's a LISP actually, not a regular autocad's build-in command.

0 Likes
Message 3 of 18

Anonymous
Not applicable

I guess that explains why it didn't work. Unfortunately, that code didn't do anything either. The log shows this 

 

Command: (progn (sssetfirst nil (SSGET "X" '((0 . "INSERT") (2 . "PCS Border Info_22X34" )))) (c:burst))

Initializing...1 found

\

Command: 
0 Likes
Message 4 of 18

ВeekeeCZ
Consultant
Consultant

You did not answer... it looks like your block is a dynamic.

 

Anyway, try this code.

And check a PICKFIRST sysvar, pre-selection must be allowed.

 

(vl-load-com)

(defun c:BurstBorder ( / e ss objs blk) ; by name
  (setq e "PCS Border Info_22X34" ; (getstring T "\nType block name(s) to select (comma-delimited list or wildcards): ")
        objs (ssadd))
  (if (setq ss (ssget "_X" '((0 . "INSERT"))))
    (progn
      (repeat (setq i (sslength ss))
        (setq name (strcase (vla-get-effectivename (vlax-ename->vla-object (setq blk (ssname ss (setq i (1- i))))))))
        (if (wcmatch name (strcase e))
          (ssadd blk objs)))
    (if (> (sslength objs) 0)
      (progn
	(sssetfirst nil objs)
	(c:burst)))))
  (princ)
)
0 Likes
Message 5 of 18

Anonymous
Not applicable

sorry about that. The block is definitely dynamic. I verified PICKFIRST is set to 1. Unfortunately, as far as I can tell, the code didn't do anything.

 

I attached a sample drawing with the block in it for reference.

0 Likes
Message 6 of 18

ВeekeeCZ
Consultant
Consultant

Hmm.... dunno what issue you're experiencing, but it works for me.

 

See the SCREENCAST

0 Likes
Message 7 of 18

Anonymous
Not applicable

Forgive my ignorance....I'm not quite sure what you're using to run it but I usually use script pro by pasting it into notepad and saving it as a .scr. could that have something to do with it?

0 Likes
Message 8 of 18

ВeekeeCZ
Consultant
Consultant

I should have told you - this is the LISP, not a script.

 

Read HERE how to use it. Basically, save it as *.lsp and load with APPLOAD.

 

I used VLIDE, which is build-in LISP editor. You can use that as well.

 

0 Likes
Message 9 of 18

Anonymous
Not applicable

Thanks for your help thus far. I'm going to have to run this lisp on over 1,000 drawings. I'm trying to work out the syntax to have a script run the lisp so I don't have to manually open every drawing. So far I've got this but I don't quite know what I'm doing.

 

(load "Path to .lsp" "Failed to Load")
(defun c:BurstBoarder ( )
0 Likes
Message 10 of 18

ВeekeeCZ
Consultant
Consultant
Accepted solution

I would suggest just copy-paste the whole code at the end of ACADDOC.lsp, save it.

 

Use modified code, to run thru all layouts. (the previous code works on current layout only)

 

And for a SCRIPT use just a command name: BurstBorder (and some other commands to exit, save ...so on)

 

(vl-load-com)

(defun c:BurstBorder ( / adoc e ss objs blk)
  (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
  (vlax-for layt (vla-get-layouts adoc)
    (if (not (= (setq lname (vla-get-name layt)) "Model"))
      (progn
        (setvar 'CTAB lname)
        (setq e "PCS Border Info_22X34" ; (getstring T "\nType block name(s) to select (comma-delimited list or wildcards): ")
              objs (ssadd))
        (if (setq ss (ssget "_X" '((0 . "INSERT"))))
          (progn
            (repeat (setq i (sslength ss))
              (setq name (strcase (vla-get-effectivename (vlax-ename->vla-object (setq blk (ssname ss (setq i (1- i))))))))
              (if (wcmatch name (strcase e))
                (ssadd blk objs)))
            (if (> (sslength objs) 0)
              (progn
                (sssetfirst nil objs)
                (c:burst))))))))
  (princ)
)
0 Likes
Message 11 of 18

Anonymous
Not applicable

Thanks for you help.

 

I'm trying really hard to follow what you're saying and I think I understand but I can't locate the ACADDOC.lsp file.... I typed

 

(findfile "acaddoc.lsp")

and it returned nil

0 Likes
Message 12 of 18

ВeekeeCZ
Consultant
Consultant

Good, then create one (it's a regular txt file with lisp extention). Save it to some of your support search file path (see Options/Files...) e.g.

 

C:\Users\UserName\appdata\roaming\autodesk\autocad 2015\r20.0\enu\support

 

You might add this location between Trusted Path as well (Options/Files...)

 

 

See HELP why you do that.

 

0 Likes
Message 13 of 18

Anonymous
Not applicable

Thanks for your patience in working with me. I'm trying but I just cant seem to get it to show up in the command prompt.

 

I have the lisp you wrote saved as ACADDOC.lsp in the folder you specified. The path is added to the Support File Search Paths, Trusted Locations and even Working. When I type the name of the function, it doesn't show up. 

 

(findfile "ACADDOC.LSP") still returns nil

setting LEGACYCODESEARCH to on changes nothing

setting SECURELOAD to 0 changes nothing

 

suggestions?

0 Likes
Message 14 of 18

ВeekeeCZ
Consultant
Consultant

Dunno. Maybe try another path from your Search path... 

 

You may create the file with just a test prompt e.g. (princ "\nACADDOC.lsp LOADED"), then you should see that in command line while opening any new/exist drawing.

 

 

If that fails, you may use another way to load the file automatically. Use APPLOAD command, in dialog there is START UP SUITE, put the *.lsp file in there. But this way is less reliable, especially when you gonna use that within the script for 1000 files...

 

Good luck.

0 Likes
Message 15 of 18

Anonymous
Not applicable

The problem was that I didn't need to add the .lsp extension when I saved the file. It was reading it as "ACADDOC.LSP.LSP". Once I removed the extra extension it worked perfectly. thanks!

0 Likes
Message 16 of 18

Anonymous
Not applicable

Any chance i can get this where it doesn't force you to switch to paper space? Can someone also point out exactly where i need to put the name of the block im looking for?

0 Likes
Message 17 of 18

ВeekeeCZ
Consultant
Consultant

@KDAWG1213 wrote:

Any chance i can get this where it doesn't force you to switch to paper space? Can someone also point out exactly where i need to put the name of the block im looking for?


That was kind of the point - to go thru all the layouts. Now I am not sure what you want... following routine burst all the block of specified name in current tab (layout/model) only. 

 

(vl-load-com)

(defun c:BurstMyBlocks ( / adoc e ss objs blk)
  
  (setq e "MyBlock" ; you can use wildcards or comma-delimited
        objs (ssadd))
  (if (setq ss (ssget "_X" '((0 . "INSERT"))))
    (progn
      (repeat (setq i (sslength ss))
        (setq name (strcase (vla-get-effectivename (vlax-ename->vla-object (setq blk (ssname ss (setq i (1- i))))))))
        (if (wcmatch name (strcase e))
          (ssadd blk objs)))
      (if (> (sslength objs) 0)
        (progn
          (sssetfirst nil objs)
          (c:burst)))))
  (princ)
  )

 

Message 18 of 18

tomasz.pakiela
Explorer
Explorer

Would it be possible to burst blocks with selected name that are inside other blocks also?

0 Likes