add a block in a block

add a block in a block

etilley327KA
Advocate Advocate
271 Views
4 Replies
Message 1 of 5

add a block in a block

etilley327KA
Advocate
Advocate

How do add a block as an attribute for another block?

Im trying to add "block-name" to this block.

 

                  (entmake
                    (list
                      '(0 . "BLOCK")
                      (cons 2 blkname) ; block name
                      '(70 . 2)
                      (cons 8 clayerb)  ; layer
                      (cons 10 pnt)  ; insertion point
                      '(4 . "SRVPNOC")    ; comment
                      )
                    ) ; end of block
                ;       1=default value ; 2=Tag   ; 3=Prompt
                    (entmake
                       (list
                         '(0 . "ATTDEF")
                         (cons 8 clayer1)           ; layer
                         (cons 10 pnt)     ; insertion point
                         '(70 . 0)                  ; attribute flags (non-constant, invisible, doesn't lock)
                         (cons 3 "")                   ; 3=Prompt (empty string)
                         (cons 2  block-name)              ; 2=Tag (attribute tag)
                         (cons 1 "") ; 1=default value (attribute value)
                         (cons 40 htx)               ; height
                         (cons 41 wdy)               ; width
                         (cons 11 pnt)      ; match insertion point
                         '(72 . 0)                   ; 0=10 as insertion point
                       )
                     )
                    (entmake
                      (list
                        '(0 . "ATTDEF")
                        (cons 8 clayer2)                 ; layer
                        (cons 10 elevdir)   ; insertion point
                        '(70 . 0)                        ; attribute flags
                        '(3 . "Elevation Value")         ; 3=Prompt
                        '(2 . "ELEV2")                   ; 2=Tag
                        (cons 1 (rtos ELEV 2 2))   ; 1=default value
                        (cons 40 htx)                    ; height
                        (cons 41 wdy)                    ; width
                        (cons 7 styname)                 ; text style
                        (cons 11 elevdir) ; match insertion point
                        '(72 . 0)                      ; 0=10 as insertion point
                      )
                    )
                    (entmake '((0 . "ENDBLK")) )       ; end of block with attdef
                 
                  ; insert the block
                    (entmake
                      (list
                        '(0 . "INSERT")
                        (cons 2 blkname)   ; block name
                        (cons 8 clayeri)   ; layer
                        '(66 . 1)          ; has attributes
                        (cons 10 pnt) ; insertion point
                        (cons 41 sclx)     ; x scale
                        (cons 42 sclx)     ; y scale
                        (cons 43 sclx)     ; z scale
                      )
                    ) ; begin insert Block
                    ; attrib #1
                    (entmake
                       (list
                         '(0 . "ATTDEF")
                         (cons 8 clayer1)           ; layer
                         (cons 10 pnt)     ; insertion point
                         '(70 . 0)                  ; attribute flags (non-constant, invisible, doesn't lock)
                         (cons 3 "")                   ; 3=Prompt (empty string)
                         (cons 2  block-name)              ; 2=Tag (attribute tag)
                         (cons 1 "") ; 1=default value (attribute value)
                         (cons 40 htx)               ; height
                         (cons 41 wdy)               ; width
                         (cons 11 pnt)      ; match insertion point
                         '(72 . 0)                   ; 0=10 as insertion point
                       )
                     )
                    ; attrib #2
                    (entmake
                      (list
                        '(0 . "ATTRIB")
                        (cons 10 elevdir)   ; insertion point
                        (cons 8 clayer2)                  ; layer
                        (cons 1 (rtos ELEV 2 2))    ; 1=default value
                        '(2 . "ELEV2")                    ; 2=Tag
                        (cons 40 htx)                     ; height
                        '(70 . 0)                         ; attribute flags
                        (cons 41 wdy)                     ; width
                        (cons 7 styname)                  ; text style
                        (cons 11 elevdir)   ; insertion point
                        '(72 . 0)                         ; 0=10 as insertion point
                      )
                    )
                    (entmake '((0 . "SEQEND")))
0 Likes
Accepted solutions (1)
272 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant

I don't think a Block can be an Attribute in another Block.  It can be an object in the other Block's definition, just as a Line or a Circle can be -- a nested Block.

Kent Cooper, AIA
0 Likes
Message 3 of 5

etilley327KA
Advocate
Advocate
So do I just change "ATTDEF" to "BLOCK"?
0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

@etilley327KA wrote:
So do I just change "ATTDEF" to "BLOCK"?

No, because an ATTDEF has properties/DXF entries that a Block does not, like Tag and Prompt and various Text properties.  I don't have experience with (entmake)ing Blocks, but my guess is that it would need to be an "INSERT" object inside the outer Block's definition, because to do it manually you would Insert the nested Block.

Kent Cooper, AIA
0 Likes
Message 5 of 5

ronjonp
Mentor
Mentor

@etilley327KA 

How many of these blocks do you need to make? If not too many, I've found it much easier to use a template with them already defined.

0 Likes