Thanks Lee,
But I am unsure that once I get inside the block's definition, I'll be able to get/set any parameter value for that block reference.
This was my attempt (bit longer than your suggestion - but practically the same):
(defun C:test ( / e BlkDef BlkRecord BlkRecXdict BlkEvalGraph EnamesOf-Actions_Parameters_Grips_Components rtn )
(while (not (and (setq e (car (entsel "\nSelect dynamic block: "))) (= "INSERT" (cdr (assoc 0 (entget e)))))) e )
(setq BlkDef (entget (tblobjname "BLOCK" (vla-get-EffectiveName (vlax-ename->vla-object e))) '("*") ))
(setq BlkRecord (digByItem 330 BlkDef))
(setq BlkRecXdict (digByName '(102 . "{ACAD_XDICTIONARY") BlkRecord))
(if (member '(3 . "ACAD_ENHANCEDBLOCK") BlkRecXdict)
(progn
(setq BlkEvalGraph (digByName '(3 . "ACAD_ENHANCEDBLOCK") BlkRecXdict))
(setq EnamesOf-Actions_Parameters_Grips_Components (mapcar 'cdr (vl-remove-if-not '(lambda (pair) (= 360 (car pair))) BlkEvalGraph)))
(setq rtn (mapcar '(lambda (x) (cdr (assoc 0 (entget x)))) EnamesOf-Actions_Parameters_Grips_Components)) ; check
); progn
); if
(if rtn (foreach x rtn (print x)))
(princ)
);| defun C:test |; (vl-load-com)
; Example: (digByItem 330 BlkDefElist)
(defun digByItem ( key elist / rtn )
(and
(listp elist) (mapcar 'car elist) (mapcar 'cdr elist) (assoc key elist) (= 'ENAME (type (cdr (assoc key elist))))
(setq rtn (entget (cdr (assoc key elist))))
)
rtn
); defun digByItem
; Example: (digByName '(102 . "{ACAD_XDICTIONARY") BlkRecordElist)
(defun digByName ( keyDpair elist / rtn )
(and
(listp keyDpair) (car keyDpair) (cdr keyDpair)
(listp elist) (mapcar 'car elist) (mapcar 'cdr elist)
(member keyDpair elist) (= 'ENAME (type (cdr (nth (1+ (vl-position keyDpair elist)) elist))))
(setq rtn (entget (cdr (nth (1+ (vl-position keyDpair elist)) elist))))
)
rtn
); defun digByName
In command prompt to confirm the results:
Select dynamic block:
"BLOCKLINEARPARAMETER"
"BLOCKLINEARGRIP"
"BLOCKGRIPLOCATIONCOMPONENT"
"BLOCKGRIPLOCATIONCOMPONENT"
"BLOCKLINEARPARAMETER"
"BLOCKLINEARGRIP"
"BLOCKGRIPLOCATIONCOMPONENT"
"BLOCKGRIPLOCATIONCOMPONENT"
"BLOCKLINEARPARAMETER"
"BLOCKLINEARGRIP"
"BLOCKGRIPLOCATIONCOMPONENT"
"BLOCKGRIPLOCATIONCOMPONENT"
"BLOCKLINEARPARAMETER"
"BLOCKLINEARGRIP"
"BLOCKGRIPLOCATIONCOMPONENT"
"BLOCKGRIPLOCATIONCOMPONENT"
"BLOCKSTRETCHACTION"
"BLOCKSTRETCHACTION"
"BLOCKSTRETCHACTION"
"BLOCKSTRETCHACTION"
I thought that the alternative VLA approach for this, would be like iterating thru the objects inside the block definition, but I was wrong:
_$ (while (not (and (setq e (car (entsel "\nSelect dynamic block: "))) (= "INSERT" (cdr (assoc 0 (entget e)))))) e )
nil
_$ (setq BlkRefObj (vlax-ename->vla-object e))
#<VLA-OBJECT IAcadBlockReference 000000890279eb48>
_$ (setq BlkDefObj (vla-item (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))) (vla-get-EffectiveName BlkRefObj)))
#<VLA-OBJECT IAcadBlock 000000890218ea78>
_$ (vlax-for o BlkDefObj (setq Lst (cons o Lst)))
(#<VLA-OBJECT IAcadAttribute 000000917c9001c8> #<VLA-OBJECT IAcadAttribute 000000917c9010a8> #<VLA-OBJECT IAcadAttribute 000000917c8ff748> #<VLA-OBJECT IAcadBlockReference 000000890279ee88> #<VLA-OBJECT IAcadBlockReference 000000890279ec18> #<VLA-OBJECT IAcadBlockReference 000000890279e188> #<VLA-OBJECT IAcadBlockReference 000000890279e0b8> #<VLA-OBJECT IAcadLine 00000089027a57d8> #<VLA-OBJECT IAcadLine 00000089027a3918> #<VLA-OBJECT IAcadLWPolyline 000000917c80f238> #<VLA-OBJECT IAcadAttribute 000000917c9001c8> #<VLA-OBJECT IAcadAttribute 000000917c9010a8> #<VLA-OBJECT IAcadAttribute 000000917c8ff748> #<VLA-OBJECT IAcadBlockReference 000000890279ee88> #<VLA-OBJECT IAcadBlockReference 000000890279ec18> #<VLA-OBJECT IAcadBlockReference 000000890279e188> #<VLA-OBJECT IAcadBlockReference 000000890279e0b8> #<VLA-OBJECT IAcadLine 00000089027a57d8> #<VLA-OBJECT IAcadLine 00000089027a3918> #<VLA-OBJECT IAcadLWPolyline 000000917c80f238>)
_$
Since there are no parameter objects collected in the list.
It seems that with vanilla lisp, we successfuly can extract the type of parameter type (assoc 0) and its "Tag Name" (assoc 305) and aswell the allowed values.
Do you have any ideas is it possible to set/get a dyn prop value with vanilla?
I always thought that if theres a way with VLA there must be a way with Vanilla.