Author Topic: Getting bad argument type: VLA-OBJECT <Entity name> when selecting dynamic block  (Read 58 times)

0 Members and 1 Guest are viewing this topic.

Shady_Shiba

  • Mosquito
  • Posts: 5
Grettings,

I wanted to be able to set an attribute from the block's dynamic property table by selecting the "sort" Value in the block, but I get an error code in return.

Im starting to think if it's the dynamic block itself. I've attached both lisp and dwg files if it is either of them or both. :idea:


Code: [Select]
(defun c:reg (/ ent)
  (setq ent (car (entsel)))
  (LM:setdynpropvalue ent "SORT" "04")
  (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)
    )
)

steve.carson

  • Newt
  • Posts: 52
You are passing an ename to Lee's function, when it wants a VLA object. Look into the vlax-ename->vla-object function.

Shady_Shiba

  • Mosquito
  • Posts: 5
that was exactly what I needed! :uglystupid2:


 thank you kind sir

steve.carson

  • Newt
  • Posts: 52
You are very welcome.  :-)