Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Blocks on the fly

3 REPLIES 3
Reply
Message 1 of 4
gregmcl
229 Views, 3 Replies

Blocks on the fly

I'm trying to make a block on the fly with lisp. I found this code on the net and it works fine.
(defun my_def () ;BLOCK Header definition:
(entmake '((0 . "BLOCK") (2 . "Test") (70 . 2) (10 0.0 0.0 0.0)))
;POINT marker definition:
(entmake '((0 . "POINT") (8 . "0") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (50 . 0.0)))
;Text ATTRIBUTE definition:
(entmake '((0 . "ATTDEF")
(8 . "0")
(10 4.0 -2.0 0.0)
(1 . "")
(2 . "TEST")
(3 . "tEST qUESTION")
(40 . 4.0)
(41 . 1.0)
(50 . 0.0)
(70 . 0)
(71 . 0)
(72 . 0)
(73 . 2)
)
) ;BLOCK's ending definition:
(entmake '((0 . "ENDBLK")))
)

However I have code that automatically at any entities to a selection set, how do I go about adding the entities from a selection set into a block definition, ie

(defun my_def () ;BLOCK Header definition:
(entmake '((0 . "BLOCK") (2 . "Test") (70 . 2) (10 0.0 0.0 0.0)))

; add my selection set entities

(repeat (setq cnt (sslength ent-collection))(setq cnt (1- cnt))(entget (ssname ent-collection cnt)))


;BLOCK's ending definition:
(entmake '((0 . "ENDBLK")))
)

Any help appreciated
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: gregmcl

you could use
(command "_block" ...
and add the entities of your selectionset
no entmake required

gregmcl wrote:

> I'm trying to make a block on the fly with lisp. I found this code on the net and it works fine.
> (defun my_def () ;BLOCK Header definition:
> (entmake '((0 . "BLOCK") (2 . "Test") (70 . 2) (10 0.0 0.0 0.0)))
> ;POINT marker definition:
> (entmake '((0 . "POINT") (8 . "0") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (50 . 0.0)))
> ;Text ATTRIBUTE definition:
> (entmake '((0 . "ATTDEF")
> (8 . "0")
> (10 4.0 -2.0 0.0)
> (1 . "")
> (2 . "TEST")
> (3 . "tEST qUESTION")
> (40 . 4.0)
> (41 . 1.0)
> (50 . 0.0)
> (70 . 0)
> (71 . 0)
> (72 . 0)
> (73 . 2)
> )
> ) ;BLOCK's ending definition:
> (entmake '((0 . "ENDBLK")))
> )
>
> However I have code that automatically at any entities to a selection set, how do I go about adding the entities from a selection set into a block definition, ie
>
> (defun my_def () ;BLOCK Header definition:
> (entmake '((0 . "BLOCK") (2 . "Test") (70 . 2) (10 0.0 0.0 0.0)))
>
> ; add my selection set entities
>
> (repeat (setq cnt (sslength ent-collection))(setq cnt (1- cnt))(entget (ssname ent-collection cnt)))
>
>
> ;BLOCK's ending definition:
> (entmake '((0 . "ENDBLK")))
> )
>
> Any help appreciated
Message 3 of 4
gregmcl
in reply to: gregmcl

Yeh, I thought of doing it with block, but the entmake way seem so much more elegant.
Message 4 of 4
Anonymous
in reply to: gregmcl

Hi,

The ideea is to append to the BLOCK (entmake ..) list, the lists returned by
applying (entget ...) to the items of the selection set. This should do it.

HTH

--
The difference between truth and fiction is that fiction has to make sense.



a écrit dans le message de news:
6391299@discussion.autodesk.com...
Yeh, I thought of doing it with block, but the entmake way seem so much more
elegant.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost