<?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 Insert specific block at a POSITION parameter in another block in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-specific-block-at-a-position-parameter-in-another-block/m-p/11682298#M35807</link>
    <description>&lt;P&gt;Hi all!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a LISP command to automatically insert a "Position number" block at a point called "POSDATA" in my conveyor block. I tried using the following LISP, but it just doesn't work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:POS (/  valid_blocks f ss i e data dpp len)
  
;;(setq valid_blocks '("CONV-480-B190""));;
(setq f (lambda (p) (vlax-get e p)))

(if 
      (setq ss (ssget '((0 . "INSERT")(2 . "`*U*,CONV-*"))))
      
  	(repeat (setq i (sslength ss))
          (setq e (vlax-ename-&amp;gt;vla-object (ssname ss (Setq i (1- i)))))
          (setq data (mapcar 'f  '("Insertionpoint" "Rotation" "EffectiveName" "XScaleFactor")))

          (if (and
                ;;(member (caddr data) valid_blocks)
		(vl-string-search "CONV-" (caddr data))
                (setq dpp (mapcar '(lambda (e) (mapcar 'f
                                      '("PropertyName" "Value" )))
                                    (vlax-invoke e 'GetDynamicBlockProperties)))
                (&amp;gt; (setq len (cadr (Assoc "Posdata" dpp))) 0)
                )
		(vlax-invoke
		  (vlax-get (vla-get-ActiveLayout
		              (vla-get-activedocument
		                (vlax-get-acad-object)
		              )
		            )
		            'Block
		  )
		  'InsertBlock
		  (polar (car data)
                         (+ (if (minusp (last data)) pi 0.0) (Cadr data))
                         len)
		  "POSITION2"	;; block needs to be in drawing to execute command
		  1 1 1 0) ;; &amp;lt;-- block rotation 0
		)
            )
          )
  (princ)
  )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't have any experience in coding at all, so I don't know what to do other than replacing names and values in the code. Just for info, the conveyor blocks might vary in name, but they all start with "CONV-", eg.:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CONV-480-B180&lt;/P&gt;&lt;P&gt;CONV-580-B380&lt;/P&gt;&lt;P&gt;CONV-680-B90&lt;/P&gt;&lt;P&gt;and so on...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached example drawing with the conveyor block and the position block, and a description of what it is supposed to look like.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If any questions, I'll be glad to elaborate &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; thanks in advance&lt;/P&gt;</description>
    <pubDate>Mon, 16 Jan 2023 12:47:21 GMT</pubDate>
    <dc:creator>cksE6SE5</dc:creator>
    <dc:date>2023-01-16T12:47:21Z</dc:date>
    <item>
      <title>Insert specific block at a POSITION parameter in another block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-specific-block-at-a-position-parameter-in-another-block/m-p/11682298#M35807</link>
      <description>&lt;P&gt;Hi all!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a LISP command to automatically insert a "Position number" block at a point called "POSDATA" in my conveyor block. I tried using the following LISP, but it just doesn't work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:POS (/  valid_blocks f ss i e data dpp len)
  
;;(setq valid_blocks '("CONV-480-B190""));;
(setq f (lambda (p) (vlax-get e p)))

(if 
      (setq ss (ssget '((0 . "INSERT")(2 . "`*U*,CONV-*"))))
      
  	(repeat (setq i (sslength ss))
          (setq e (vlax-ename-&amp;gt;vla-object (ssname ss (Setq i (1- i)))))
          (setq data (mapcar 'f  '("Insertionpoint" "Rotation" "EffectiveName" "XScaleFactor")))

          (if (and
                ;;(member (caddr data) valid_blocks)
		(vl-string-search "CONV-" (caddr data))
                (setq dpp (mapcar '(lambda (e) (mapcar 'f
                                      '("PropertyName" "Value" )))
                                    (vlax-invoke e 'GetDynamicBlockProperties)))
                (&amp;gt; (setq len (cadr (Assoc "Posdata" dpp))) 0)
                )
		(vlax-invoke
		  (vlax-get (vla-get-ActiveLayout
		              (vla-get-activedocument
		                (vlax-get-acad-object)
		              )
		            )
		            'Block
		  )
		  'InsertBlock
		  (polar (car data)
                         (+ (if (minusp (last data)) pi 0.0) (Cadr data))
                         len)
		  "POSITION2"	;; block needs to be in drawing to execute command
		  1 1 1 0) ;; &amp;lt;-- block rotation 0
		)
            )
          )
  (princ)
  )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't have any experience in coding at all, so I don't know what to do other than replacing names and values in the code. Just for info, the conveyor blocks might vary in name, but they all start with "CONV-", eg.:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CONV-480-B180&lt;/P&gt;&lt;P&gt;CONV-580-B380&lt;/P&gt;&lt;P&gt;CONV-680-B90&lt;/P&gt;&lt;P&gt;and so on...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached example drawing with the conveyor block and the position block, and a description of what it is supposed to look like.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If any questions, I'll be glad to elaborate &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; thanks in advance&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2023 12:47:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-specific-block-at-a-position-parameter-in-another-block/m-p/11682298#M35807</guid>
      <dc:creator>cksE6SE5</dc:creator>
      <dc:date>2023-01-16T12:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: Insert specific block at a POSITION parameter in another block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-specific-block-at-a-position-parameter-in-another-block/m-p/11682639#M35808</link>
      <description>&lt;P&gt;Seems ok this way.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:POS (/  valid_blocks f ss i e data dpp lenx leny)
  
  ;;(setq valid_blocks '("CONV-480-B190""));;
  (setq f (lambda (p) (vlax-get e p)))
  
  (if
    (setq ss (ssget '((0 . "INSERT")(2 . "`*U*,CONV-*"))))
    
    (repeat (setq i (sslength ss))
      (setq e (vlax-ename-&amp;gt;vla-object (ssname ss (Setq i (1- i)))))
      (setq data (mapcar 'f  '("Insertionpoint" "Rotation" "EffectiveName" "XScaleFactor" "YScaleFactor")))
      
      (if (and
	    ;;(member (caddr data) valid_blocks)
	    (vl-string-search "CONV-" (caddr data))
	    (setq dpp (mapcar '(lambda (e) (mapcar 'f
						   '("PropertyName" "Value" )))
			      (vlax-invoke e 'GetDynamicBlockProperties)))
	    (setq lenx (cadr (Assoc "POSDATA X" dpp)))
	    (setq leny (cadr (Assoc "POSDATA Y" dpp)))
	    )
	
	(vlax-invoke
	  (vlax-get (vla-get-ActiveLayout
		      (vla-get-activedocument
			(vlax-get-acad-object)
			)
		      )
		    'Block
		    )
	  'InsertBlock
	  (polar (polar (car data)
			(+ (if (minusp (cadddr data)) pi 0.0) (Cadr data))
			lenx)
		 (+ (if (minusp (last data)) pi 0.0) (+ (* 0.5 pi) (Cadr data)))
		 leny)
	  "POSITION2"	;; block needs to be in drawing to execute command
	  1 1 1 0) ;; &amp;lt;-- block rotation 0
	)
      )
    )
  (princ)
  )
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2023 14:53:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-specific-block-at-a-position-parameter-in-another-block/m-p/11682639#M35808</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2023-01-16T14:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: Insert specific block at a POSITION parameter in another block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-specific-block-at-a-position-parameter-in-another-block/m-p/11682652#M35809</link>
      <description>&lt;P&gt;Seems to work as intended - thank you very much &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2023 14:55:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-specific-block-at-a-position-parameter-in-another-block/m-p/11682652#M35809</guid>
      <dc:creator>cksE6SE5</dc:creator>
      <dc:date>2023-01-16T14:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: Insert specific block at a POSITION parameter in another block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-specific-block-at-a-position-parameter-in-another-block/m-p/11700960#M35810</link>
      <description>&lt;P&gt;I noticed one minor issue (at least I hope it's minor). When I Rotate3D or 3DR one of my conveyors, the position-block doesn't adhere correctly to the snap point, but rather places itself several meters out in the open... Any ways to fix this?&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Captureconv.JPG" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1166292iFCCC4C8A679E16DB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Captureconv.JPG" alt="Captureconv.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 07:32:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-specific-block-at-a-position-parameter-in-another-block/m-p/11700960#M35810</guid>
      <dc:creator>cksE6SE5</dc:creator>
      <dc:date>2023-01-24T07:32:40Z</dc:date>
    </item>
  </channel>
</rss>

