guitarguy1685 发表于 2022-7-6 11:40:07

Dynamic block and Autolisp & D

Is it possible to retrieve the name of a visibility state from a Dynamic Block?
 
I want a lisp that I can click on a block and then draw a leader and fill an attribute block with the block name.
 
I was able to make it work with a simple block but what of a Dynamic Block?
 
the DXF grp code "2" where the name of the block normally is just shows a "*U2" when it's a Dynamic block.
 
any ideas? Thanks in advance

lpseifert 发表于 2022-7-6 11:59:19

Q1
I can't take credit for this... posted by drsvsmani on Autodesk Discussion Groups
(defun DynamicProps (ename propname value / obj prpL cla cll prp)(setq obj (if (= (type ename) 'VLA-OBJECT) ename (vlax-ename->vla-object ename)))(setq prpL (vlax-invoke obj 'getdynamicblockproperties))(setq return(if (setq prp (vl-remove-if-not (function (lambda(x)(= (vlax-get-property x 'PropertyName) propname))) prpL))(mapcar (function (lambda(v)(if (and (/= value nil)(vlax-property-available-p v 'Value)(/= (type value)'LIST))(progn (vlax-put-property v 'Value value)(vla-update obj)))(if (and (vlax-property-available-p v 'AllowedValues) (vlax-get v 'AllowedValues))(list (vlax-get v 'Value)(vlax-get v 'AllowedValues))(vlax-get v 'Value)))) prp)(mapcar (function (lambda(v)(list (vla-get-propertyName v)(vlax-get v 'Value) v))) prpL)))return)(setq vs (DynamicProps (car (entsel)) "Visibility" nil))(car (car vs));returns current visibility stateQ2
 

(vlax-get (vlax-ename->vla-object (car (entsel))) 'EffectiveName)

BearDyugin 发表于 2022-7-6 12:23:18

(defun block_name (bloc / name)(vl-load-com) (setq        bloc (if (eq (type bloc) 'ENAME)       (vlax-ename->vla-object bloc)   )name (if (eq (type bloc) 'VLA-OBJECT)       (cond       ((= (vla-get-isdynamicblock bloc) :vlax-true)          (vla-get-effectivename bloc)       )       (t          (vla-get-name bloc)       )       )   ) ;_cond ))

guitarguy1685 发表于 2022-7-6 12:33:10

hmm i can't get either one to work

BearDyugin 发表于 2022-7-6 12:48:00

Has forgotten to load in a code vla functions (vl-load-com)
Geo_Point - name of the selected block
页: [1]
查看完整版本: Dynamic block and Autolisp & D