Results 1 to 9 of 9

Thread: Simple ssget syntax question, I hope.

  1. #1
    Member
    Join Date
    2010-08
    Posts
    21
    Login to Give a bone
    0

    Talking Simple ssget syntax question, I hope.

    Hello,

    This will be simple for one of the regular pros.

    I have this one line of code.

    setq ss (ssget '((0 . "INSERT")(66 . 1)))

    Works perfect for selecting blocks with attributes.

    I want it to include all the nested blocks with attributes as well.

    I thought the ":V" parameter would work, but I am struggling with the syntax.
    It may even require a recursive routine.

    Your expertise would really help.

    Thank you.

  2. #2
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Simple ssget syntax question, I hope.

    Hello,

    Try it with the following code,

    Code:
    (setq ss (ssget '((0 . "INSERT")(66 . 1)(2 . "YourBlockName"))))
    Regards,

    Tharwat

  3. #3
    Member
    Join Date
    2010-08
    Posts
    21
    Login to Give a bone
    0

    Default Re: Simple ssget syntax question, I hope.

    Thanks for the post, but what I am trying to obtain is a selection set containing all blocks and nested blocks with attributes.

    not a specific known block,

    setq ss (ssget '((0 . "INSERT")(66 . 1)))

    works perfectly, unless i have a block within a block.

  4. #4
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Simple ssget syntax question, I hope.

    Yes the same code but you should add "_X" as the following;

    Code:
    (setq ss (ssget "_x"  '((0 . "INSERT")(66 . 1))))
    Regards,

  5. #5
    Member
    Join Date
    2010-08
    Posts
    21
    Login to Give a bone
    0

    Default Re: Simple ssget syntax question, I hope.

    again.. this does nothing for nested blocks.

    I want a selection set that includes all blocks and nested blocks with attributes

  6. #6
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Simple ssget syntax question, I hope.

    Actually the last code that I post is getting the selection but it would be under the name of
    the variable . And to check this out, enter !ss after implementing the code.

    Here is another one would select all Block and would hold them for an action ...
    Code:
    (sssetfirst nil(ssget "_x" '((0 . "INSERT")(66 . 1))))
    Try the following code to get the DXf for Block Attributes and upload them here to check
    them out by me.

    Code:
    (setq ss (car(entget(entsel))))
    Regards,

    Tharwat
    Last edited by tharwat; 2010-08-15 at 07:13 PM.

  7. #7
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Simple ssget syntax question, I hope.

    Quote Originally Posted by tufofi View Post
    again.. this does nothing for nested blocks.

    I want a selection set that includes all blocks and nested blocks with attributes
    That's impossible. You can't get a selection set of nested ANYTHINGs. You can only get selection sets of entities directly drawn in Model / Paper Space.

    To obtain access to the entities inside blocks you need to either use nentsel to pick one at a time. Or go into the block's definition:
    Code:
    (setq bdata (tblsearch "BLOCK" "BlockName")
    
    ;; Get 1st internal entity
    (setq ename (cdr (assoc -2 bdata)))
    ;; Step through all internals
    (while ename
      ;; Do whatever you want with that ename. It can be anything from lines, 
      ;; to attribute definitions, to other block references.
      (setq ename (entnext ename)) ;Get next internal
    )
    Note there is only one set of these entities per block NAME. Even if your block is copied 1,000,0000 times there's still only one definition - thus only one set of internal entities.

    A further note about attributes is that these are special "linked" entities. They always follow the block REFERENCE. Note the ATTDEF's inside the block are the attribute DEFINITIONS, not the attribute values. This can again be seen similar to the difference between block definitions and block references.

    To obtain the attribute values of a block reference use entnext after you've got the block reference's (INSERT's) ename:
    Code:
    ;; Get the 1st block from the selection set
    (setq blk_ename (ssname ss 0))
    ;; Get the entity following it
    (setq att_ename (entnext blk_ename))
    ;; Loop until the next entity is no longer an attribute
    (while (and att_ename ;Check if entity exists
                (setq att_data (entget att_ename)) ;Get its DXF data
                (eq (cdr (assoc 0 att_data)) "ATTRIB") ;Check if attribute
           )
      ;; Do whatever you want with the current attribute
      (setq att_ename (entnext att_ename)) ;Get the next entity
    )
    What you can do is using the above methods to step through the block definitions and / or the attributes following each block reference, you can add them to a list of enames. In this way you can use nth in much the same way as you'd use ssname.

  8. #8
    Member
    Join Date
    2010-08
    Posts
    21
    Login to Give a bone
    0

    Default Re: Simple ssget syntax question, I hope.

    Thanks for the excellent feedback.

    Makes more sense now, just trying to Frankenstein the ATTOUT.lsp routine to be more flexible with nested blocks. I want it to support arrangements of blocks even if blocked.
    So, technically the attribute handling has been handled for me.

    I narrowed the line of code down to
    setq ss (ssget '((0 . "INSERT")(66 . 1)))

    Your pieces of code above should help me tweak it to include all inserts, no matter how deep or nested. Although my plan may be flawed.

  9. #9
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Simple ssget syntax question, I hope.

    I know you want to modify the ATTOUT command, that's why you've got a selection set. It would have been more "consistent" if your modification simply did all the blocks in the current drawing. It would also be a bit easier. You could then just use the ActiveX block collection and step through it all. That way you've got absolutely everything graphical in the DWG, since this collection includes a block definition for Model Space, as well as a Paper Space block for each tab.

Similar Threads

  1. simple filename syntax question
    By tufofi in forum AutoLISP
    Replies: 3
    Last Post: 2011-07-08, 06:14 PM
  2. Need ssget syntax for color NOT bylayer
    By GeorgeM in forum AutoLISP
    Replies: 2
    Last Post: 2008-11-14, 07:56 PM
  3. Simple question - i hope
    By Mr Cory in forum AutoLISP
    Replies: 12
    Last Post: 2007-11-14, 07:55 PM
  4. First Braced Frame Elevations (simple questions I hope?) :)
    By scowsert in forum Revit Structure - General
    Replies: 2
    Last Post: 2007-07-05, 01:40 AM

Posting Permissions

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