this is not a compilation but rather another quick-written lisp, which kills dynamicy in every dynamic block and attributes to text in every block present in a dwg database. however original attributes will stay in block definition till specially written to kill them too.
;**************************************************************************************************************************************
; komondormrex, mar 2023
;**************************************************************************************************************************************
(defun c:Kill_Dynamicy_Attributes (/
block_before_name block_after_name block_collection layers_collection
attributes_list dtext_dxf block_layer true_color_object
original_block_insertion_point original_block_scale_XYZ_list
inserts_sset_object block_attributes_list
group_code group_data
xref_field xref_start xref_end xref camera_number
)
(vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
(setq block_collection (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
layers_collection (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
)
(if (null block_index) (setq block_index 0))
(if (null (vl-catch-all-error-p (vl-catch-all-apply 'vla-item (list (vla-get-selectionsets (vla-get-activedocument (vlax-get-acad-object))) "Inserts_Collection"))))
(vla-delete (vla-item (vla-get-selectionsets (vla-get-activedocument (vlax-get-acad-object))) "Inserts_Collection"))
)
(setq inserts_sset_object (vla-add (vla-get-selectionsets (vla-get-activedocument (vlax-get-acad-object))) "Inserts_Collection")
group_code (vlax-make-safearray vlax-vbinteger '(0 . 0))
)
(vlax-safearray-put-element group_Code 0 0)
(setq group_data (vlax-make-safearray vlax-vbvariant '(0 . 0)))
(vlax-safearray-put-element group_data 0 "insert")
(vla-selectonscreen inserts_sset_object group_code group_data)
(vlax-map-collection inserts_sset_object
'(lambda (object)
(cond
(
(and
(= "AcDbBlockReference" (vla-get-objectname object))
; (/= "*" (substr (setq block_before_name (vla-get-effectivename object)) 1 1))
(setq block_before_name (vla-get-effectivename object))
)
(setq original_block_insertion_point (vlax-get object 'insertionpoint)
original_block_scale_XYZ_list (list (vla-get-xscalefactor object) (vla-get-yscalefactor object) (vla-get-zscalefactor object))
attribute_name_list (mapcar '(lambda (attribute) (vla-get-tagstring attribute))
(vlax-invoke object 'getattributes)
)
)
(if (minusp (vlax-get object 'isdynamicblock))
(progn
(vla-converttostaticblock object (setq block_after_name (strcat block_before_name "_" (itoa (setq block_index (1+ block_index))))))
)
)
(if (and
(minusp (vlax-get object 'hasattributes))
(setq attributes_list (vlax-invoke object 'getattributes))
(setq block_attributes_list (mapcar '(lambda (attribute) (cons (vla-get-tagstring attribute) attribute)) attributes_list))
(null (setq block_attribute_definition_list nil))
(vlax-for every_block_object (vla-item block_collection (vla-get-name object))
(if (= "AcDbAttributeDefinition" (vla-get-objectname every_block_object))
(setq block_attribute_definition_list (append block_attribute_definition_list
(list (cons (cdr (assoc 2 (entget (vlax-vla-object->ename every_block_object))))
every_block_object
)
)
)
)
)
)
(if (assoc "HYPERLINK" block_attributes_list)
(setq xref_field (cdr (assoc 2 (entget (cdr (assoc 360 (dictsearch (cdr (assoc -1 (dictsearch (cdr (assoc 360 (entget (vlax-vla-object->ename (cdr (assoc "HYPERLINK" block_attributes_list)))))) "ACAD_FIELD"))) "TEXT"))))))
xref_start (vl-string-search "http" xref_field)
xref_end (vl-string-search "##" xref_field)
xref (substr xref_field (1+ xref_start) (- xref_end xref_start))
camera_number (vla-get-textstring (cdr (assoc "TXT" block_attributes_list)))
)
t
)
)
(progn
(foreach attribute attributes_list
(if (zerop (vlax-get (vla-item layers_collection (vla-get-layer attribute)) 'lock))
(progn
(if (zerop (vlax-get attribute 'invisible))
(progn
(setq dtext_dxf (vl-remove-if '(lambda (group) (member (car group) '(0 -1 330 5 280 2 70 74)))
(entget (vlax-vla-object->ename attribute))
)
)
(entmake (append '((0 . "TEXT")) dtext_dxf))
(setq dtext_object (vlax-ename->vla-object (entlast)))
(if (not (zerop (vla-get-alignment attribute)))
(progn
(vla-put-alignment dtext_object (vla-get-alignment attribute))
(vla-put-textalignmentpoint dtext_object (vla-get-textalignmentpoint attribute))
)
)
(setq dtext_in_block_object
(vlax-invoke (vla-get-activedocument (vlax-get-acad-object))
'copyobjects
(list dtext_object)
(vla-item block_collection (vla-get-name object))
)
)
(setq parent_attribute (cdr (assoc (cdr (assoc 2 (entget (vlax-vla-object->ename attribute)))) block_attribute_definition_list)))
(if (not (zerop (vla-get-alignment parent_attribute)))
(if (member "DIAM" attribute_name_list)
(vla-put-textalignmentpoint (car dtext_in_block_object) (vla-get-textalignmentpoint parent_attribute))
(vla-put-textalignmentpoint (car dtext_in_block_object) (vlax-3d-point (mapcar '/ (mapcar '- (vlax-get dtext_object 'textalignmentpoint) original_block_insertion_point) original_block_scale_XYZ_list)))
)
(if (member "DIAM" attribute_name_list)
(vla-put-insertionpoint (car dtext_in_block_object) (vla-get-insertionpoint parent_attribute))
(vla-put-insertionpoint (car dtext_in_block_object) (vlax-3d-point (mapcar '/ (mapcar '- (vlax-get dtext_object 'insertionpoint) original_block_insertion_point) original_block_scale_XYZ_list)))
)
)
(vla-put-height (car dtext_in_block_object) (vla-get-height parent_attribute))
(vla-put-rotation (car dtext_in_block_object) (vla-get-rotation parent_attribute))
(vl-catch-all-apply 'vla-put-layer (list (car dtext_in_block_object) "0")) ;(vla-get-layer object)))
(vla-put-truecolor (car dtext_in_block_object) (vla-get-truecolor parent_attribute))
(vla-erase dtext_object)
)
)
(vla-erase attribute)
)
(princ (strcat "\nSkip killing attribute on locked layer \"" (vla-get-layer attribute) "\""))
)
)
(foreach assoc_attribute block_attribute_definition_list
(vla-delete (cdr assoc_attribute))
)
(if (assoc "HYPERLINK" block_attributes_list)
(entmod (append (entget (vlax-vla-object->ename object)) (list (list -3 (list "PE_URL"
(cons 1000 xref)
(cons 1002 "{")
(cons 1000 camera_number)
(cons 1002 "{")
(cons 1071 1)
(cons 1002 "}")
(cons 1002 "}")
)
)
)
)
)
)
)
)
)
(
t
)
)
)
)
(vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
(princ)
)
;**************************************************************************************************************************************