Hi All
I was able to reproduce the error that I need help with. I am attaching the code and a block for others to test. Here's the issue: if you run the attached code and insert the dynamic block into a drawing that doesn't have the block in it it works fine. However, if you try the routine in a drawing that has the dynamic block in it will give you an error message after block is inserted and manipulated by code. Here's the error message I get:
Current settings: Object conversion=Delete
Enter name of output file:
Enter name of existing block or
[= (block=output file)/* (whole drawing)] <define new drawing>:
I have a great number of dynamic blocks that I manipulate with code that started giving me this error message since version 2022. I have spent many hours on the internet trying to see if anyone else has encountered this problem to no avail. Any help and insights are greatly appreciated. Thanks.
Manuel
P.S. You will need to modify the path to the new location of the block on your end.
Code:
;___________________________________________________________________________________________________________
;
; Function for changing dynamic block properties with wildcards, with error checking and trapping
; Predcate function (returns T for success or nil for failure)
; Written By: Peter Jamtgaard copyright 2014 all rights reserved
; Syntax (dynamicpropertyset nil "Visibilit*" "none") ; <- nil indicates last entity
; Syntax (dynamicpropertyset (entlast) "Visibilit*" "none")
; Syntax (dynamicpropertyset objBlock "Visibilit*" "none")
;___________________________________________________________________________________________________________
(vl-load-com)
(defun CM:DPS (objBlock strWCDynamicProperty Value / objProperty)
(and
(or objBlock
(setq objBlock (entlast))
)
(or (= (type objBlock) 'VLA-OBJECT)
(and (= (type objBlock) 'ENAME)
(setq objBlock (vlax-ename->vla-object objBlock))
)
)
(= (type strWCDynamicProperty) 'STR)
Value
(wcmatch (vla-get-objectname objBlock) "AcDbBlockReference,AcDbMInsertBlock")
(= (vla-get-isdynamicblock objBlock) :vlax-true)
(apply 'or (mapcar '(lambda (objProperty)(and
(wcmatch (strcase (vla-get-propertyname objProperty))
(strcase strWCDynamicProperty)
)
(errortrap '(vla-put-value objProperty Value))
)
)
(vlax-invoke objBlock "getdynamicblockproperties")
)
)
)
)
;___________________________________________________________________________________________________________
;
; Standardized Error Trap
;___________________________________________________________________________________________________________
(defun ErrorTrap (symFunction / objError result X)
(if (vl-catch-all-error-p
(setq objError (vl-catch-all-apply
'(lambda (X)(set X (eval symFunction)))
(list 'result))))
nil
(if result result 'T)
)
)
(defun c:idblk (/ inspt )
(if (setq inspt (getpoint "\nSelect insertion point: "))
(progn
(if (tblsearch "BLOCK" "toilet")
(command "-insert" "toilet1" inspt 1 1 0)
(command "-insert" (strcat "C:\\CMA 2022\\MEP\\" "toilet1") inspt 1 1 0)
)
(CM:DPS (entlast) "Visibility" "Detailed")
)
)
(princ)
)