<?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 Model Space and Paper Space in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670536#M54401</link>
    <description>&lt;P&gt;If an ActiveX function requires obtaining a pointer to model space or paper space to execute. In this case, the obtaining a pointer:&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier" color="#333399"&gt;(vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)))&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;will only execute in &lt;STRONG&gt;model space&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;And the obtaining a pointer:&lt;BR /&gt;&lt;FONT color="#333399"&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;(vla-get-PaperSpace (vla-get-ActiveDocument (vlax-get-acad-object)))&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;will be executed &lt;STRONG&gt;only in layout&lt;/STRONG&gt;.&lt;BR /&gt;Is it possible to remove this restriction so that the function that requires obtaining a pointer is &lt;SPAN&gt;executed&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;both in model space and in paper space&lt;/STRONG&gt;&lt;/U&gt;?&lt;/P&gt;</description>
    <pubDate>Wed, 06 Oct 2021 14:18:02 GMT</pubDate>
    <dc:creator>Browning_Zed</dc:creator>
    <dc:date>2021-10-06T14:18:02Z</dc:date>
    <item>
      <title>Model Space and Paper Space</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670536#M54401</link>
      <description>&lt;P&gt;If an ActiveX function requires obtaining a pointer to model space or paper space to execute. In this case, the obtaining a pointer:&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier" color="#333399"&gt;(vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)))&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;will only execute in &lt;STRONG&gt;model space&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;And the obtaining a pointer:&lt;BR /&gt;&lt;FONT color="#333399"&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;(vla-get-PaperSpace (vla-get-ActiveDocument (vlax-get-acad-object)))&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;will be executed &lt;STRONG&gt;only in layout&lt;/STRONG&gt;.&lt;BR /&gt;Is it possible to remove this restriction so that the function that requires obtaining a pointer is &lt;SPAN&gt;executed&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;both in model space and in paper space&lt;/STRONG&gt;&lt;/U&gt;?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 14:18:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670536#M54401</guid>
      <dc:creator>Browning_Zed</dc:creator>
      <dc:date>2021-10-06T14:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: Model Space and Paper Space</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670570#M54402</link>
      <description>&lt;LI-CODE lang="general"&gt;(vla-get-ActiveSpace (vla-get-ActiveDocument (vlax-get-acad-object)))&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 06 Oct 2021 14:27:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670570#M54402</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2021-10-06T14:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Model Space and Paper Space</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670696#M54403</link>
      <description>&lt;P&gt;This doesn't work in my case.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 15:07:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670696#M54403</guid>
      <dc:creator>Browning_Zed</dc:creator>
      <dc:date>2021-10-06T15:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Model Space and Paper Space</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670738#M54404</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(setq doc (vla-get-ActiveDocument (vlax-get-acad-object))
	space
	 (if (= (getvar 'cvport) 1)
	   (vla-get-PaperSpace doc)
	   (vla-get-ModelSpace doc)
	 )
  )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 15:23:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670738#M54404</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2021-10-06T15:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: Model Space and Paper Space</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670739#M54405</link>
      <description>&lt;P&gt;Or you can use&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(vla-get-ActiveLayout (vla-get-activedocument(vlax-get-acad-object)))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Command: (vla-get-Name(vla-get-ActiveLayout (vla-get-activedocument(vlax-get-acad-object))))
"Layout1"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Command: (vla-get-Name(vla-get-ActiveLayout (vla-get-activedocument(vlax-get-acad-object))))
"Model"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or you can use code from &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt; depending what you want.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 15:25:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670739#M54405</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2021-10-06T15:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: Model Space and Paper Space</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670794#M54406</link>
      <description>&lt;P&gt;Unfortunately, I have not been able to achieve the desired result. It doesn't work for me. I'll give code. It converts an LW Polyline (as well as other entities) to a multiline.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(Conv2Mline ( / )
   (vla-AddMline
     (vla-get-ModelSpace
       (vla-get-ActiveDocument
         (vlax-get-acad-object)
       )
     )
     (LM:SafearrayVariant vlax-VBDouble (apply 'append (LM:ent-&amp;gt;pts (car (entsel)) 3)))
   )
)
;; Entity to Point List  -  Lee Mac
;; Returns a list of WCS points describing or approximating the supplied entity, else nil if the entity is not supported.
;; ent - [ent] Entity name to be described by point list (POINT/LINE/ARC/CIRCLE/LWPOLYLINE/POLYLINE/ELLIPSE/SPLINE)
;; acc - [num] Positive number determining the point density for non-linear objects
(defun LM:ent-&amp;gt;pts ( ent acc / ang bul cen cls di1 di2 enx inc itm lst num ocs rad tot typ vt1 vt2 vtl )
    (setq enx (entget ent)
          typ (cdr (assoc 0 enx))
    )
    (cond
        (   (= "POINT" typ)
            (list (cdr (assoc 10 enx)))
        )
        (   (= "LINE" typ)
            (mapcar '(lambda ( x ) (cdr (assoc x enx))) '(10 11))
        )
        (   (or (= "ARC" typ) (= "CIRCLE" typ))
            (if (= "ARC" typ)
                (setq ang (cdr (assoc 50 enx))
                      tot (rem (+ pi pi (- (cdr (assoc 51 enx)) ang)) (+ pi pi))
                      num (fix (+ 1.0 1e-8 (* acc (/ tot (+ pi pi)))))
                      inc (/ tot (float num))
                      num (1+ num)
                )
                (setq ang 0.0
                      tot (+ pi pi)
                      num (fix (+ 1e-8 acc))
                      inc (/ tot (float num))
                )
            )
            (setq cen (cdr (assoc 010 enx))
                  rad (cdr (assoc 040 enx))
                  ocs (cdr (assoc 210 enx))
            )
            (repeat num
                (setq lst (cons (trans (polar cen ang rad) ocs 0) lst)
                      ang (+ ang inc)
                )
            )
            (reverse lst)
        )
        (   (or (= "LWPOLYLINE" typ)
                (and (= "POLYLINE" typ) (zerop (logand (logior 16 64) (cdr (assoc 70 enx)))))
            )
            (if (= "LWPOLYLINE" typ)
                (setq vtl (LM:ent-&amp;gt;pts:lwpolyvertices enx))
                (setq vtl (LM:ent-&amp;gt;pts:polyvertices   ent))
            )
            (if (setq ocs (cdr (assoc 210 enx))
                      cls (= 1 (logand 1 (cdr (assoc 70 enx))))
                )
                (setq vtl (append vtl (list (cons (caar vtl) 0.0))))
            )
            (while (setq itm (car vtl))
                (setq vtl (cdr vtl)
                      vt1 (car itm)
                      bul (cdr itm)
                      lst (cons (trans vt1 ocs 0) lst)
                )
                (if (and (not (equal 0.0 bul 1e-8)) (setq vt2 (caar vtl)))
                    (progn
                        (setq rad (/ (* (distance vt1 vt2) (1+ (* bul bul))) 4.0 bul)
                              cen (polar vt1 (+ (angle vt1 vt2) (- (/ pi 2.0) (* 2.0 (atan bul)))) rad)
                              rad (abs rad)                            
                              tot (* 4.0 (atan bul))
                              num (fix (+ 1.0 1e-8 (* acc (/ (abs tot) (+ pi pi)))))
                              inc (/ tot (float num))
                              ang (+ (angle cen vt1) inc)
                        )                        
                        (repeat (1- num)
                            (setq lst (cons (trans (polar cen ang rad) ocs 0) lst)
                                  ang (+ ang inc)
                            )
                        )
                    )
                )
            )
            (reverse (if cls (cdr lst) lst))
        )
        (   (= "ELLIPSE" typ)
            (setq di1 (vlax-curve-getdistatparam ent (vlax-curve-getstartparam ent))
                  di2 (vlax-curve-getdistatparam ent (vlax-curve-getendparam   ent))
                  di2 (- di2 1e-8)
            )
            (while (&amp;lt; di1 di2)
                (setq lst (cons (vlax-curve-getpointatdist ent di1) lst)
                      rad (distance '(0.0 0.0) (vlax-curve-getfirstderiv ent (vlax-curve-getparamatdist ent di1)))
                      di1 (+ di1 (/ di2 (1+ (fix (* acc (/ di2 rad (+ pi pi)))))))
                )
            )
            (reverse (if (vlax-curve-isclosed ent) lst (cons (vlax-curve-getendpoint ent) lst)))
        )
        (   (= "SPLINE" typ)
            (setq di1 (vlax-curve-getdistatparam ent (vlax-curve-getstartparam ent))
                  di2 (vlax-curve-getdistatparam ent (vlax-curve-getendparam   ent))
                  lst (list (vlax-curve-getstartpoint ent))
                  inc (/ (- di2 di1) (float acc))
                  di1 (+ di1 inc)
            )
            (repeat (1- (fix (+ 1e-8 acc)))
                (setq lst (cons (vlax-curve-getpointatdist ent di1) lst)
                      di1 (+ di1 inc)
                )
            )
            (reverse (if (vlax-curve-isclosed ent) lst (cons (vlax-curve-getendpoint ent) lst)))
        )
    )
)
(defun LM:ent-&amp;gt;pts:lwpolyvertices ( enx / elv lst vtx )
    (setq elv (list (cdr (assoc 38 enx))))
    (while (setq vtx (assoc 10 enx))
        (setq enx (cdr (member vtx enx))
              lst (cons (cons (append (cdr vtx) elv) (cdr (assoc 42 enx))) lst)
        )
    )
    (reverse lst)
)
(defun LM:ent-&amp;gt;pts:polyvertices ( ent / lst vte vtx )
    (setq vte (entnext ent)
          vtx (entget  vte)
    )   
    (while (= "VERTEX" (cdr (assoc 0 vtx)))
        (setq lst (cons (cons (cdr (assoc 10 vtx)) (cdr (assoc 42 vtx))) lst)
              vte (entnext vte)
              vtx (entget  vte)
        )
    )
    (reverse lst)
)
(defun LM:SafearrayVariant ( datatype data )
 (vlax-make-variant
   (vlax-safearray-fill
     (vlax-make-safearray datatype
       (cons 0 (1- (length data)))
     )
     data
   )    
 )
)

(Conv2Mline)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 15:46:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670794#M54406</guid>
      <dc:creator>Browning_Zed</dc:creator>
      <dc:date>2021-10-06T15:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: Model Space and Paper Space</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670801#M54407</link>
      <description>&lt;P&gt;I tried again but that also doesn't work. I posted the code above this post.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 15:44:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670801#M54407</guid>
      <dc:creator>Browning_Zed</dc:creator>
      <dc:date>2021-10-06T15:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: Model Space and Paper Space</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670820#M54408</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt; take care, if a viewport is activated in the current paper space (vla-get-ActiveLayout ...) will return the paper space layout despite the active space is model space.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 15:49:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670820#M54408</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2021-10-06T15:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Model Space and Paper Space</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670832#M54409</link>
      <description>&lt;LI-CODE lang="general"&gt;(defun Conv2Mline (/)
  (vla-AddMline
    (if	(= (getvar 'cvport) 1)
      (vla-get-PaperSpace (vla-get-ActiveDocument (vlax-get-acad-object)))
      (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)))
    )
    (LM:SafearrayVariant vlax-VBDouble (apply 'append (LM:ent-&amp;gt;pts (car (entsel)) 3)))
  )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 06 Oct 2021 15:53:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670832#M54409</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2021-10-06T15:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: Model Space and Paper Space</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670850#M54410</link>
      <description>Thanks a lot! The function now works as expected.</description>
      <pubDate>Wed, 06 Oct 2021 15:58:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/model-space-and-paper-space/m-p/10670850#M54410</guid>
      <dc:creator>Browning_Zed</dc:creator>
      <dc:date>2021-10-06T15:58:02Z</dc:date>
    </item>
  </channel>
</rss>

