<?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: Viewport Scale Equal To Annotation Scale - LISP in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/viewport-scale-equal-to-annotation-scale-lisp/m-p/12419389#M20846</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14650428"&gt;@chancevv&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on your screenshots, it would appear to me that your &lt;U&gt;Paper Space&lt;/U&gt; is setup to be &lt;STRONG&gt;INCHES&lt;/STRONG&gt; and your &lt;U&gt;Model Space&lt;/U&gt; to be &lt;STRONG&gt;FEET&lt;/STRONG&gt;. If I am correct in those 2 assumptions, then this code below should work for you. I have set it up in a way so that when you input your desired scales, you can enter &lt;EM&gt;both&lt;/EM&gt; your decimal/engineering scales (e.g. 1"=30') and your architectural scales (e.g. 1/8"=1').&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:TEST ( / errMsg paperInch drawingFoot ssVP vp cScale lockState)
  ;; initial checks to be sure we're in paper space
  (if (or (not (= 1 (getvar 'CVPORT)))
          (not (zerop (getvar 'TILEMODE))))
    (setq errMsg "\nMust be in Paper Space.")
  );if
  (if errMsg (progn (alert (princ errMsg)) (exit)))
  ;; get vp scale inputs from user [or we can use defaults if desired]
  ;; (setq paperInch 1)
  ;; (setq drawingFoot 30)
  (initget 7) (setq paperInch (getreal "\nEnter Paper Inches (e.g. if 1\"=30' then enter '1'): "))
  (initget 7) (setq drawingFoot (getreal "\nEnter Drawing Feet (e.g. if 1\"=30' then enter '30'): "))
  (prompt "Select VIEWPORT to change scale: ")
  (if (setq ssVP (ssget "_+.:E:S" '((0 . "VIEWPORT"))))
    (progn
      (setq vp (ssname ssVP 0))
      (setq cScale (/ (* 12.0 paperInch) (* 12.0 drawingFoot)))
      (setq lockState (getpropertyvalue vp "Locked"))
      (setpropertyvalue vp "Locked" 0) 
      (setpropertyvalue vp "CustomScale" cScale)
      (setpropertyvalue vp "Locked" lockState)
      (prompt "\nCustom Viewport scale successfully set.")
    );progn
  ;else
    (prompt "\nViewport not selected. No action taken.")
  );if
  (princ)
);defun&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;~DD&lt;/P&gt;</description>
    <pubDate>Mon, 04 Dec 2023 22:36:21 GMT</pubDate>
    <dc:creator>CodeDing</dc:creator>
    <dc:date>2023-12-04T22:36:21Z</dc:date>
    <item>
      <title>Viewport Scale Equal To Annotation Scale - LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/viewport-scale-equal-to-annotation-scale-lisp/m-p/12419312#M20845</link>
      <description>&lt;P&gt;Hi! Running into an interesting situation when trying to scale the viewport of my layout with LISP.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Quick rundown: I'm trying to automate scaling the viewport to 1" = 750' by calling a custom command made with LISP. When doing this manually usingmouse and keyboard, I noticed in the command line that it uses the command _.MSPACE to enter the model space of the viewport, _CANNOSCALE to adjust the scale of the viewport to the predefined scales on the list, and then ._PSPACE to exit the viewport. Seems simple.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 262px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1300700iC5AB3E64C4BB2CCA/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Here's what the command line looks like:&lt;/P&gt;&lt;P&gt;Command: _.MSPACE&lt;BR /&gt;Command: _CANNOSCALE&lt;BR /&gt;Enter new value for CANNOSCALE &amp;lt;"1" = 500'"&amp;gt;: 1" = 750'&lt;BR /&gt;Command: _.PSPACE&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If I click back into the viewport and type VPSCALE, the scale corresponds with the value chosen from the list. Ex: the command line will show&amp;nbsp;PS:MS == 1:750 for this example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I want to apply this into LISP code. Based on what the command line was showing while doing this manually, I created the following:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:scaleadjustment()
(setq desiredscale "1\" = 750'")
(command "._mspace")
(command "_cannoscale" desiredscale)
(command "._pspace")
(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Upon calling the command, the command line looks virtually the same:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Command: SCALEADJUSTMENT&lt;BR /&gt;Command: ._mspace&lt;BR /&gt;Command: _cannoscale&lt;BR /&gt;Enter new value for CANNOSCALE &amp;lt;"1" = 500'"&amp;gt;: 1" = 750'&lt;BR /&gt;Command: ._pspace&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;However, it does not increase or decrease the zoom of my viewport like it would if I am using the button at the bottom of the screen and clicking the corresponding value. If I type in _CANNOSCALE after calling the command, it has the value CANNOSCALE &amp;lt;1" = 750'"&amp;gt;: , but if I type VPSCALE it will show the initial scale value. Therefore, when using _CANNOSCALE in LISP, it doesn't automatically match the viewport scale with the updated annotation scale.&lt;BR /&gt;&lt;BR /&gt;There is a button to the right of the scale value for this, but from what I can (or can't) find, there is not a command to queue this. Does anyone know how it can be replicated in LISP, or if there is a different way to tackle this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.png" style="width: 417px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1300702iABC328F073FB8B82/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.png" alt="2.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Really appreciate any insight!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2023 21:43:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/viewport-scale-equal-to-annotation-scale-lisp/m-p/12419312#M20845</guid>
      <dc:creator>chancevv</dc:creator>
      <dc:date>2023-12-04T21:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: Viewport Scale Equal To Annotation Scale - LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/viewport-scale-equal-to-annotation-scale-lisp/m-p/12419389#M20846</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14650428"&gt;@chancevv&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on your screenshots, it would appear to me that your &lt;U&gt;Paper Space&lt;/U&gt; is setup to be &lt;STRONG&gt;INCHES&lt;/STRONG&gt; and your &lt;U&gt;Model Space&lt;/U&gt; to be &lt;STRONG&gt;FEET&lt;/STRONG&gt;. If I am correct in those 2 assumptions, then this code below should work for you. I have set it up in a way so that when you input your desired scales, you can enter &lt;EM&gt;both&lt;/EM&gt; your decimal/engineering scales (e.g. 1"=30') and your architectural scales (e.g. 1/8"=1').&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:TEST ( / errMsg paperInch drawingFoot ssVP vp cScale lockState)
  ;; initial checks to be sure we're in paper space
  (if (or (not (= 1 (getvar 'CVPORT)))
          (not (zerop (getvar 'TILEMODE))))
    (setq errMsg "\nMust be in Paper Space.")
  );if
  (if errMsg (progn (alert (princ errMsg)) (exit)))
  ;; get vp scale inputs from user [or we can use defaults if desired]
  ;; (setq paperInch 1)
  ;; (setq drawingFoot 30)
  (initget 7) (setq paperInch (getreal "\nEnter Paper Inches (e.g. if 1\"=30' then enter '1'): "))
  (initget 7) (setq drawingFoot (getreal "\nEnter Drawing Feet (e.g. if 1\"=30' then enter '30'): "))
  (prompt "Select VIEWPORT to change scale: ")
  (if (setq ssVP (ssget "_+.:E:S" '((0 . "VIEWPORT"))))
    (progn
      (setq vp (ssname ssVP 0))
      (setq cScale (/ (* 12.0 paperInch) (* 12.0 drawingFoot)))
      (setq lockState (getpropertyvalue vp "Locked"))
      (setpropertyvalue vp "Locked" 0) 
      (setpropertyvalue vp "CustomScale" cScale)
      (setpropertyvalue vp "Locked" lockState)
      (prompt "\nCustom Viewport scale successfully set.")
    );progn
  ;else
    (prompt "\nViewport not selected. No action taken.")
  );if
  (princ)
);defun&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;~DD&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2023 22:36:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/viewport-scale-equal-to-annotation-scale-lisp/m-p/12419389#M20846</guid>
      <dc:creator>CodeDing</dc:creator>
      <dc:date>2023-12-04T22:36:21Z</dc:date>
    </item>
  </channel>
</rss>

