(ssget "_x" (list (cons 8 "layername"))) inside blocks

(ssget "_x" (list (cons 8 "layername"))) inside blocks

davidkoh007
Contributor Contributor
4,686 Views
15 Replies
Message 1 of 16

(ssget "_x" (list (cons 8 "layername"))) inside blocks

davidkoh007
Contributor
Contributor

Hi, I have an issue with (ssget "_x" (list (cons 8 "layername"))). It doesnt create selection set from entities that are inside blocks.

How can create selection set from these? Thanks for help.

0 Likes
Accepted solutions (2)
4,687 Views
15 Replies
Replies (15)
Message 2 of 16

cadffm
Consultant
Consultant

SelectionSets of these objects are useless (99%),

tell us what you want to do with the objects!

Sebastian

0 Likes
Message 3 of 16

davidkoh007
Contributor
Contributor

entmod the layer

0 Likes
Message 4 of 16

SeeMSixty7
Advisor
Advisor
Accepted solution

The process for that would be to open the block definitions of the blocks and then modify the layer. If you are talking about attributes attached to inserts, then that would be stepping through all blocks that have attributes, looking at each layer of those and then updating that entitiy.

 

;something similar to update block definitions
(setq bldata (tblnext "BLOCK" T)) (while bldata ;....step through the block definitions and make your changes
)
0 Likes
Message 5 of 16

cadffm
Consultant
Consultant
Accepted solution

You have to iterate thru all blocks,

check all the objects, if LayerX, then..

 

Add you 'check if layer is "mylayerX" then..

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/change-a-layer-within-all-blocks/td-...

Or search 5min more, you will find 100 samples to do this.

Sebastian

0 Likes
Message 6 of 16

davidkoh007
Contributor
Contributor

Seems like going through the blocks is the way to go. I just thought there's a more straightforward way I was missing. Thanks.

0 Likes
Message 7 of 16

SeeMSixty7
Advisor
Advisor

Another solution could be LAYTRANS command. If you are just trying to remap a layer to another layer.

For instance if you have Layer A inside all your block and you want them to be MYNEWLAYER. You coudl easily do that in a couple of clicks.

 

Good luck,

0 Likes
Message 8 of 16

davidkoh007
Contributor
Contributor

The issue is i'm using BricsCAD v12 which doesnt support laymrg or laytrans. So I gotta code it myself.

0 Likes
Message 9 of 16

SeeMSixty7
Advisor
Advisor

Well here is my BLK20 command that updates blocks by selection or all blocks in drawing to move all ents within a block to 0, color = BYLAYER, linetype=bylayer.

 

You can probably use this a s good starting point.

 

Good luck,

 

(defun c:blk20( / bldata hdent hddata oldcol oldlay
                  newlay oldlin newcol1 newcol newlin
                  newlin1 ans sel1
              )
  (initget "A S")
  (setq ans (getkword "\nRedefine All Blocks or Select Block <S>: "))
  (if (or (not ans) (= ans "") (= ans "S"))
    (progn
       (setq blname (cdr (assoc 2 
                         (entget (car 
                         (entsel "\nSelect block to Redefine: "))))
                    )
             bldata (tblsearch "BLOCK" blname)
             sel1   T
       )
    )
    (setq bldata (tblnext "BLOCK" T))
  )
  (while bldata
   (setq hdent  (cdr (assoc -2 bldata))
         bldata (reverse (cdr (reverse bldata)))
   )
   (entmake bldata)
   (while hdent
      (setq hddata (entget hdent)
            oldcol (assoc 62 hddata)
            oldlay (assoc 8 hddata)
            newlay (cons 8 "0")
            oldlin (assoc 6 hddata)
            hddata (subst newlay oldlay hddata)
      )
      (if oldcol
        (progn
          (setq newcol (cdr (member oldcol hddata))
                newcol1(reverse (cdr (member oldcol (reverse hddata))))
                hddata (append newcol1 newcol)
          )
        )
      )
      (if oldlin
        (progn
          (setq newlin (cdr (member oldlin hddata))
                newlin1(reverse (cdr (member oldlin (reverse hddata))))
                hddata (append newlin1 newlin)
          )
        )
      )
      (setq hddata (cdr hddata))
      (entmake hddata)
      (setq hdent (entnext hdent))
   )
   (entmake (list (cons 0 "ENDBLK")))
   (if sel1
      (setq bldata nil)
      (setq bldata (tblnext "BLOCK"))
   )
  )
  (prompt "\nRedfinition complete!")
)
0 Likes
Message 10 of 16

ronjonp
Mentor
Mentor

@davidkoh007 wrote:

entmod the layer


You don't need to iterate anything if you are changing the layer properties. Unless you meant entmod the object on a certain layer ?

0 Likes
Message 11 of 16

davidkoh007
Contributor
Contributor

entmod layer (dxf group code 😎 of a certain object. nvm i will eventually code it, just didnt have the time to get to it yet

0 Likes
Message 12 of 16

dbroad
Mentor
Mentor

If you're using Bricscad, why seek solutions on Autodesk forums?  Unless we are using Bricscad, there's no way we even know its command and customization capabilities, although, from looking at its website, it looks like an AutoCAD knock-off. I'm really surprised that the product isn't being sued for copyright infringement.  The ribbon looks almost identical to AutoCAD.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 13 of 16

ronjonp
Mentor
Mentor

@dbroad Competition is a good thing IMO. Bricscad is actively developing its product and addressing issues brought up from its users in weeks not years. Should Microsoft have sued Autodesk for using their ribbon idea? 🤔

 

0 Likes
Message 14 of 16

pendean
Community Legend
Community Legend
Umm, who cares what Bricscad is doing, why post on an Autodesk forum?

They have a healthy forum community with lots of timely answer to their softwares' questions here https://forum.bricsys.com/

0 Likes
Message 15 of 16

ronjonp
Mentor
Mentor

@pendean wrote:
Umm, who cares what Bricscad is doing, why post on an Autodesk forum?

They have a healthy forum community with lots of timely answer to their softwares' questions here https://forum.bricsys.com/


WOW ... maybe you're right 😑. With that attitude this probably is the wrong place to post. They should have posted at TheSwamp or CADTutor. I know plenty of people there will happily solve problems for both AutoCAD and Bricscad.

0 Likes
Message 16 of 16

davidkoh007
Contributor
Contributor

I came here to debate on a LISP matter because I know this is a friendly and a helpful community, I didn't come here to argue about different software.

0 Likes