See the top rated post in this thread. Click here

Results 1 to 9 of 9

Thread: Lisp code to wblock all objects except Civil 3D objects

  1. #1
    Member
    Join Date
    2016-02
    Location
    Calgary Alberta
    Posts
    14
    Login to Give a bone
    0

    Default Lisp code to wblock all objects except Civil 3D objects

    Hello, does anyone have or can easily create lisp code to create a selection set of all objects excluding civil 3D objects?
    I would like to have a function to wblock 2D objects to drawing file.

    Trevor

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,096
    Login to Give a bone
    0

    Default Re: Lisp code to wblock all objects except Civil 3D objects

    You would probably need to make two selection sets. The first set would contain all of the objects in the drawing. The second set would then be created based off of a filter of the ObjectName property. You would probably cycle through the first set for each object to check that property. Most, if not all, of the the Civil 3D objects have a ObjectName prefix string of "AECC".
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    1

    Default Re: Lisp code to wblock all objects except Civil 3D objects

    Code:
    (defun c:Wblock2D (/ ss)
    
      (if (setq ss (ssget "_:L" '((0 . "~AECC*"))))
        (progn
          (sssetfirst nil ss)
          (initcommandversion)
          (command "._wblock")
        )
      )
    
      (princ)
    )
    [Edit] - Selecting non-AECC objects is not necessarily the same as selecting 2D (non-3D) objects, FWIW.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  4. #4
    Member
    Join Date
    2016-02
    Location
    Calgary Alberta
    Posts
    14
    Login to Give a bone
    0

    Default Re: Lisp code to wblock all objects except Civil 3D objects

    BlackBox thank you!
    that is really better and definitely what I need for this, thanks for the code!

  5. #5
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    0

    Default Re: Lisp code to wblock all objects except Civil 3D objects

    Quote Originally Posted by Trevor Deleske View Post
    BlackBox thank you!
    that is really better and definitely what I need for this, thanks for the code!
    Happy to help.

    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  6. #6
    Member
    Join Date
    2016-02
    Location
    Calgary Alberta
    Posts
    14
    Login to Give a bone
    0

    Default Re: Lisp code to wblock all objects except Civil 3D objects

    Good morning BlackBox, I was testing out the code you had provided me and realized that it collects paperspace objects also.
    could I ask you to tweak it to not pickup paperspace objects?

    Regards

    Trevor

  7. #7
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    0

    Default Re: Lisp code to wblock all objects except Civil 3D objects

    Quote Originally Posted by Trevor Deleske View Post
    I was testing out the code you had provided me and realized that it collects paperspace objects also.
    could I ask you to tweak it to not pickup paperspace objects?
    Correct; the code above allows the user to graphically select of any non-AECC object.

    Given that even AECC objects created in paperspace are automagically moved to modelspace, they cannot be graphically selected from paperspace per-se.


    This will preclude selection outside of model tab:

    Code:
    (defun c:Wblock2D (/ ctab ss)
    
      (if
        (and
          (= "Model" (setq ctab (getvar 'ctab)))
          (setq ss (ssget "_:L" '((0 . "~AECC*"))))
        )
         (progn
           (sssetfirst nil ss)
           (initcommandversion)
           (command "._wblock")
         )
         (if (not ss)
           (prompt (strcat "\n** Command not allowed in " ctab " Tab ** \n"))
         )
      )
    
      (princ)
    )

    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  8. #8
    Member
    Join Date
    2016-02
    Location
    Calgary Alberta
    Posts
    14
    Login to Give a bone
    0

    Default Re: Lisp code to wblock all objects except Civil 3D objects

    thanks again BlackBox! this is not the first time you have helped me out.
    much appreciated!
    Kudos

    Trevor

  9. #9
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    0

    Default Re: Lisp code to wblock all objects except Civil 3D objects

    Quote Originally Posted by Trevor Deleske View Post
    thanks again BlackBox! this is not the first time you have helped me out.
    much appreciated!
    Kudos
    Cheers dude.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Similar Threads

  1. 2013: Use VB code to interact and control objects in ASD
    By lacthan in forum AutoCAD Structural Detailing
    Replies: 0
    Last Post: 2014-10-18, 07:55 AM
  2. Can't copy or Wblock drawing because of proxy objects
    By bmonk in forum AutoCAD General
    Replies: 6
    Last Post: 2013-08-12, 03:25 PM
  3. Replies: 7
    Last Post: 2010-11-19, 08:47 PM
  4. WBLOCK command inverts objects
    By jason.cyr13 in forum AutoCAD General
    Replies: 3
    Last Post: 2009-06-29, 09:24 PM
  5. Civil 3D Objects not displaying correctly in Civil 3D 2008
    By xstat21x in forum AutoCAD Civil 3D - General
    Replies: 1
    Last Post: 2007-05-10, 01:36 PM

Posting Permissions

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