Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey everyone, thanks to @ВeekeeCZ, I obtained a LISP that inserts blocks by predetermining dynamic properties and attributes. However, I tried a lot and could not set the angle as radians. I always get the error of ; error: lisp value has no coercion to VARIANT with this type: ANG1.
Here is the LISP and DWG, I hope you may help.
(vl-load-com)
(defun c:INS123 ( / o dynprops atvalues)
(defun dtr (a)
(* pi (/ a 180.0))
)
(setq ang1 (dtr 25.0)) ; POSSIBLE ERROR POINT!!
(command-s "_.-insert" "BLOCKNAME1" "_b" "0,-10" "_s" 1 "_r" 0)
(setq dynprops '(
("Angle1" . ang1) ; POSSIBLE ERROR POINT!!
("Position1 X" . 10) ; all dyn-values are numbers - without ""
("Position1 Y" . 10)
("Position2 X" . 20) ; all dyn-values are numbers - without ""
("Position2 Y" . 20)
("Position3 X" . 30) ; all dyn-values are numbers - without ""
("Position3 Y" . 30)
("Position4 X" . 40) ; all dyn-values are numbers - without ""
("Position4 Y" . 40)
)
atvalues '(
("TAG1" . "VALUE11")
("TAG2" . "VALUE22")
("TAG3" . "VALUE33")
("TAG4" . "VALUE44")
))
(setq o (vlax-ename->vla-object (entlast)))
(LM:setdynprops o dynprops)
(LM:vl-setattributevalues o atvalues)
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Set Dynamic Block Properties - Lee Mac
;; Modifies values of Dynamic Block properties using a supplied association list.
;; blk - [vla] VLA Dynamic Block Reference object
;; lst - [lst] Association list of (( . ) ... )
;; Returns: nil
(defun LM:setdynprops ( blk lst / itm )
(setq lst (mapcar '(lambda ( x ) (cons (strcase (car x)) (cdr x))) lst))
(foreach x (vlax-invoke blk 'getdynamicblockproperties)
(if (setq itm (assoc (strcase (vla-get-propertyname x)) lst))
(vla-put-value x (vlax-make-variant (cdr itm) (vlax-variant-type (vla-get-value x)))))))
;; Set Attribute Values - Lee Mac
;; Sets attributes with tags found in the association list to their associated values.
;; blk - [vla] VLA Block Reference Object
;; lst - [lst] Association list of (( . ) ... )
;; Returns: nil
(defun LM:vl-setattributevalues ( blk lst / itm )
(foreach att (vlax-invoke blk 'getattributes)
(if (setq itm (assoc (vla-get-tagstring att) lst))
(vla-put-textstring att (cdr itm)))))
Solved! Go to Solution.