Insert block with "entmake" on new drawings...

Insert block with "entmake" on new drawings...

Anonymous
Not applicable
1,788 Views
2 Replies
Message 1 of 3

Insert block with "entmake" on new drawings...

Anonymous
Not applicable

Hi Guys,

Im trying to insert a block with entmake, it's working, but only if the drawing already know the path of the block .dwg.

Obviously, when i create a new drawing, this code won't work, unless i insert at least one block with the "insert" command.

 

The code...

 

(entmake (list
'(0 . "INSERT")
'(66 . 0);
(cons 2 "blockname")  ;i can't put the path in here.
(cons 10 basepoint)
(cons 41 fator); X
(cons 42 fator); Y
(cons 43 fator); Z
(cons 50 0);
(cons 210 (list 0.0 0.0 1.0)))))

 

I could use 

(command "_.insert" "C:\\blocks\\blockname.dwg" basepoint "" "" "")

because i can specify the path.

 

Is there a way i can use the entmake and specify the block path so i can use the entget code on new drawings ?

Many thanks.

 

0 Likes
1,789 Views
2 Replies
Replies (2)
Message 2 of 3

Sea-Haven
Mentor
Mentor

I would have thought entmake is just that make an entity the block already exists so it contradicts.

 

if you use command insert then erase last it will be in the dwg for future use. 

Message 3 of 3

SeeMSixty7
Advisor
Advisor

Like @Sea-Haven said. The Block is not in the current drawing when you start new.

 

You will need to either create the block definition first, and then use the entmake code you have or insert the block using the "Command" method.

 

If it is a simple block you can simply check to see if the block is defined in the block table and if it is not, entmake the block definition, and then entmake the block insert.

Here is a sample of creating the block definition.

(setq _FDBLOCK "FileDate")
(setq _FDATT "DATESTAMP")
(defun CreateFileInfoBlockDefinition ()
   (setq cfibd-head   (list (cons 0 "BLOCK")
                            (cons 2 _FDBLOCK)
                            (cons 70 2)
                            (cons 3 "")
                            (cons 10 (list 0.0 0.0 0.0))
                      )
         cfibd-attdef (list (cons 0 "ATTDEF")
                            (cons 67 0)
                            (cons 8 "0")
                            (cons 62 7)
                            (cons 10 (list 0.0 0.0 0.0))
                            (cons 40 0.0703125)
                            (cons 1 _FDATT)
                            (cons 50 0.0)
                            (cons 41 0.9)
                            (cons 51 0.0)
                            (cons 7 "STANDARD")
                            (cons 71 0)
                            (cons 72 0)
                            (cons 11 (list 0.0 0.0 0.0))
                            (cons 210 (list 0.0 0.0 1.0))
                            (cons 3 _FDATT)
                            (cons 2 _FDATT)
                            (cons 70 0)
                            (cons 73 0)
                            (cons 74 0)
                            (cons 280 0)
                      )
         cfibd-endblk (list (cons 0 "ENDBLK"))
   )
   (entmake cfibd-head)
   (entmake cfibd-attdef)
   (entmake cfibd-endblk)
)

Good luck,

 

0 Likes