马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 newer 于 2016-5-17 20:09 编辑
问题:
Is there an example showing how to access dynamic block properties?
解决方案:
Here is a Visual Lisp example that iterates through dynamic properties of a selected block reference. If the property name is "Bolt Length" the value is printed on the command line. This shows the general approach to using ActiveX from Visual Lisp to access dynamic properties.
- (defun c:test (/ appAcad docCurrent utilObj oBkRef pt oProps i obj oPVar
- oPValue str
- )
- (vl-load-com)
- (setq appAcad (vlax-get-acad-object)
- docCurrent (vla-get-ActiveDocument appAcad)
- utilObj (vla-get-utility docCurrent)
- )
- (vla-getentity utilObj 'oBkRef pt "Select a dynamic block reference")
- (setq oProps (vlax-variant-value (vla-GetDynamicBlockProperties oBkRef)))
- (setq i (vlax-safearray-get-l-bound oProps 1))
- (while (<= i (vlax-safearray-get-u-bound oProps 1))
- (progn
- (setq obj (vlax-safearray-get-element oProps i)) ; (princ obj)
- (princ "\n")
- (princ (vla-get-PropertyName obj))
- (princ "\n")
- (if (= (vla-get-PropertyName obj) "Bolt Length")
- (progn
- (setq oPVar (vla-get-value obj))
- (setq oPValue (vlax-variant-value oPVar))
- (setq str (vla-get-propertyname obj))
- (setq str (strcat str " = "))
- (setq str (strcat str (rtos oPValue)))
- (princ str)
- (princ "\n")
- ) ; progn
- ) ; if
- (setq i (1+ i))
- ) ; progn
- ) ; while
- (princ)
- )
|