Jump to content

Lisp & Dynamic Block


REID7800

Recommended Posts

I'm not quite sure what you are trying to achieve using the LISP to select the grip - why not just select the grip manually?

 

If you wanted to modify the properties you would need to look into the code for getting at Dynamic Block properties, I have written a plethora of code for such here:

 

;; Retrieves All Properties from a Dynamic Block
;; Args: obj ~ Dynamic Block VLA-Object
;; Returns: ((<property name> <value>) ...)

(defun GetDynProps (obj)
 ;; Lee Mac  ~  07.04.10
 (mapcar
   (function
     (lambda (x / v)
       (list (vla-get-PropertyName x)
             (if (= 8192 (logand 8192 (vlax-variant-type (setq v (vla-get-value x)))))
               (vlax-safearray->list (vlax-variant-value v))
               (vlax-variant-value v)))))

   (vlax-invoke obj 'GetDynamicBlockProperties)))

;; Retrieves All Properties from a Dynamic Block
;; Args: obj ~ Dynamic Block VLA-Object
;; Returns: ((<property name> <value>) ...)

(defun GetDynProps (obj)
 ;; Lee Mac  ~  07.04.10
 (mapcar
   (function
     (lambda (x) (list (vla-get-PropertyName x) (vlax-get x 'Value))))

   (vlax-invoke obj 'GetDynamicBlockProperties)))

;; Changes a Dynamic Block Property Value
;; Args: obj  ~ Dynamic Block VLA-Object
;;       prop ~ Property Name
;;       val  ~ New Value
;; Returns: New Value (val)

(defun PutDynPropValue (obj prop val)
 ;; Lee Mac  ~  07.04.10
 (mapcar
   (function
     (lambda (x)
       (if (eq (strcase prop) (strcase (vla-get-propertyName x)))
         (vla-put-value x
           (vlax-make-variant val
             (vlax-variant-type (vla-get-value x)))))))

   (vlax-invoke obj 'GetDynamicBlockProperties)) val)

;; Retrieves the Allowed Values for a Specific Property
;; Args: obj  ~ Dynamic Block VLA-Object
;;       prop ~ Property Name
;; Returns: List of Allowed Values (or nil)

(defun GetPropAllowedValues (obj prop / a)
 ;; Lee Mac  ~  07.04.10
 (mapcar
   (function
     (lambda (x / w)
       (if (eq (strcase prop) (strcase (vla-get-propertyName x)))
         (setq a
           (mapcar
             (function
               (lambda (v)
                 (if (= 8192 (logand 8192 (vlax-variant-type v)))
                   (vlax-safearray->list (vlax-variant-value v))
                     (vlax-variant-value v))))

             (if (< 0 (vlax-safearray-get-u-bound
                        (setq w (vlax-variant-value
                                  (vla-get-AllowedValues x))) 1))

               (vlax-safearray->list w)))))))

   (vlax-invoke obj 'GetDynamicBlockProperties)) a)

;; Retrieves the Allowed Values for a Specific Property
;; Args: obj  ~ Dynamic Block VLA-Object
;;       prop ~ Property Name
;; Returns: List of Allowed Values (or nil)

(defun GetPropAllowedValues (obj prop / a)
 ;; Lee Mac  ~  07.04.10
 (mapcar
   (function
     (lambda (x)
       (if (eq (strcase prop) (strcase (vla-get-propertyName x)))
         (setq a (vlax-get x 'AllowedValues)))))

   (vlax-invoke obj 'GetDynamicBlockProperties)) a)

;; Retrieves the Allowed Values for all Properties
;; Args: obj  ~ Dynamic Block VLA-Object
;; Returns: ((<property name> (<Allowed Values>)) ...)

(defun GetAllowedValues (obj)
 ;; Lee Mac  ~  07.04.10
 (mapcar
   (function
     (lambda (x / w)
       (list (vla-get-propertyname x)
             (mapcar
               (function
                 (lambda (v)
                   (if (= 8192 (logand 8192 (vlax-variant-type v)))
                     (vlax-safearray->list (vlax-variant-value v))
                       (vlax-variant-value v))))

               (if (< 0 (vlax-safearray-get-u-bound
                          (setq w (vlax-variant-value
                                    (vla-get-AllowedValues x))) 1))

                 (vlax-safearray->list w))))))

   (vlax-invoke obj 'GetDynamicBlockProperties)))

;; Retrieves the Allowed Values for all Properties
;; Args: obj  ~ Dynamic Block VLA-Object
;; Returns: ((<property name> (<Allowed Values>)) ...)

(defun GetAllowedValues (obj)
 ;; Lee Mac  ~  07.04.10
 (mapcar
   (function
     (lambda (x)
       (list (vla-get-propertyname x)
             (vlax-get x 'AllowedValues))))

   (vlax-invoke obj 'GetDynamicBlockProperties)))

 

Lee, thank you for these sub-routines. I think I am finally starting to get the hang of some of this stuff and this is just the boost I need to get some real work done :).

I hope you don't mind me using them - I promise to keep them intact with your name on them.

Link to comment
Share on other sites

  • Replies 61
  • Created
  • Last Reply

Top Posters In This Topic

  • alanjt

    22

  • Lt Dan's legs

    17

  • Lee Mac

    12

  • REID7800

    8

Top Posters In This Topic

Posted Images

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...