Results 1 to 10 of 10

Thread: select dynamic blocks

  1. #1
    Active Member
    Join Date
    2011-07
    Location
    The Netherlands
    Posts
    62
    Login to Give a bone
    0

    Default select dynamic blocks

    Hi guys,

    When I want to select all blocks with a specific name in drawing area + all layouts, I use this command:
    (sssetfirst nil (ssget "_x" '((0 . "INSERT") (2 . "123"))))

    With this code I have selected all blocks with the name "123" in the model space and also all layouts.

    However, this does not work with Dynamic blocks... Is there also a way to select dynamic blocks?

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

    Default Re: select dynamic blocks

    Have you tried a search in the AutoLISP forum here? That has come up once or twice there.
    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
    Active Member
    Join Date
    2011-07
    Location
    The Netherlands
    Posts
    62
    Login to Give a bone
    0

    Default Re: select dynamic blocks

    Yes, but many threads and I lost after page 9 or so.. I did not see any thread with the same question.
    Do you have any link for me?

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

    Default Re: select dynamic blocks

    And that was after you searched that forum? Weird. I found something on the subject here and here. Both were in the top five in a search for "ssget dynamic blocks" in that forum.
    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

  5. #5
    Active Member
    Join Date
    2011-07
    Location
    The Netherlands
    Posts
    62
    Login to Give a bone
    0

    Default Re: select dynamic blocks

    Thank you,

    I found those already, but they don't answer the question. I want to sellect dyn blocks in modelspace + layout.
    If I would like to select them only in modelspace, I could use 'selectsimilar', that also works for dyn blocks. However that is another case.

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

    Default Re: select dynamic blocks

    The problem with dynamic blocks is once they are modified, the reference name is changed to an anonymous name. That is why your group code "2" doesn't work.

    To select all of the dynamic blocks for the name you are supplying to group code "2", you will need to cycle through all of the entities in a selection set containing all blocks in your drawing or layout. For each entity in your selection set, you will need to convert them to a VLA-OBJECT to allow you to query the EffectiveName property to match your block name.

    You could also modify the code T. Willey posted about querying the model space entities to do what you are attempting to do.
    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

  7. #7
    Certifiable AUGI Addict cadtag's Avatar
    Join Date
    2000-12
    Location
    Cairo - no, not Illinois
    Posts
    4,967
    Login to Give a bone
    0

    Default Re: select dynamic blocks

    It's not possible to create a selection set that spans multiple layouts and model space. What you will have to do is create a routine that selectes your blocks in model space, _does something with them_, and then sequentially step through each layout tab, creating a new selection set of your dynamic blocks, do something with them, and go on to the next layout tab. Gathering them all into a single selection set is just not a capability of autocad.

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

    Default Re: select dynamic blocks

    Quote Originally Posted by peysey View Post
    Hi guys,

    When I want to select all blocks with a specific name in drawing area + all layouts, I use this command:
    (sssetfirst nil (ssget "_x" '((0 . "INSERT") (2 . "123"))))

    With this code I have selected all blocks with the name "123" in the model space and also all layouts.

    However, this does not work with Dynamic blocks... Is there also a way to select dynamic blocks?
    Quote Originally Posted by peysey View Post
    Thank you,

    I found those already, but they don't answer the question. I want to sellect dyn blocks in modelspace + layout.
    If I would like to select them only in modelspace, I could use 'selectsimilar', that also works for dyn blocks. However that is another case.
    Not sure that you understand the difference between a Pickset and a SelectionSet.

    SelectSimilar 'selects' (onscreen) a Pickset - the set of entities that is actively 'selected' (picked) onscreen, that shows up in Properties Pane, etc. You can only 'select' (pick, onscreen) entities on your current tab (model, layout, etc).

    SelectionSets are programmatic and when used with "_x" selection method, contain entities from the entire database, which includes model, layout, etc. These entities can be iterated, and even modified (programmatically), but cannot be 'selected' (picked, onscreen) if they do not reside on the active tab (CTAB sysvar).

    To add to Opie's and cadtag's apt posts, please consider this example:

    Code:
    (vl-load-com)
    
    (defun c:BlockCount (/ blockName i ss)
      (if
        (and
          (setq blockName (getstring "\nEnter block name: "))
          (setq blockName (strcase blockName))
          (ssget "_x" '((0 . "INSERT")))
          )
        (progn
          (setq i 0)
          (vlax-for	x (setq ss (vla-get-activeselectionset
    			     (vla-get-activedocument (vlax-get-acad-object))))
    	(if (= blockName (strcase (vla-get-effectivename x)))
    	  (setq i (1+ i))
    	)
          )
          (prompt (strcat "\n** " (itoa i) " blocks found ** "))
          (vla-delete ss)
        )
      )
      (princ)
    )
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3630, Core i9-9900K 5.0GHz, 128GB RAM, Samsung 970 Pro M.2, 8GB NVIDIA Quadro P4000

  9. #9
    Active Member
    Join Date
    2011-07
    Location
    The Netherlands
    Posts
    62
    Login to Give a bone
    0

    Default Re: select dynamic blocks

    Hi guys, Thank you!

    I'm not (yet) capable of reading lisp codes, but I think I should change "blockname" to my own blockname? I did that by changing it to 123 (tha is my dynamic blockname):
    However, I could not let it work...

    What am I doing wrong?
    Code:
    (defun c:BlockCount (/ 123 i ss)
      (if
        (and
          (setq 123 (getstring "123"))
          (setq 123 (strcase 123))
          (ssget "_x" '((0 . "INSERT")))
          )
        (progn
          (setq i 0)
          (vlax-for	x (setq ss (vla-get-activeselectionset
    			     (vla-get-activedocument (vlax-get-acad-object))))
    	(if (= 123 (strcase (vla-get-effectivename x)))
    	  (setq i (1+ i))
    	)
          )
          (prompt (strcat "\n** " (itoa i) " blocks found ** "))
          (vla-delete ss)
        )
      )
      (princ)
    )
    Last edited by BlackBox; 2021-10-22 at 04:10 PM. Reason: Please use [CODE] Tags

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

    Default Re: select dynamic blocks

    Quote Originally Posted by peysey View Post
    Hi guys, Thank you!

    I'm not (yet) capable of reading lisp codes, but I think I should change "blockname" to my own blockname? I did that by changing it to 123 (tha is my dynamic blockname):
    However, I could not let it work...

    What am I doing wrong?
    Code:
    (defun c:BlockCount (/ 123 i ss)
      (if
        (and
          (setq 123 (getstring "123"))
          (setq 123 (strcase 123))
          (ssget "_x" '((0 . "INSERT")))
          )
        (progn
          (setq i 0)
          (vlax-for	x (setq ss (vla-get-activeselectionset
    			     (vla-get-activedocument (vlax-get-acad-object))))
    	(if (= 123 (strcase (vla-get-effectivename x)))
    	  (setq i (1+ i))
    	)
          )
          (prompt (strcat "\n** " (itoa i) " blocks found ** "))
          (vla-delete ss)
        )
      )
      (princ)
    )
    No, you should not do that.

    Please try the sample code before modifying it, and it might make more sense.

    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 3630, Core i9-9900K 5.0GHz, 128GB RAM, Samsung 970 Pro M.2, 8GB NVIDIA Quadro P4000

Similar Threads

  1. Quick Select &Dynamic; Blocks
    By Wish List System in forum AutoCAD Wish List
    Replies: 3
    Last Post: 2018-03-09, 05:00 PM
  2. Dynamic Blocks - Creating dynamic bolt blocks
    By jake1889 in forum Dynamic Blocks - Technical
    Replies: 3
    Last Post: 2014-08-08, 12:56 PM
  3. ssget to select inherited dynamic blocks
    By Wish List System in forum AutoCAD Wish List
    Replies: 1
    Last Post: 2012-06-18, 03:20 PM
  4. Select Dynamic Blocks by Current Visibility State
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2009-07-05, 10:03 PM
  5. How select dynamic blocks with a determinate visibility
    By mateo in forum Dynamic Blocks - Technical
    Replies: 1
    Last Post: 2005-10-28, 08:42 AM

Tags for this Thread

Posting Permissions

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