+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
  1. #1
    Full Member
    Discipline
    Civil
    Using
    AutoCAD 2015
    Join Date
    May 2016
    Posts
    73

    Default Lisp Request - Select object in paperspace in across multiple layouts

    Registered forum members do not see this ad.

    If only QSelect weren't lying when it gives the option to search "Entire Drawing."

    As the title says, I'd like to be able to grab all instances of an object (typically a block) across multiple layout tabs in paper space (if it were in model, this wouldn't be a problem). The end goal being to change a property across the board. I know there's GATTE if it's a block attribute that needs changing, but that's not always the case.

    Ideally, some way to grab all instances with optional filters would be great. Really, I just want QSelect to have better functionality.

    It looks like someone addressed it here, but I'm not having any success with that method.

    Thanks for any help!

  2. #2
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    800

    Default

    Whats the name of the block, is it dynamic?

  3. #3
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    5,756

    Default

    Then what to do after selecting these Block references?

  4. #4
    Full Member
    Discipline
    Civil
    Using
    AutoCAD 2015
    Join Date
    May 2016
    Posts
    73

    Default

    The name will change. I'm not looking for a one time option. I guess prompting to select an instance of the block or type a name would be great.

    Mostly the blocks will be static, but could occasionally be dynamic, in which case it would be helpful to be able to filter the selection based on which state the block is in.

  5. #5
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    800

    Default

    This should grip all blocks in the drawing, with the same name:

    Code:
    (defun C:test ( / blk SS nSS i e )
      (setvar 'errno 0)
      (while (/= 52 (getvar 'errno))
        (setq blk (car (entsel "\nSelect block to filter <exit>: ")))
        (cond 
          ((= 7 (getvar 'errno)) (princ) (setvar 'errno 0))
          ((and blk (/= "INSERT" (cdr (assoc 0 (entget blk))))) (princ))
          (blk 
            (setq blk (vla-get-EffectiveName (vlax-ename->vla-object blk)))
            (setq SS (ssget "_X" (list (cons 0 "INSERT"))))
            (setq nSS (ssadd))
            (repeat (setq i (sslength SS))
              (setq e (ssname SS (setq i (1- i))))
              (and (eq blk (vla-get-EffectiveName (vlax-ename->vla-object e)))
                (ssadd e nSS)
              )
            )
            (sssetfirst nil nSS)
            (setvar 'errno 52)
          )
        )
      )
      (princ)
    )

  6. #6
    Full Member
    Discipline
    Civil
    Using
    AutoCAD 2015
    Join Date
    May 2016
    Posts
    73

    Default

    Any number of things. Delete them all (I know there are other ways to do this too), change their layer (or any other property/attribute), maybe even move them all using displacement (lets say you've got a scale bar on multiple layouts that now needs to be an inch to the left on every sheet).

    I know there are generally work arounds for most of these, but it'd be handy to have one command to do it all.

  7. #7
    Full Member
    Discipline
    Civil
    Using
    AutoCAD 2015
    Join Date
    May 2016
    Posts
    73

    Default

    Perfect! It looks like it kicks out everything that's not on the current layout if you try to run a command on the selection set. But changing anything in the properties panel works like a charm--which is pretty much all I need.

    Thanks a ton, Grrr!

  8. #8
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    800

    Default

    Quote Originally Posted by eyeofnewt555 View Post
    Perfect! It looks like it kicks out everything that's not on the current layout if you try to run a command on the selection set. But changing anything in the properties panel works like a charm--which is pretty much all I need.
    I didn't knew about that, but the code is supposed to grip every occurence in all layouts. BTW that suggestion you addressed should work for non-dynamic blocks.

    Quote Originally Posted by eyeofnewt555 View Post
    Thanks a ton, Grrr!
    You're welcome!

  9. #9
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    8,801

    Default

    I do some stuff like this but in a different way just atke advantage of Setvar CTAB which can open every layout 1 at a time and do something also adding the 410 filter.
    Code:
    (setq doc (vla-get-activedocument (vlax-get-acad-object)))
    (vlax-for lay (vla-get-Layouts doc)
    (setq plotabs (cons (vla-get-name lay) plotabs))
    )
    (foreach tabname plotabs 
          ; no need to regen each sheet
          (setq ss1 (ssget "x"  (list (cons 0 "INSERT") (cons 2 bname)(cons 410 tabname))))
    and so on do your move etc as a defun at this point
    A man who never made mistakes never made anything

  10. #10
    Full Member
    Discipline
    Civil
    Using
    AutoCAD 2015
    Join Date
    May 2016
    Posts
    73

    Default

    Registered forum members do not see this ad.

    Thanks, BigAl! If I ever get half decent at writing LISPs, I'll try that out. It sounds like it could be neat.

Similar Threads

  1. LISP Request - Simple - Change UCS rotation in multiple layouts
    By eyeofnewt555 in forum AutoLISP, Visual LISP & DCL
    Replies: 0
    Last Post: 27th Jun 2016, 04:21 pm
  2. Moving object from Paper to Model across multiple Layouts
    By loopfish in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 6
    Last Post: 2nd Jan 2016, 06:11 pm
  3. Macro or LISP - select all layouts & publish
    By mikekmx in forum AutoCAD General
    Replies: 8
    Last Post: 26th Mar 2014, 02:52 am
  4. Replies: 2
    Last Post: 27th Jul 2012, 05:26 am
  5. Lisp to select a field and highlight associated object
    By markv in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 2nd Nov 2011, 02:30 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts