TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: curmudgeon on August 13, 2009, 12:45:34 PM
-
I have a routine that traces "contiguous" arcs representing electrical circuits. I want to gather data along that "path" and save it as extended data in the home run, the arrow head for a particular circuit.
(setq store (list (cons 0 "INSERT")
(assoc 8 ent)
(cons 100 "AcDbBlockReference")
(cons 2 "ar_head")
(cons 10 head)
(cons 50 ang)
'((-3 ("rak"
(1000 . "Kenny is handsome")
(1000 . "And intelligent")
)
)
)
)
)
(entmake store)
without the extended data, it works as expected. you may recognize the source I am using, afralisp. but the examples I have found take an existing entity and add extended data to it. I was hoping to create, entmake, the original entity with the extended data in the first place.
is this possible?
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
I added this, and it works, but I would still like a more straightforward method.
(entmake store)
(entmod (append (entget (entlast))
'((-3
("rak"
(1000 . "Kenny is handsome")
(1000 . "And intelligent")
)
)
)
)
)
-
I always use the VL method when working with xdata, this may help you if you want to proceed in that way:
(defun putxdat (Obj App Data / ent type1 valeur)
(setq xtype
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray
vlax-vbInteger '(0 . 1)) '(1001 1000))))
(setq xval
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray
vlax-vbVariant '(0 . 1)) (list App Data))))
(vla-setXData Obj xtype xval))
-
The way I have done it is to make an entity list, then make my xdata list and append the latter onto the former
(setq x_dataList (list xData_app_name)
x_dataList (append x_dataList (list
(cons 1000 "EXISTING")
(cons 1010 sect_cl_pt)
(cons 1011 sect_cl_pt_zag)
(cons 1012 (car sect_coords))
(cons 1040 curr_station)
(cons 1070 zag)
(cons 1071 controlling_coord_pos)
);list
);append
pline_list_x (append pline_list (list (append '(-3) (list x_dataList)))) ;; pline_list is an 'entmake' list for a polyline
) ;setq
(entmake pline_list_x)
I can keep the 2 lists straight in my mind better if I keep them separate until the very last minute
-
;; try above block...
(regapp "rak")
(setq store (list (cons 0 "INSERT")
(assoc 8 ent)
(cons 100 "AcDbBlockReference")
(cons 2 "ar_head")
(cons 10 head)
(cons 50 ang)
'(-3 ("rak"
(1000 . "Kenny is handsome")
(1000 . "And intelligent")
)
)
)
)
(entmake store)
-
I use this for a simple string of xdata. It could be modified for multiples.
;++++++++++++ Add XDATA String To An Entity ++++++++++++++++++++++
(defun add_xdata_str (e a v);;;EName APPID String_value
(and (= (type a) 'STR)
(not (tblsearch "APPID" a))
(regapp a))
(and (= (type e) 'ENAME)
(= (type v) 'STR)
(entmod
(append (entget e)
(list
(cons -3
(list
(cons a
(list (cons 1000 v))))))))))
-David
-
;; try above block...
(regapp "rak")
(setq store (list (cons 0 "INSERT")
(assoc 8 ent)
(cons 100 "AcDbBlockReference")
(cons 2 "ar_head")
(cons 10 head)
(cons 50 ang)
'(-3 ("rak"
(1000 . "Kenny is handsome")
(1000 . "And intelligent")
)
)
)
)
(entmake store)
excellent. extra parenthesis. my bad.
to use vl methods I will have to retool my entire brain.
which can begin as soon as I remember where I left it.
thanks guys. you're the best.
-
No problem - I think I would have to retool my brain to get back to working with DXF...