@lzedCB hi,
Although i do not understand why one want to do such a thing but this was nice challenge to code 😀
and here is how it works:
if the selected block(s) has attributes + hyperlink, it will be explode and any ATTDEF inside will be set with the block hyperlink data - works?
enjoy
Moshe
(vl-load-com)
(defun c:hexp (/ attdef->text ; local function
ss AcDbBlkRef attributes hyperlinks first ent anchor elist0 elist1)
(defun attdef->text (e)
(entmake
(append
(list '(0 . "TEXT") '(72 . 4))
(vl-remove-if
'(lambda (dxf)
(member (car dxf) '(-1 0 2 3 5 70 72 74 100 102 280 330 347 360 370 440)) ; eliminate these dxf codes from elist
)
e
); vl-remove-if
); append
); entmake
); attdef->text
; here start c:hexp
(setvar "cmdecho" 0)
(command "._undo" "_begin")
(if (setq ss (ssget '((0 . "insert") (2 . "CUBO-T-SMB-VISTA.FOTO,`*U*"))))
(foreach ename (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
(setq AcDbBlkRef (vlax-ename->vla-object ename))
(if (and
(eq (strcase (vla-get-effectiveName AcDbBlkRef)) "CUBO-T-SMB-VISTA.FOTO")
(eq (vla-get-hasAttributes AcDbBlkRef) :vlax-true)
)
(progn
(foreach AcDbAttrib (vlax-invoke AcDbBlkRef 'getAttributes)
(setq attributes (cons (cons (strcase (vla-get-tagString AcDbAttrib)) (vla-get-textString AcDbAttrib)) attributes))
(vlax-release-object AcDbAttrib)
); vlax-for
(setq hyperlinks nil)
(vlax-for AcDbHyperLink (vla-get-hyperlinks AcDbBlkRef)
(setq hyperlinks (append hyperlinks (list (vla-get-URL AcDbHyperLink) (vla-get-URLNamedLocation AcDbHyperLink) (vla-get-URLdescription AcDbHyperLink))))
(vlax-release-object AcDbHyperLink)
); vlax-for
(if hyperlinks
(progn
(command "._point" "0,0,0")
(setq anchor (entlast) ent anchor)
(command "._explode" ename)
(while (setq ent (entnext ent))
(setq elist0 (entget ent))
(if (eq (cdr (assoc '0 elist0)) "ATTDEF")
(progn
(setq elist1 (attdef->text elist0))
(entmod (subst (cons '1 (cdr (assoc (strcase (cdr (assoc '2 elist0))) attributes))) (assoc '1 elist1) elist1))
(command "._-hyperlink" "_insert" "_object" "_si" (entlast) (car hyperlinks) (cadr hyperlinks) (caddr hyperlinks))
(entdel ent)
); progn
); if
); while
(entdel anchor)
); progn
); if
); progn
); if
(vlax-release-object AcDbBlkRef)
); foreach
); if
(command "._undo" "_end")
(setvar "cmdecho" 1)
(princ)
); c:hexp