<?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: Error if selection set is out of view - 0xC0000005 (Access Violation) in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-if-selection-set-is-out-of-view-0xc0000005-access/m-p/10032379#M65108</link>
    <description>&lt;LI-CODE lang="markup"&gt;(setq ss (nentsel pss)) ;this didn't work for 0xC0000005 error&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This can not work since nentsel is not a function that creates selection set, and variable pss is also not defined.&lt;/P&gt;&lt;P&gt;In condion statement you have (&amp;gt; (sslength ss) 1)&lt;/P&gt;&lt;P&gt;&lt;A href="https://documentation.help/AutoLISP-Functions/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-699d.htm" target="_blank" rel="noopener"&gt;Read here what nentsel is used for.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Jan 2021 15:42:42 GMT</pubDate>
    <dc:creator>hak_vz</dc:creator>
    <dc:date>2021-01-26T15:42:42Z</dc:date>
    <item>
      <title>Error if selection set is out of view - 0xC0000005 (Access Violation)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-if-selection-set-is-out-of-view-0xc0000005-access/m-p/10032316#M65107</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I am working on a lisp to create "wire jumps" on selected polylines, where at every intersection it breaks the vertical line to prevent an overlap. I have it working, for the most part. I'm on AutoCAD 2019.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If my selection set (all selected polylines) is completely in view within model space and the code is run: no errors, all is great in the world.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If my selection set is partially out of view (zoomed in, part of a polyline with an intersect or a turning vertex not displayed in view), an error will occur. If I step through the code in VLISP this error comes up:&lt;BR /&gt;; error: Exception occurred: 0xC0000005 (Access Violation)&lt;BR /&gt;; warning: unwind skipped on exception&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just can't figure it out. It's strange that it only occurs while part of the selection is out of view. I could write in a viewport change at each run but that is rather inefficient.&lt;BR /&gt;Any help or direction would be appreciated-&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;;==================================================================================================================================================
