I have now tested on my full autocad and adjusted the lisp accordingly.
The block is now positioned centrally below the text, allowing for the different scaling of the block (mm) and the drawing (m)
You are no longer asked to select text as it will now automatically select all text on the set layer.
I have indicated with comments items that can be changed to allow for different drawing set-ups
;;
(defun rh:gbbc (obj / ll ur lst c_pt)
(if (and obj (= (type obj) 'ENAME)) (setq obj (vlax-ename->vla-object obj)))
(cond (obj
(vlax-invoke-method obj 'getboundingbox 'll 'ur)
(setq lst (mapcar 'vlax-safearray->list (list ll ur))
c_pt (mapcar '(lambda (x y) (/ (+ x y) 2.0)) (car lst) (cadr lst))
);end_setq
)
);end_cond
c_pt
);end_defun
(defun dxf (key lst) (cdr (assoc key lst)))
(defun rh:put_att_val (atts att val) (vl-some '(lambda (x) (if (= (strcase att) (strcase (vla-get-tagstring x))) (vla-put-textstring x val))) atts))
(vl-load-com)
(defun c:test ( / *error* c_doc c_spc sv_lst sv_vals ss obj ent t_str i_pt n_obj atts) ;; your can change test to whatever you desire
(defun *error* ( msg )
(vla-regen c_doc acallviewports)
(mapcar 'setvar sv_lst sv_vals)
(if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error : ( " msg " ) occurred.")))
(princ)
);end_*error*_defun
(setq c_doc (vla-get-activedocument (vlax-get-acad-object))
c_spc (vlax-get-property c_doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
sv_lst (list 'cmdecho 'osmode)
sv_vals (mapcar 'getvar sv_lst)
blk "DEMANDA" ;BLOCK NAME
sc 0.5 ;BLOCK SCALE
);end_setq
(mapcar 'setvar sv_lst (list 0 0))
(setq ss (ssget "_X" '((0 . "TEXT") (8 . "Domicilios")))) ;Change (8 . "Domicilios") to the text layer you require
(cond (ss
(repeat (setq cnt (sslength ss))
(setq obj (vlax-ename->vla-object (setq ent (ssname ss (setq cnt (1- cnt)))))
t_no (atof (dxf 1 (entget ent)))
i_pt (mapcar '+ (rh:gbbc obj) '(0.0 -0.000033 0.0)) ;change the -0.000033 to the y axis offset you require
);end_setq
(cond ( (> t_no 11.0)
(setq t_str (vl-string-translate "." "," (rtos (* t_no 0.3) 2 1))
n_obj (vlax-invoke c_spc 'insertblock i_pt blk sc sc sc 0.0)
atts (vlax-invoke n_obj 'getattributes)
);end_setq
(rh:put_att_val atts "DEMANDA" t_str) ;change "DEMANDA" to the attribute tag your require
)
);end_cond
);end_repeat
(vla-regen c_doc acallviewports)
)
(t (alert "Nothing Selected"))
);end_cond
(mapcar 'setvar sv_lst sv_vals)
(princ)
);end_defun
I am not one of the robots you're looking for