<?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: Center of the screen. in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188077#M80917</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5830512"&gt;@adaptacad&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;....&amp;nbsp;&lt;FONT&gt;Now how to find the nearest block point?&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;Something like this [minimally tested]:&lt;/P&gt;
&lt;PRE&gt;(defun C:&lt;FONT color="#000000"&gt;&lt;STRONG&gt;IBCVC&lt;/STRONG&gt;&lt;/FONT&gt; ; = &lt;FONT color="#000000"&gt;&lt;STRONG&gt;I&lt;/STRONG&gt;&lt;/FONT&gt;nsert at &lt;FONT color="#000000"&gt;&lt;STRONG&gt;B&lt;/STRONG&gt;&lt;/FONT&gt;lock &lt;FONT color="#000000"&gt;&lt;STRONG&gt;C&lt;/STRONG&gt;&lt;/FONT&gt;losest to &lt;FONT color="#000000"&gt;&lt;STRONG&gt;V&lt;/STRONG&gt;&lt;/FONT&gt;iew &lt;FONT color="#000000"&gt;&lt;STRONG&gt;C&lt;/STRONG&gt;&lt;/FONT&gt;enter
  (/ ss dst vc n blk bdst theOne)
  (if (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 410 (getvar 'ctab)))))
    (progn ; then
      (setq
        dst (distance (getvar 'extmin) (getvar 'extmax))
          ; virtually guaranteed farther than some Block will be from ViewCenter
        vc (getvar 'viewctr)
      ); setq
      (repeat (setq n (sslength ss))
        (setq blk (ssname ss (setq n (1- n))))
        (if (&amp;lt; (setq bdst (distance (cdr (assoc 10 (entget blk))) vc)) dst); closer than any other so far
          (setq theOne blk dst bdst); then -- mark as closest; its distance for basis of next comparison
        ); if
      ); repeat
      (command "_.insert" "Blk_Insert" "_none" (cdr (assoc 10 (entget theOne))) 1 1 0)
    ); progn
  ); if
  (princ)
); defun&lt;/PRE&gt;</description>
    <pubDate>Fri, 06 Dec 2019 20:21:52 GMT</pubDate>
    <dc:creator>Kent1Cooper</dc:creator>
    <dc:date>2019-12-06T20:21:52Z</dc:date>
    <item>
      <title>Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9187676#M80913</link>
      <description>&lt;P&gt;&lt;SPAN style="box-sizing: border-box; font-size: 16px;"&gt;Is there a way to insert a block at the same rotation as another block closer to the center of my screen?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="box-sizing: border-box; font-size: 16px;"&gt;-&amp;gt; I zoomed, I called the command, and the new block will be inserted in the block closest to my zoom.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="box-sizing: border-box; font-size: 16px;"&gt;I got a .dwg with the example.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2019 17:08:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9187676#M80913</guid>
      <dc:creator>adaptacad</dc:creator>
      <dc:date>2019-12-06T17:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9187844#M80914</link>
      <description>&lt;P&gt;The &lt;FONT color="#000000"&gt;&lt;STRONG&gt;VIEWCTR&lt;/STRONG&gt;&lt;/FONT&gt; System Variable holds the [as you might expect] &lt;FONT color="#000000"&gt;&lt;STRONG&gt;VIEW&lt;/STRONG&gt; &lt;STRONG&gt;C&lt;/STRONG&gt;&lt;/FONT&gt;en&lt;FONT color="#000000"&gt;&lt;STRONG&gt;T&lt;/STRONG&gt;&lt;/FONT&gt;e&lt;FONT color="#000000"&gt;&lt;STRONG&gt;R&lt;/STRONG&gt;&lt;/FONT&gt;, i.e. the middle of the current viewing area.&amp;nbsp; You can use that as an insertion point for a Block with:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; (getvar 'viewctr)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;when asked for the insertion point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But to find the already-inserted Block that's closest to that location would probably require a routine to find &lt;EM&gt;all&lt;/EM&gt;&amp;nbsp; Blocks in the current space, step through them all looking at the distance from there to each one's insertion point, and use the one for which that distance is shortest.&amp;nbsp; It's probably doable in an AutoLisp routine, if that sounds like what you need to do.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2019 18:33:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9187844#M80914</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2019-12-06T18:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9187852#M80915</link>
      <description>&lt;P&gt;Command INSERT&lt;/P&gt;&lt;P&gt;Enable option: Insertion point -&amp;gt; specify on screen&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2019 18:30:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9187852#M80915</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2019-12-06T18:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188005#M80916</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(command "Insert" "Blk_Insert" (getvar 'viewctr) 1 1 0)&lt;/PRE&gt;&lt;P&gt;&lt;FONT&gt;It Works very well!&lt;BR /&gt;Now how to find the nearest block point?&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2019 19:41:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188005#M80916</guid>
      <dc:creator>adaptacad</dc:creator>
      <dc:date>2019-12-06T19:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188077#M80917</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5830512"&gt;@adaptacad&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;....&amp;nbsp;&lt;FONT&gt;Now how to find the nearest block point?&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;Something like this [minimally tested]:&lt;/P&gt;
&lt;PRE&gt;(defun C:&lt;FONT color="#000000"&gt;&lt;STRONG&gt;IBCVC&lt;/STRONG&gt;&lt;/FONT&gt; ; = &lt;FONT color="#000000"&gt;&lt;STRONG&gt;I&lt;/STRONG&gt;&lt;/FONT&gt;nsert at &lt;FONT color="#000000"&gt;&lt;STRONG&gt;B&lt;/STRONG&gt;&lt;/FONT&gt;lock &lt;FONT color="#000000"&gt;&lt;STRONG&gt;C&lt;/STRONG&gt;&lt;/FONT&gt;losest to &lt;FONT color="#000000"&gt;&lt;STRONG&gt;V&lt;/STRONG&gt;&lt;/FONT&gt;iew &lt;FONT color="#000000"&gt;&lt;STRONG&gt;C&lt;/STRONG&gt;&lt;/FONT&gt;enter
  (/ ss dst vc n blk bdst theOne)
  (if (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 410 (getvar 'ctab)))))
    (progn ; then
      (setq
        dst (distance (getvar 'extmin) (getvar 'extmax))
          ; virtually guaranteed farther than some Block will be from ViewCenter
        vc (getvar 'viewctr)
      ); setq
      (repeat (setq n (sslength ss))
        (setq blk (ssname ss (setq n (1- n))))
        (if (&amp;lt; (setq bdst (distance (cdr (assoc 10 (entget blk))) vc)) dst); closer than any other so far
          (setq theOne blk dst bdst); then -- mark as closest; its distance for basis of next comparison
        ); if
      ); repeat
      (command "_.insert" "Blk_Insert" "_none" (cdr (assoc 10 (entget theOne))) 1 1 0)
    ); progn
  ); if
  (princ)
); defun&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Dec 2019 20:21:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188077#M80917</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2019-12-06T20:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188092#M80918</link>
      <description>&lt;PRE&gt;(defun c:ntb ( / cp dx dy p1 p2 ss i mindist di mp tp *error*)
(defun *error* () (princ))
(setvar "cmdecho" 0)
(setq 
    cp (getvar "VIEWCTR")
    dy (* 0.5 (getvar "VIEWSIZE"))
    dx (* 0.5 (* vy (/ (car (getvar "SCREENSIZE"))(cadr (getvar"SCREENSIZE")))))
    p1 (mapcar '- cp (list dx dy))
    p2 (mapcar '+ cp (list dx dy))
    ss (ssget "w" p1 p2 '((0 . "INSERT")))    
    i 0
    mindist 1e8
)
    (if ss
        (progn
            (command "Insert" "Blk_Insert" cp 1 1 0)
            (while (&amp;lt; i (sslength ss))
                (setq di (distance cp (setq tp(cdr (assoc 10 (entget (ssname ss i)))))))
                (if (&amp;lt; di mindist)
                    (setq mp tp mindist di)
                )
             (setq i (+ i 1))
            )
            (command "move" (entlast) "" cp mp)
        )
        (princ "\nThere is no block in visible area!")
    )
(setvar "cmdecho" 1)
(princ)
)&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Dec 2019 21:02:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188092#M80918</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2019-12-06T21:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188349#M80919</link>
      <description>&lt;P&gt;&lt;FONT&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp; Thank you very much!! it Works very well!&lt;BR /&gt;How do I rotate at the same angle as "Block_Mult"?&lt;BR /&gt;How not to insert in the base of "Block_Mult" but in the place of the example?&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2019 00:48:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188349#M80919</guid>
      <dc:creator>adaptacad</dc:creator>
      <dc:date>2019-12-07T00:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188350#M80920</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;&lt;FONT&gt;It does not work !!&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2019 00:48:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188350#M80920</guid>
      <dc:creator>adaptacad</dc:creator>
      <dc:date>2019-12-07T00:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188499#M80921</link>
      <description>&lt;PRE&gt;(defun c:ntb ( / cp dx dy p1 p2 ss i mindist di mp tp *error*)
(defun *error* () (princ))
(setvar "cmdecho" 0)
(setq 
    cp (getvar "VIEWCTR")
    dy (* 0.5 (getvar "VIEWSIZE"))
    dx (* 0.5 (* dy (/ (car (getvar "SCREENSIZE"))(cadr (getvar"SCREENSIZE")))))
    p1 (mapcar '- cp (list dx dy))
    p2 (mapcar '+ cp (list dx dy))
    ss (ssget "w" p1 p2 '((0 . "INSERT")))    
    i 0
    mindist 1e8
)
    (if ss
        (progn
            (command "Insert" "Blk_Insert" cp 1 1 0)
            (while (&amp;lt; i (sslength ss))
                (setq di (distance cp (setq tp(cdr (assoc 10 (entget (ssname ss i)))))))
                (if (&amp;lt; di mindist)
                    (setq mp tp mindist di)
                )
             (setq i (+ i 1))
            )
            (command "move" (entlast) "" cp mp)
        )
        (princ "\nThere is no block in visible area!")
    )
(setvar "cmdecho" 1)
(princ)
)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;(defun c:ntb2 ( / cp dx dy p1 p2 ss i mindist di mp tp *error*)&lt;BR /&gt;(defun *error* () (princ))&lt;BR /&gt;(setvar "cmdecho" 0)&lt;BR /&gt;(setq &lt;BR /&gt;cp (getvar "VIEWCTR")&lt;BR /&gt;ss (ssget "x" '((0 . "INSERT"))) &lt;BR /&gt;i 0&lt;BR /&gt;mindist 1e8&lt;BR /&gt;)&lt;BR /&gt;(if ss&lt;BR /&gt;(progn&lt;BR /&gt;(while (&amp;lt; i (sslength ss))&lt;BR /&gt;(setq di (distance cp (setq tp(cdr (assoc 10 (entget (ssname ss i)))))))&lt;BR /&gt;(if (&amp;lt; di mindist)&lt;BR /&gt;(setq mp tp mindist di)&lt;BR /&gt;)&lt;BR /&gt;(setq i (+ i 1))&lt;BR /&gt;)&lt;BR /&gt;(command "Insert" "Blk_Insert" mp 1 1 0)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;(setvar "cmdecho" 1)&lt;BR /&gt;(princ)&lt;BR /&gt;)&lt;/PRE&gt;</description>
      <pubDate>Sat, 07 Dec 2019 07:00:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188499#M80921</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2019-12-07T07:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188683#M80922</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5830512"&gt;@adaptacad&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;FONT&gt;….&lt;BR /&gt;How do I rotate at the same angle as "Block_Mult"?&lt;BR /&gt;How not to insert in the base of "Block_Mult" but in the place of the example?&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[No AutoCAD here, but I'll give it a shot....]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1.&amp;nbsp; You should be able to replace the &lt;FONT color="#000000"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/FONT&gt; at the end of the Insert command with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (&lt;FONT color="#000000"&gt;cdr (assoc 50 (entget theOne)))&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; I'm not sure what you mean by "in the place of the example" -- what would determine where that place is, if it's not the insertion point of the Block closest to the center of the current view?&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2019 12:51:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188683#M80922</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2019-12-07T12:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188871#M80923</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;&lt;FONT&gt;It Works very well. Thank you!!!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp;&lt;FONT&gt;This point with the same rotation as the block.&lt;/FONT&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="img.PNG" style="width: 945px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/705492i0834275B9DDBF984/image-size/large?v=v2&amp;amp;px=999" role="button" title="img.PNG" alt="img.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2019 16:36:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188871#M80923</guid>
      <dc:creator>adaptacad</dc:creator>
      <dc:date>2019-12-07T16:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188932#M80924</link>
      <description>&lt;P&gt;(defun c:ntb ( / cp dx dy p1 p2 ss i mindist di mp tp e *error*)&lt;BR /&gt;(defun *error* () (princ))&lt;BR /&gt;(defun rad_to_deg (rad)(* 180.0 (/ rad pi)))&lt;BR /&gt;(setvar "cmdecho" 0)&lt;BR /&gt;(setq&lt;BR /&gt;cp (getvar "VIEWCTR")&lt;BR /&gt;dy (* 0.5 (getvar "VIEWSIZE"))&lt;BR /&gt;dx (* 0.5 (* dy (/ (car (getvar "SCREENSIZE"))(cadr (getvar"SCREENSIZE")))))&lt;BR /&gt;p1 (mapcar '- cp (list dx dy))&lt;BR /&gt;p2 (mapcar '+ cp (list dx dy))&lt;BR /&gt;ss (ssget "w" p1 p2 '((0 . "INSERT")))&lt;BR /&gt;i 0&lt;BR /&gt;mindist 1e8&lt;BR /&gt;)&lt;BR /&gt;(if ss&lt;BR /&gt;(progn&lt;BR /&gt;&lt;BR /&gt;(while (&amp;lt; i (sslength ss))&lt;BR /&gt;(setq di (distance cp (setq tp(cdr (assoc 10 (entget (ssname ss i)))))))&lt;BR /&gt;(if (&amp;lt; di mindist)&lt;BR /&gt;(setq mp tp mindist di e (ssname ss i))&lt;BR /&gt;)&lt;BR /&gt;(setq i (+ i 1))&lt;BR /&gt;)&lt;BR /&gt;(command "Insert" "Blk_Insert" mp 1 1 0)&lt;BR /&gt;(command "rotate" (entlast) "" mp (rad_to_deg(cdr (assoc 50 (entget e)))))&lt;BR /&gt;)&lt;BR /&gt;(princ "\nThere is no block in visible area!")&lt;BR /&gt;)&lt;BR /&gt;(setvar "cmdecho" 1)&lt;BR /&gt;(princ)&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2019 17:56:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188932#M80924</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2019-12-07T17:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188939#M80925</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;(defun c:ntb ( / cp dx dy p1 p2 ss i mindist di mp tp e *error*)&lt;BR /&gt;(defun *error* () (princ))&lt;BR /&gt;(defun rad_to_deg (rad)(* 180.0 (/ rad pi)))&lt;BR /&gt;(setvar "cmdecho" 0)&lt;BR /&gt;(setq&lt;BR /&gt;cp (getvar "VIEWCTR")&lt;BR /&gt;dy (* 0.5 (getvar "VIEWSIZE"))&lt;BR /&gt;dx (* 0.5 (* dy (/ (car (getvar "SCREENSIZE"))(cadr (getvar"SCREENSIZE")))))&lt;BR /&gt;p1 (mapcar '- cp (list dx dy))&lt;BR /&gt;p2 (mapcar '+ cp (list dx dy))&lt;BR /&gt;ss (ssget "w" p1 p2 '((0 . "INSERT")))&lt;BR /&gt;i 0&lt;BR /&gt;mindist 1e8&lt;BR /&gt;)&lt;BR /&gt;(if ss&lt;BR /&gt;(progn&lt;BR /&gt;&lt;BR /&gt;(while (&amp;lt; i (sslength ss))&lt;BR /&gt;(setq di (distance cp (setq tp(cdr (assoc 10 (entget (ssname ss i)))))))&lt;BR /&gt;(if (&amp;lt; di mindist)&lt;BR /&gt;(setq mp tp mindist di e (ssname ss i))&lt;BR /&gt;)&lt;BR /&gt;(setq i (+ i 1))&lt;BR /&gt;)&lt;BR /&gt;(command "Insert" "Blk_Insert" mp 1 1 0)&lt;BR /&gt;(command "rotate" (entlast) "" mp (rad_to_deg(cdr (assoc 50 (entget e)))))&lt;BR /&gt;)&lt;BR /&gt;(princ "\nThere is no block in visible area!")&lt;BR /&gt;)&lt;BR /&gt;(setvar "cmdecho" 1)&lt;BR /&gt;(princ)&lt;BR /&gt;)&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp; Thank you. Rotation works great, but how to insert at this point?&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="img.PNG" style="width: 945px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/705509iFC6FC6B51B6AE456/image-size/large?v=v2&amp;amp;px=999" role="button" title="img.PNG" alt="img.PNG" /&gt;&lt;/span&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2019 18:01:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188939#M80925</guid>
      <dc:creator>adaptacad</dc:creator>
      <dc:date>2019-12-07T18:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188956#M80926</link>
      <description>&lt;P&gt;Sorry but I get lost.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="slope4.jpg" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/705511i46579CD210D61D2D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="slope4.jpg" alt="slope4.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I've got this. Problem is probably in some system variables . At first I had problem with rotation. In my case it is base angle direction is East and i use cc direction. I guess you may have something different.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In both codes we only work with insertion points, so I don't see a reason that they don't join.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2019 18:23:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9188956#M80926</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2019-12-07T18:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9189235#M80927</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5830512"&gt;@adaptacad&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp;&lt;FONT&gt;This point with the same rotation as the block.&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is "this point" &lt;EM&gt;not&lt;/EM&gt;&amp;nbsp; the insertion point of that Block?&amp;nbsp; The blue square down lower looks like a grip, which presumably would be the insertion point.&amp;nbsp; If that's true, I suggest you redefine the Block to make the point you want at a specific location its insertion point.&amp;nbsp; Otherwise, the routine will need to do some calculation&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #666666; cursor: text; font-family: inherit; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.7142; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;, affected by the rotation&lt;/SPAN&gt;, of the insertion point to use in order to land "this point" at the insertion point of the closest-to-view-center Block.&amp;nbsp; And you will need to build the distance from this Block's insertion point to "this point" into that calculation.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Dec 2019 03:25:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9189235#M80927</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2019-12-08T03:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9190917#M80928</link>
      <description>&lt;P&gt;&lt;FONT&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp; It's working very well, I would just like to move the block to that point.&lt;BR /&gt;understand?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Img.PNG" style="width: 565px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/705920i1C10794574E04D99/image-size/large?v=v2&amp;amp;px=999" role="button" title="Img.PNG" alt="Img.PNG" /&gt;&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2019 13:17:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9190917#M80928</guid>
      <dc:creator>adaptacad</dc:creator>
      <dc:date>2019-12-09T13:17:46Z</dc:date>
    </item>
    <item>
      <title>Re: Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9190924#M80929</link>
      <description>&lt;P&gt;&lt;FONT&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp; I can't change the base of the block! &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2019 13:20:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9190924#M80929</guid>
      <dc:creator>adaptacad</dc:creator>
      <dc:date>2019-12-09T13:20:11Z</dc:date>
    </item>
    <item>
      <title>Re: Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9190943#M80930</link>
      <description>&lt;P&gt;If the recently-posted images show the Block at zero rotation, and if you want the location at the freehand arrowhead point to be what's at the insertion point of the closest-to-view-center Block, try this variant [untested]:&lt;/P&gt;
&lt;PRE&gt;(defun C:IBCVC ; = Insert at Block Closest to View Center
  (/ ss dst vc n blk bdst theOne)
  (if (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 410 (getvar 'ctab)))))
    (progn ; then
      (setq
        dst (distance (getvar 'extmin) (getvar 'extmax))
          ; virtually guaranteed farther than some Block will be from ViewCenter
        vc (getvar 'viewctr)
      ); setq
      (repeat (setq n (sslength ss))
        (setq blk (ssname ss (setq n (1- n))))
        (if (&amp;lt; (setq bdst (distance (cdr (assoc 10 (entget blk))) vc)) dst); closer than any other so far
          (setq theOne blk dst bdst); then -- mark as closest; its distance as next comparison
        ); if
      ); repeat
      &lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;(setq rot (cdr (assoc 50 (entget theOne))))&lt;/FONT&gt;&lt;/STRONG&gt;
      (command "_.insert" "Blk_Insert" "_none"
        &lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;(polar (cdr (assoc 10 (entget theOne))) (- rot (/ pi 2)) 2.5)&lt;/FONT&gt;&lt;/STRONG&gt;
        1 1 &lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;rot&lt;/FONT&gt;&lt;/STRONG&gt;
      ); command
    ); progn
  ); if
  (princ)
); defun&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Dec 2019 13:26:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9190943#M80930</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2019-12-09T13:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9190954#M80931</link>
      <description>&lt;P&gt;Will write it later.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2019 13:33:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9190954#M80931</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2019-12-09T13:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: Center of the screen.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9191257#M80932</link>
      <description>&lt;PRE&gt;(defun c:ntb ( / cp dx dy p1 p2 ss i mindist di mp tp e *error*) 
(defun *error* () (princ))
(defun rad_to_deg (rad)(* 180.0 (/ rad pi)))
(setvar "cmdecho" 0)
(setq 
    cp (getvar "VIEWCTR")
    dy (* 0.5 (getvar "VIEWSIZE"))
    dx (* 0.5 (* dy (/ (car (getvar "SCREENSIZE"))(cadr (getvar"SCREENSIZE")))))
    p1 (mapcar '- cp (list dx dy))
    p2 (mapcar '+ cp (list dx dy))
    ss (ssget "w" p1 p2 '((0 . "INSERT")))    
    i 0
    mindist 1e8
)
    (if ss
        (progn
           
            (while (&amp;lt; i (sslength ss))
                (setq di (distance cp (setq tp(cdr (assoc 10 (entget (ssname ss i)))))))
                (if (&amp;lt; di mindist)
                    (setq mp tp mindist di e  (ssname ss i))
                )
             (setq i (+ i 1))
            )
            (command "Insert" "Blk_Insert" mp 1 1 0)
            (command "rotate" (entlast) "" mp (rad_to_deg(cdr (assoc 50 (entget e)))))
            (command "move" (entlast) "" mp (polar mp (+ (cdr (assoc 50 (entget e))) (* 0.5 pi)) 2.5))
        )
        (princ "\nThere is no block in visible area!")
    )
(setvar "cmdecho" 1)
(princ)
)&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="slope3.jpg" style="width: 839px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/705978iEA5607F8194BC113/image-size/large?v=v2&amp;amp;px=999" role="button" title="slope3.jpg" alt="slope3.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2019 15:28:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/center-of-the-screen/m-p/9191257#M80932</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2019-12-09T15:28:44Z</dc:date>
    </item>
  </channel>
</rss>