;make wire jumps for crossing lines
(defun c:WJ-[wirejump] ( / *error* errmsg _ActiveDoc _StartUndo _EndUndo doc ss gap x _pts a plst ent nobj pint rlst mp1 mp2)
(vl-load-com)
(setq doc  (vla-get-ActiveDocument (vlax-get-acad-object)))
;error &amp;amp; undo handler
(defun *error* ( errmsg )
  (_EndUndo (_ActiveDoc))
  (if (not (wcmatch (strcase errmsg t) "*break,*cancel*,*exit*"))
  (princ (strcat "\n** Error: " errmsg " **")))
  (princ))
  (defun _ActiveDoc nil
      (eval (list 'defun '_ActiveDoc 'nil (vla-get-activedocument (vlax-get-acad-object))))
      (_ActiveDoc))
  (defun _StartUndo ( doc ) (_EndUndo doc)
      (vla-StartUndoMark doc))
  (defun _EndUndo ( doc )
      (if (= 8 (logand 8 (getvar 'UNDOCTL)))
        (vla-EndUndoMark doc)))
(_StartUndo (_ActiveDoc))
;variables
(setq gap 0.5)
(setq
    oldecho (getvar "CMDECHO")
    oldblip (getvar "BLIPMODE")
    oldosm (getvar "OSMODE"))
(setvar "CMDECHO" 0)
(setvar "BLIPMODE" 0)
(setvar "OSMODE" 0)
;jump, jump, jump, jump
(defun _pts (e / pint)
  (setq pint (mapcar 'cdr (vl-remove-if '(lambda (x) (/= 10 (car x))) (entget e))))
  (mapcar '(lambda (a plst) (list a plst)) pint (cdr pint)))
(cond	((and (setq ss (ssget ":L" '((0 . "lwpolyline")))) ;ss = selection set
	      ;(setq ss (nentsel pss)) ;this didn't work for 0xC0000005 error
            (&amp;gt; (sslength ss) 1))
       (repeat (setq nobj (sslength ss)) ;nobj = number of objects in selection
               (setq ent (ssname ss (setq nobj (1- nobj)))) ;ent = individual entity name
               (setq rlst (cons (_pts ent) rlst))) ;rlst = growing list of points
       (setq rlst (apply 'append rlst))
       (while	(setq a (car rlst)) ;returns the first element of list
              (setq rlst (cdr rlst)) ;returns list containing all but the first element of the specified list
              (foreach x rlst
                (if (setq pint (inters (car a) (cadr a) (car x) (cadr x))) ;pint = point of intersect
                    (setq plst (cons pint plst))))) ;plst = full list of intersects
       (foreach pint plst
           (if (and (setq mp1 (ssget "c" (list (car pint) ( - (cadr pint) gap)) (list (car pint) ( - (cadr pint) gap)) (list (cons 0 "lwpolyline"))))
                    (setq mp2 (ssget "c" (list (car pint) ( + (cadr pint) gap)) (list (car pint) ( + (cadr pint) gap)) (list (cons 0 "lwpolyline")))))
            (command "_.break" ; we are failing here ; error: Exception occurred: 0xC0000005 (Access Violation); warning: unwind skipped on exception
               (mapcar '+ (list (car pint) ( - (cadr pint) gap) (caddr pint)) '(0 0))
               (mapcar '+ (list (car pint) ( + (cadr pint) gap) (caddr pint)) '(0 0)))
           ))))
;end it
(setvar "CMDECHO" oldecho)
(setvar "BLIPMODE" oldblip)
(setvar "OSMODE" oldosm)
(_EndUndo (_ActiveDoc))
(princ "\n-jumps made-")(princ))
;==================================================================================================================================================&lt;/LI-CODE&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 15:21:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-if-selection-set-is-out-of-view-0xc0000005-access/m-p/10032316#M65107</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-01-26T15:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: Error if selection set is out of view - 0xC0000005 (Access Violation)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-if-selection-set-is-out-of-view-0xc0000005-access/m-p/10032379#M65108</link>
      <description>&lt;LI-CODE lang="markup"&gt;(setq ss (nentsel pss)) ;this didn't work for 0xC0000005 error&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This can not work since nentsel is not a function that creates selection set, and variable pss is also not defined.&lt;/P&gt;&lt;P&gt;In condion statement you have (&amp;gt; (sslength ss) 1)&lt;/P&gt;&lt;P&gt;&lt;A href="https://documentation.help/AutoLISP-Functions/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-699d.htm" target="_blank" rel="noopener"&gt;Read here what nentsel is used for.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 15:42:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-if-selection-set-is-out-of-view-0xc0000005-access/m-p/10032379#M65108</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2021-01-26T15:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: Error if selection set is out of view - 0xC0000005 (Access Violation)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-if-selection-set-is-out-of-view-0xc0000005-access/m-p/10032414#M65109</link>
      <description>&lt;P&gt;That's a known issue - read a caution&amp;nbsp;&lt;A href="http://www.lee-mac.com/ssget.html" target="_self"&gt;HERE&lt;/A&gt;&amp;nbsp; on Lee's page. Edit: I was hoping that the same note I'll find&amp;nbsp;&lt;A href="https://help.autodesk.com/view/ACD/2021/ENU/?guid=GUID-0F37CC5E-1559-4011-B8CF-A3BA0973B2C3" target="_self"&gt;HERE&lt;/A&gt;&amp;nbsp;, unfortunately not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So either ZOOM Extents prior to (ssget "c") if that's work for you or if the drawing is too large, zoom to a smaller area to make sure it's on-screen.&amp;nbsp;Then you can ZOOM previous.&lt;/P&gt;
&lt;P&gt;Yes, it slows things down. Or avoid using (ssget "c/cp/w/wp")... somehow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="gtx-trans" style="position: absolute; left: 376px; top: 117.085px;"&gt;
&lt;DIV class="gtx-trans-icon"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 26 Jan 2021 16:00:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-if-selection-set-is-out-of-view-0xc0000005-access/m-p/10032414#M65109</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2021-01-26T16:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: Error if selection set is out of view - 0xC0000005 (Access Violation)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-if-selection-set-is-out-of-view-0xc0000005-access/m-p/10032552#M65110</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; Pardon that line, I should have removed it before posting (it has ; demarked). I found on another forum they used an nentsel to solve the&amp;nbsp;0xC0000005 error, before I tracked mine down further to being my view range. Experimental place holder to remind myself I tried it.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(&amp;gt; (sslength ss) 1) is to verify more than one PLine is selected.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1779365"&gt;@ВeekeeCZ&lt;/a&gt;&amp;nbsp;well darn, there it is. Not the news I was hoping for but manageable to work around it. I originally used a vlax-invoke to get the intersects and it functioned, but it kept forgetting the remaining intersetion points half way through on larger selection sets. Maybe due to it breaking the original selected lines. The ssget never had issues with objects out of view on that one:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(cond
    ((and (setq ss (ssget ":L" '((0 . "lwpolyline"))))
          (&amp;gt; (sslength ss) 1)
          (setq ss (mapcar 'vlax-ename-&amp;gt;vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))
          (setq nextss ss))
   (foreach thispnt	ss
       (if (setq pts (apply 'append
			    (mapcar '(lambda (x) (vlax-invoke thispnt 'intersectwith x acextendnone))
				    (setq nextss (cdr nextss))
				    )))
   (while	(caddr pts)
	   (cond ((and (setq XYpnt (list (car pts) (cadr pts)))
                 (setq Dpnt (vlax-curve-getdistatpoint thispnt XYpnt))
                 (setq p1a (vlax-curve-getpointatdist thispnt (+ Dpnt 0)))
                 (setq p2a (vlax-curve-getpointatdist thispnt (- Dpnt 0)))
                 (setq p1 (list (car p1a) ( - (cadr p1a) gap) (caddr p1a)))
                 (setq p2 (list (car p2a) ( + (cadr p2a) gap) (caddr p2a)))
                 )
            (command "_.break" (mapcar '+ p1 '(0 0)) (mapcar '+ p2 '(0 0)))
            ))
	        (setq pts (cdddr pts)))))
    ))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Nonethelss, seems a ZOOM-Object ZOOM-Previous might be easiest. I'll move forward with that. Thank you!-&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 16:35:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-if-selection-set-is-out-of-view-0xc0000005-access/m-p/10032552#M65110</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-01-26T16:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: Error if selection set is out of view - 0xC0000005 (Access Violation)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-if-selection-set-is-out-of-view-0xc0000005-access/m-p/10032590#M65111</link>
      <description>&lt;P&gt;Interestingly enough, just tried it on 2021 and it worked without issues... guess that bug is finally down for the count.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 16:50:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-if-selection-set-is-out-of-view-0xc0000005-access/m-p/10032590#M65111</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-01-26T16:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Error if selection set is out of view - 0xC0000005 (Access Violation)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-if-selection-set-is-out-of-view-0xc0000005-access/m-p/10032617#M65112</link>
      <description>&lt;P&gt;It could have something to do with&amp;nbsp;&lt;A href="https://help.autodesk.com/view/ACD/2021/ENU/?guid=GUID-2609B540-EF39-45B5-8682-FEC7F16B77DE" target="_self"&gt;THIS&lt;/A&gt;&amp;nbsp; feature which was added to some update of 2018... with some change in 2019... something like that. Not sure though.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 16:57:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-if-selection-set-is-out-of-view-0xc0000005-access/m-p/10032617#M65112</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2021-01-26T16:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: Error if selection set is out of view - 0xC0000005 (Access Violation)</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-if-selection-set-is-out-of-view-0xc0000005-access/m-p/10032731#M65113</link>
      <description>&lt;P&gt;That was it!! SELECTIONOFFSCREEN&amp;gt;2 did the trick. Outstanding, thank you-&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 17:41:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-if-selection-set-is-out-of-view-0xc0000005-access/m-p/10032731#M65113</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-01-26T17:41:04Z</dc:date>
    </item>
  </channel>
</rss>

