PDA

View Full Version : Using entmake to create a block


t-bone67
2005-06-05, 05:32 AM
I have this nice routine that inserts a user specified light fixture in the center of a room. At the moment it's using the insert command to insert a block from our symbols library, so the entire path to the appropriate directory is in the code. It works great, but if the symbols directory gets moved I'll have to go back and change the code or if I send my routines to an outsource I'll have to change the code and or send them my blocks.

Therefore, I want to use entmake to create the blocks and then insert them. I looked all through the Help file, but didn't find enough info to be useful. All I know is I need to make multiple calls to entmake. The first to establish I'm creating a block and an additional call for each entity that will be included in the block and the final call is to endblk (I think).

Can anybody help me out? All of them, except the ceiling fan symbol, are just circles, either a single circle, a double circle, or a circle with 2 lines forming an X. I thought it would be simple, but I can't find any example code to go by.

Thanks in advance!!

fixo
2005-06-06, 08:08 PM
You will excuse the code incorrect
Do not use this as finished solution a only as example.
Arbitrary symbols which draws program they can't
correspond to the graphic your standards
Try this one, tested in A2000
Thank you


(defun C:demo-block-entmake (/ clr ipt name osm p1 p2 p3 p4 rad)
(setq osm (getvar "osmode"))
(setvar "osmode" 0)
(setq name (getstring T "nBlock name n :"))
(initget 9)
(setq ipt (getpoint "nSpecify insertion point n :"))
(if (not (tblsearch "BLOCK" name))
(progn
(initget 7)
(setq rad (getdist "nCircle rad n :" ipt)
p1 (polar ipt (* pi 0.25) rad)
p2 (polar ipt (* pi 1.25) rad)
p3 (polar ipt (* pi 0.75) rad)
p4 (polar ipt (* pi 1.75) rad)
)
(entmake
(mapcar 'cons
(list 0 100 67 8 100 70 10 2 1)
(list "BLOCK" "AcDbEntity" 0
"0" "AcDbBlockBegin" 0
ipt name ""
)
)
)
(entmake
(mapcar 'cons
(list 0 100 8 62 100 10 40)
(list "CIRCLE" "AcDbEntity" "0" 1 "AcDbCircle" ipt rad)
)
)

(entmake
(mapcar 'cons
(list 0 100 8 62 100 10 11)
(list "LINE" "AcDbEntity" "0" 1 "AcDbLine" p1 p2)
)
)
(entmake
(mapcar 'cons
(list 0 100 8 62 100 10 11)
(list "LINE" "AcDbEntity" "0" 1 "AcDbLine" p3 p4)
)
)
(entmake
(mapcar 'cons
(list 0 100 67 8 100)
(list "ENDBLK" "AcDbEntity" 0 "0" "AcDbBlockEnd")
)
)
)
)
(entmake
(mapcar 'cons
(list 0 100 67 410 8 62 100 2 10 41 42 43 50 70 71 44 45 210)
(list
"INSERT"
"AcDbEntity"
0
(getvar "CTAB")
(getvar "CLAYER")
(progn
(setq clr (getvar "CECOLOR"))
(cond
((= clr "BYLAYER") 256)
((= clr "BYBLOCK") 0)
(T (atoi clr))
)
)
"AcDbBlockReference"
name
ipt
1.0
1.0
1.0
0.0
0
0
0.0
0.0
'(0 0 1)
)
)
)
(setvar "osmode" osm)
(princ)
)
(C:demo-block-entmake)
(princ)