<?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 Re: Get insertion point, then do something... in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-insertion-point-then-do-something/m-p/6705519#M126214</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/671374"&gt;@CSM_MAI&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have a lisp routine that will get the insertion point of a border/block, and then move it to the origin. I've looked around on the forum, but i'm not quite sure what to look for. I want the lisp to get the insertion point (location on drawing) of the border(which I have), see if it is at "0,0,0", if so do this, if not do this.(that part I do not have). I'm just looking for some direction and any info would be appreciated. I had though about &amp;nbsp; (setq pt1 (getpoint bdr)) might be a closer step in the right direction.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is most&amp;nbsp;of the code I am working with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(defun c:mall ()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;(if &lt;U&gt;(setq bdr (cdr (assoc 10 (entget (ssname (ssget "_X" '((2 . "border"))) 0)))))&lt;/U&gt; &lt;STRONG&gt;This part is just getting the insertion point.&amp;nbsp;Replace with&amp;nbsp;this to check if it is at 0,0,0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;EM&gt;(equal '(0.0 0.0 0.0) (setq bdr (cdr (assoc 10 (entget (ssname (ssget "_X" '((2 . "border"))) 0))))))&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; (prong&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(princ "\n Drawing Border already at Origin...")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(progn&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(command "_select" "all" "")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(command "._move" "p" "" bdr "0,0,0")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(princ "\n Drawing border moved to Origin...")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;) ;end if&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(princ)&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Nov 2016 15:44:59 GMT</pubDate>
    <dc:creator>Ranjit_Singh</dc:creator>
    <dc:date>2016-11-23T15:44:59Z</dc:date>
    <item>
      <title>Get insertion point, then do something...</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-insertion-point-then-do-something/m-p/6705487#M126212</link>
      <description>&lt;P&gt;I have a lisp routine that will get the insertion point of a border/block, and then move it to the origin. I've looked around on the forum, but i'm not quite sure what to look for. I want the lisp to get the insertion point (location on drawing) of the border(which I have), see if it is at "0,0,0", if so do this, if not do this.(that part I do not have). I'm just looking for some direction and any info would be appreciated. I had though about &amp;nbsp; (setq pt1 (getpoint bdr)) might be a closer step in the right direction.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is most&amp;nbsp;of the code I am working with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(defun c:mall ()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;(if (setq bdr (cdr (assoc 10 (entget (ssname (ssget "_X" '((2 . "border"))) 0)))))&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; (progn&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;EM&gt;*****&lt;/EM&gt;&lt;U&gt;&lt;EM&gt;This is the part I have no idea what to do with&lt;/EM&gt;&lt;/U&gt;&lt;EM&gt;****&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/EM&gt;&lt;EM&gt;******&lt;/EM&gt;&lt;U&gt;&lt;EM&gt;I want it to do nothing but the prompt below if the drawing border is already at "0,0,0"&lt;/EM&gt;&lt;/U&gt;&lt;EM&gt;****&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(princ "\n Drawing Border already at Origin...")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(progn&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(command "_select" "all" "")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(command "._move" "p" "" bdr "0,0,0")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(princ "\n Drawing border moved to Origin...")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;) ;end if&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(princ)&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 15:32:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-insertion-point-then-do-something/m-p/6705487#M126212</guid>
      <dc:creator>CSM_MAI</dc:creator>
      <dc:date>2016-11-23T15:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: Get insertion point, then do something...</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-insertion-point-then-do-something/m-p/6705518#M126213</link>
      <description>&lt;P&gt;Try something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:mall (/ bdr)
  (if (setq bdr (cdr (assoc 10 (entget (ssname (ssget "_X" '((2 . "border"))) 0)))))
    (if (equal bdr '(0 0 0) 1e-4)
      (prompt "\n Drawing Border already at Origin..."); then
      (progn ; else
        (command "._move" "all" "" "_none" bdr "_none" "0,0,0")
        (prompt "\n Drawing and border moved to Origin...")
      ); progn
    ); if [at origin or not]
  ); if [border found]
  (princ) 
); defun
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might want to add another test before going through with processing it -- whether that "border" Block/Xref is found.&amp;nbsp; If it's not, you'll get an error from the attempt to get an insertion point from something that doesn't exist.&amp;nbsp; And there's also the possibility that it will be found in a &lt;EM&gt;different space&lt;/EM&gt; than you're currently in -- if you might ever run this [for example] in Model Space when the border is in Paper Space, you'll get unexpected results, so adjustments should be made.&amp;nbsp; Also, if you ever use non-World User Coordinate Systems, you might want to account for that with [I would assume]&amp;nbsp;translation of the insertion point and the Move displacement points to work in World coordinates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I simplified some things [e.g. no need to select everything and then use the Previous selection in the Move command].&amp;nbsp; And I put in "none" Osnap calls before the Move displacement points, in case Object Snap is on and there might be anything in the vicinity that could throw things off.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 15:56:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-insertion-point-then-do-something/m-p/6705518#M126213</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2016-11-23T15:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: Get insertion point, then do something...</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-insertion-point-then-do-something/m-p/6705519#M126214</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/671374"&gt;@CSM_MAI&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have a lisp routine that will get the insertion point of a border/block, and then move it to the origin. I've looked around on the forum, but i'm not quite sure what to look for. I want the lisp to get the insertion point (location on drawing) of the border(which I have), see if it is at "0,0,0", if so do this, if not do this.(that part I do not have). I'm just looking for some direction and any info would be appreciated. I had though about &amp;nbsp; (setq pt1 (getpoint bdr)) might be a closer step in the right direction.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is most&amp;nbsp;of the code I am working with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(defun c:mall ()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;(if &lt;U&gt;(setq bdr (cdr (assoc 10 (entget (ssname (ssget "_X" '((2 . "border"))) 0)))))&lt;/U&gt; &lt;STRONG&gt;This part is just getting the insertion point.&amp;nbsp;Replace with&amp;nbsp;this to check if it is at 0,0,0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;EM&gt;(equal '(0.0 0.0 0.0) (setq bdr (cdr (assoc 10 (entget (ssname (ssget "_X" '((2 . "border"))) 0))))))&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; (prong&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(princ "\n Drawing Border already at Origin...")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(progn&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(command "_select" "all" "")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(command "._move" "p" "" bdr "0,0,0")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(princ "\n Drawing border moved to Origin...")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;) ;end if&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;(princ)&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 15:44:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-insertion-point-then-do-something/m-p/6705519#M126214</guid>
      <dc:creator>Ranjit_Singh</dc:creator>
      <dc:date>2016-11-23T15:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: Get insertion point, then do something...</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-insertion-point-then-do-something/m-p/6705539#M126215</link>
      <description>&lt;P&gt;In addition to what Kent said, you may also wish to use the trans function on both of the points during the move command in case the origin is not the World Coordinate System.&amp;nbsp; Also if bdr is not equal to (trans bdr 0 1) then you might want to notify the user.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; (command "._move" "p" "" (trans bdr 0 1)  (trans '(0 0 0) 0 1))&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Nov 2016 15:54:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-insertion-point-then-do-something/m-p/6705539#M126215</guid>
      <dc:creator>dbroad</dc:creator>
      <dc:date>2016-11-23T15:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: Get insertion point, then do something...</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-insertion-point-then-do-something/m-p/6705554#M126216</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;In addition to what Kent said, you may also wish to use the trans function ....&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;[No, Doug didn't miss my mention of translating between coordinate systems -- he replied before (or while) I edited that topic into my reply.]&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 15:59:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-insertion-point-then-do-something/m-p/6705554#M126216</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2016-11-23T15:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: Get insertion point, then do something...</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-insertion-point-then-do-something/m-p/6705574#M126217</link>
      <description>&lt;P&gt;The point of the initial (if ... conditions should be to cover at least most basic cases that causing an error... or unwanted behavior...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- if not object found... (different layer..)&lt;/P&gt;
&lt;P&gt;- if unwanted objects found&lt;/P&gt;
&lt;P&gt;-&amp;nbsp;in unwanted space (layout)...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe like this.. to start&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  (if (and (setq ss (ssget "_A" '((0 . "INSERT")  			; block
                                  (2 . "border")			; layer
                                  (cons 410 (getvar 'CTAB)))))		; current layout (model)
           (setq bdr (cdr (assoc 10 (entget (ssname ss 0)))))
           )
    (if (equal bdr '(0 0 0) 1e-4)
...&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Nov 2016 16:05:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-insertion-point-then-do-something/m-p/6705574#M126217</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2016-11-23T16:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: Get insertion point, then do something...</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-insertion-point-then-do-something/m-p/6706106#M126218</link>
      <description>&lt;P&gt;Thanks for the help everyone. I got what I needed. Also I appreciate the input for the adding a test to see if the border is actually in the drawing and whether or not it is layout. I tend to forget about adding functions like that. Most of the time all of the drawings I deal with are in Model Space and the coordinate system is typically default. Thanks again and happy thanksgiving.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 19:04:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-insertion-point-then-do-something/m-p/6706106#M126218</guid>
      <dc:creator>CSM_MAI</dc:creator>
      <dc:date>2016-11-23T19:04:36Z</dc:date>
    </item>
  </channel>
</rss>

