请注意,没有必要以任何方式修改我的代码-
您应该使用所需的参数调用函数,例如:
- (defun c:test ( / blk )
- (if (and (setq blk (car (entsel "\nSelect dynamic block: ")))
- (setq blk (vlax-ename->vla-object blk))
- (= "AcDbBlockReference" (vla-get-objectname blk))
- (= :vlax-true (vla-get-isdynamicblock blk))
- )
- (LM:setdynpropvalue blk "distance1" 1.0)
- )
- (princ)
- )
- ;; Set Dynamic Block Property Value - Lee Mac
- ;; Modifies the value of a Dynamic Block property (if present)
- ;; blk - [vla] VLA Dynamic Block Reference object
- ;; prp - [str] Dynamic Block property name (case-insensitive)
- ;; val - [any] New value for property
- ;; Returns: [any] New value if successful, else nil
- (defun LM:setdynpropvalue ( blk prp val )
- (setq prp (strcase prp))
- (vl-some
- '(lambda ( x )
- (if (= prp (strcase (vla-get-propertyname x)))
- (progn
- (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x))))
- (cond (val) (t))
- )
- )
- )
- (vlax-invoke blk 'getdynamicblockproperties)
- )
- )
- (vl-load-com) (princ)
如果您在使用我的代码时保留我的代码头,我将不胜感激。 |