Author Topic: Locate block within multiple layouts  (Read 1655 times)

0 Members and 1 Guest are viewing this topic.

Biscuits

  • Swamp Rat
  • Posts: 502
Locate block within multiple layouts
« on: March 30, 2016, 11:23:22 AM »
Using Acad2015 Windows 7 (64) bit

Any ideas for a simple method to locate a block within a drawing that has multiple layouts?
QSelect appears to only work in the current layout.

Any advice would be helpful. Thanks


mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Locate block within multiple layouts
« Reply #1 on: March 30, 2016, 11:39:05 AM »
what are you trying to do to this block?
Be your Best


Michael Farrell
http://primeservicesglobal.com/

ronjonp

  • Needs a day job
  • Posts: 7530
Re: Locate block within multiple layouts
« Reply #2 on: March 30, 2016, 11:45:37 AM »
Assuming it's not a modified dynamic block:
Code - Auto/Visual Lisp: [Select]
  1. (SSSETFIRST nil (ssget "_x" (list '(0 . "insert") (cons 2 "blockname"))))
Then change what you want in the properties box.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Locate block within multiple layouts
« Reply #3 on: March 30, 2016, 11:47:49 AM »
MJ  Looking to locate and possibly explode it.

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Locate block within multiple layouts
« Reply #4 on: March 30, 2016, 12:02:38 PM »
MJ  Looking to locate and possibly explode it.
that's not nice...
why not just block edit it instead?

this would update all instances of the block without you locating it
Be your Best


Michael Farrell
http://primeservicesglobal.com/

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Locate block within multiple layouts
« Reply #5 on: March 30, 2016, 12:43:34 PM »
Basically, some items in our older drawings should never have been blocks in the first place.
My employer wants/insists these blocks be exploded. Example: a line of text or a simple line. Some of these older blocks contain extraneous data that mess up file management software that renders PDFs from the drawings when checked into the system. The data should have been purged from the original block but still remain. So, if I'm trying to find a block called "TIC"
I have to find where in the drawing it is located then determine if it should be exploded. Trust me it is more involved than that.
But, for now I am looking for a way to locate which layout (s) contain the block in question. Qselect is great only for the current layout and some of our file may have 30 layouts or more. Thank you ronjonp for the code, but it does not direct me to the layout (s). Block edit is not an option.

Thanks for the help, gang!

ChrisCarlson

  • Guest
Re: Locate block within multiple layouts
« Reply #6 on: March 30, 2016, 01:16:06 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun c:explodeTIC ( / ss)
  2.         (if
  3.                 (setq ss (ssget "_x" (list (cons 0 "INSERT") (cons 2 "TIC"))))
  4.                         (progn
  5.                                 (command "_.explode" ss)
  6.                                 (princ (strcat (itoa (sslength ss))" Blocks Exploded"))
  7.                         )
  8.                         (princ "\nNo Blocks Found")
  9.         )
  10.         (princ)
  11. )
  12.  

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Locate block within multiple layouts
« Reply #7 on: March 30, 2016, 01:21:10 PM »
Thanks for the effort Chris. I already have a similar routine. But. I have to locate the blocks first for a visual then only possibly explode.

It's the finding of the block I need.

ronjonp

  • Needs a day job
  • Posts: 7530
Re: Locate block within multiple layouts
« Reply #8 on: March 30, 2016, 01:26:46 PM »
This will print the tabname to the command line where the blocks are found.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ ss)
  2.   (if (setq ss (ssget "_x" (list '(0 . "insert") '(2 . "TIC"))))
  3.     (mapcar '(lambda (b) (print (cdr (assoc 410 (entget b))))) (mapcar 'cadr (ssnamex ss)))
  4.   )
  5. )
« Last Edit: March 31, 2016, 08:22:00 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12921
  • London, England
Re: Locate block within multiple layouts
« Reply #9 on: March 30, 2016, 01:29:32 PM »
When you know the layout, this may help you locate all references of the block:

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/to-find-amp-mark-blocks-via-lisp/m-p/4715139#M318045

ChrisCarlson

  • Guest
Re: Locate block within multiple layouts
« Reply #10 on: March 30, 2016, 02:05:25 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun c:explodeTIC ( / ss)
  2.         (if
  3.                 (setq ss (ssget "_x" (list (cons 0 "INSERT") (cons 2 "TIC"))))
  4.                         (progn
  5.                                 (command "_.explode" ss)
  6.                                 (princ (strcat (itoa (sslength ss))" Blocks Exploded"))
  7.                         )
  8.                         (princ "\nNo Blocks Found")
  9.         )
  10.         (princ)
  11. )
  12.  

Actually, testing this code it only explodes in the current space.

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Locate block within multiple layouts
« Reply #11 on: March 30, 2016, 02:13:44 PM »
ronjonp's FOO code comes closest to what I need. I can make this work.

Big thank you to everyone for their efforts. You guys are awesome.

Thanks again

ronjonp

  • Needs a day job
  • Posts: 7530
Re: Locate block within multiple layouts
« Reply #12 on: March 30, 2016, 02:47:05 PM »
Glad to help :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1454
  • Marco
Re: Locate block within multiple layouts
« Reply #13 on: March 31, 2016, 03:57:44 AM »
Why not create clean blocks on separate DWG files and then insert them with "insert="  ?