<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic LISP ROUTINE - Setting Dynamic Properties Problem while Inserting Block in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-routine-setting-dynamic-properties-problem-while-inserting/m-p/10482771#M57937</link>
    <description>&lt;P&gt;Hey everyone, thanks to&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1779365"&gt;@ВeekeeCZ&lt;/a&gt;, 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&amp;nbsp;&lt;STRONG&gt;; error: lisp value has no coercion to VARIANT with this type: ANG1.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the LISP and DWG, I hope you may help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(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-&amp;gt;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)))))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Jul 2021 16:15:41 GMT</pubDate>
    <dc:creator>emreakyazici</dc:creator>
    <dc:date>2021-07-20T16:15:41Z</dc:date>
    <item>
      <title>LISP ROUTINE - Setting Dynamic Properties Problem while Inserting Block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-routine-setting-dynamic-properties-problem-while-inserting/m-p/10482771#M57937</link>
      <description>&lt;P&gt;Hey everyone, thanks to&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1779365"&gt;@ВeekeeCZ&lt;/a&gt;, 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&amp;nbsp;&lt;STRONG&gt;; error: lisp value has no coercion to VARIANT with this type: ANG1.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the LISP and DWG, I hope you may help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(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-&amp;gt;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)))))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 16:15:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-routine-setting-dynamic-properties-problem-while-inserting/m-p/10482771#M57937</guid>
      <dc:creator>emreakyazici</dc:creator>
      <dc:date>2021-07-20T16:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: LISP ROUTINE - Setting Dynamic Properties Problem while Inserting Block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-routine-setting-dynamic-properties-problem-while-inserting/m-p/10482819#M57938</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10060062"&gt;@emreakyazici&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try updating this portion of your code:&lt;/P&gt;&lt;PRE&gt;  (setq dynprops (&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;list&lt;/STRONG&gt;&lt;/FONT&gt;

		   (&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;cons&lt;/STRONG&gt;&lt;/FONT&gt; "Angle1" ang1) ; POSSIBLE ERROR POINT!!
		   &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;'&lt;/STRONG&gt;&lt;/FONT&gt;("Position1 X" . 10)			; all dyn-values are numbers - without ""
		   &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;'&lt;/STRONG&gt;&lt;/FONT&gt;("Position1 Y" . 10)

		   &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;'&lt;/STRONG&gt;&lt;/FONT&gt;("Position2 X" . 20)			; all dyn-values are numbers - without ""
		   &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;'&lt;/STRONG&gt;&lt;/FONT&gt;("Position2 Y" . 20)

		   &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;'&lt;/STRONG&gt;&lt;/FONT&gt;("Position3 X" . 30)			; all dyn-values are numbers - without ""
		   &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;'&lt;/STRONG&gt;&lt;/FONT&gt;("Position3 Y" . 30)

		   &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;'&lt;/STRONG&gt;&lt;/FONT&gt;("Position4 X" . 40)			; all dyn-values are numbers - without ""
		   &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;'&lt;/STRONG&gt;&lt;/FONT&gt;("Position4 Y" . 40)

		   )&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your error was happening because you are "quoting" which does not &lt;U&gt;evaluate&lt;/U&gt; the 'ang1' variable. To prevent this in the future you can read the differences here:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.lee-mac.com/quote.html" target="_blank" rel="noopener"&gt;http://www.lee-mac.com/quote.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;~DD&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 16:38:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-routine-setting-dynamic-properties-problem-while-inserting/m-p/10482819#M57938</guid>
      <dc:creator>CodeDing</dc:creator>
      <dc:date>2021-07-20T16:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: LISP ROUTINE - Setting Dynamic Properties Problem while Inserting Block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-routine-setting-dynamic-properties-problem-while-inserting/m-p/10482837#M57939</link>
      <description>&lt;P&gt;Oh, thank you so much. It's working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you don't mind, I have a second question. I have a basic second command which creates lines according to insert point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I merge these commands, according to insert point and previous LISP? I tried a little but, couldn't manage.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:S55 ( / p1 p2 p3 p4)
(setq p1 (getpoint "\nLine origin: "))
(setq p2 (mapcar '+ p1 '(5 5 0)))
(setq p3 (mapcar '+ p1 '(0 -5 0)))


(setq p4 (mapcar '+ p3 '(60 0 0)))
(setq p5 (mapcar '+ p3 '(-60 0 0)))



(entmakex (list '(0 . "LINE")(cons 10 p1)(cons 11 p3)))
(entmakex (list '(0 . "LINE")(cons 10 p3)(cons 11 p4)))
(entmakex (list '(0 . "LINE")(cons 10 p3)(cons 11 p5)))

)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 16:46:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-routine-setting-dynamic-properties-problem-while-inserting/m-p/10482837#M57939</guid>
      <dc:creator>emreakyazici</dc:creator>
      <dc:date>2021-07-20T16:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: LISP ROUTINE - Setting Dynamic Properties Problem while Inserting Block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-routine-setting-dynamic-properties-problem-while-inserting/m-p/10483207#M57940</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10060062"&gt;@emreakyazici&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you trying to merge your S55 command with the INS123 command? Is that what you mean?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 19:50:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-routine-setting-dynamic-properties-problem-while-inserting/m-p/10483207#M57940</guid>
      <dc:creator>CodeDing</dc:creator>
      <dc:date>2021-07-20T19:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: LISP ROUTINE - Setting Dynamic Properties Problem while Inserting Block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-routine-setting-dynamic-properties-problem-while-inserting/m-p/10490583#M57941</link>
      <description>&lt;P&gt;Yes. I need to add properly S55 to INS123, briefly.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jul 2021 12:26:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-routine-setting-dynamic-properties-problem-while-inserting/m-p/10490583#M57941</guid>
      <dc:creator>emreakyazici</dc:creator>
      <dc:date>2021-07-23T12:26:17Z</dc:date>
    </item>
  </channel>
</rss>

