<?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: Custom Save command help in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-save-command-help/m-p/5458478#M145106</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to add lines to it that will check if the current drawing has a viewport in, if it does not then I just want it to run a regular save command without zooming or running propulate. Some of our drawings are just model files and having it run the extra commands are just unneccesary and are causing issues.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;One way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(setq ss (ssget "_X" (list '(0 . "VIEWPORT")))
      layt_lst (layoutlist))
(if (/= (sslength ss) (length layt_lst))
  ;; do the layout commands
  ;; do just the save
  )&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;I hope this helps&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;Henrique&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 05 Jan 2015 10:48:12 GMT</pubDate>
    <dc:creator>hmsilva</dc:creator>
    <dc:date>2015-01-05T10:48:12Z</dc:date>
    <item>
      <title>Custom Save command help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-save-command-help/m-p/5458452#M145105</link>
      <description>&lt;P&gt;I am currently altering our work save config to better suit our workflow but I am struggling to make one change.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The current command is this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(command"_.Undefine""_.QSave") ; Undefine the QSave command
; define a custom Save command that executes Propulate command and then save
(defun c:Qsave ()
 (command"_PSPACE""")
 (command"_.layout""_Set""") ; Move to LAYOUT 1
 (command"_.regen")
 (command"_.Propulate""_Update""_Current") ; run Propulate command
 (command"_.ZOOM""_E") ; zoom extents before save
 (command"_.QSave""""")(princ) ; run standard save command
)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add lines to it that will check if the current drawing has a viewport in, if it does not then I just want it to run a regular save command without zooming or running propulate. Some of our drawings are just model files and having it run the extra commands are just unneccesary and are causing issues.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jan 2015 10:08:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-save-command-help/m-p/5458452#M145105</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-01-05T10:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Save command help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-save-command-help/m-p/5458478#M145106</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to add lines to it that will check if the current drawing has a viewport in, if it does not then I just want it to run a regular save command without zooming or running propulate. Some of our drawings are just model files and having it run the extra commands are just unneccesary and are causing issues.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;One way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(setq ss (ssget "_X" (list '(0 . "VIEWPORT")))
      layt_lst (layoutlist))
(if (/= (sslength ss) (length layt_lst))
  ;; do the layout commands
  ;; do just the save
  )&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;I hope this helps&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;Henrique&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jan 2015 10:48:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-save-command-help/m-p/5458478#M145106</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2015-01-05T10:48:12Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Save command help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-save-command-help/m-p/5458480#M145107</link>
      <description>Thank you, would I add it in at the beginning just under this line?&lt;BR /&gt;&lt;BR /&gt;(defun c:Qsave ()</description>
      <pubDate>Mon, 05 Jan 2015 10:54:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-save-command-help/m-p/5458480#M145107</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-01-05T10:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Save command help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-save-command-help/m-p/5458482#M145108</link>
      <description>&lt;P&gt;&lt;SPAN class="hps"&gt;You 're welcome.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;Try&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(command"_.Undefine""_.QSave") ; Undefine the QSave command
; define a custom Save command that executes Propulate command and then save
(defun c:Qsave ( / layt_lst ss)
  (setq ss (ssget "_X" (list '(0 . "VIEWPORT")))
      layt_lst (layoutlist))
(if (/= (sslength ss) (length layt_lst))
  (progn
 (command"_PSPACE""")
 (command"_.layout""_Set""") ; Move to LAYOUT 1
 (command"_.regen")
 (command"_.Propulate""_Update""_Current") ; run Propulate command
 (command"_.ZOOM""_E") ; zoom extents before save
 (command"_.QSave""""")(princ) ; run standard save command
 );; progn
 (command"_.QSave""""")(princ) ; run standard save command
  );; if
  (princ)
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Henrique&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jan 2015 11:00:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-save-command-help/m-p/5458482#M145108</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2015-01-05T11:00:42Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Save command help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-save-command-help/m-p/5458496#M145109</link>
      <description>Just getting a syntax error &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;</description>
      <pubDate>Mon, 05 Jan 2015 11:11:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-save-command-help/m-p/5458496#M145109</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-01-05T11:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Save command help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-save-command-help/m-p/5458513#M145110</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;Just getting a syntax error &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Code revised&lt;/P&gt;
&lt;PRE&gt;(command"_.Undefine""_.QSave") ; Undefine the QSave command
; define a custom Save command that executes Propulate command and then save
(defun c:Qsave ( / layt_lst ss)
  (setq ss (ssget "_X" (list '(0 . "VIEWPORT")))
      layt_lst (layoutlist))
(if (/= (sslength ss) (length layt_lst))
  (progn
 (command"_PSPACE""")
 (command"_.layout""_Set""") ; Move to LAYOUT 1
 (command"_.regen")
 (command"_.Propulate""_Update""_Current") ; run Propulate command
 (command"_.ZOOM""_E") ; zoom extents before save
 (command"_.QSave") ; run standard save command
 );; progn
 (command"_.QSave") ; run standard save command
  );; if
  (princ)
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Henrique&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jan 2015 11:33:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-save-command-help/m-p/5458513#M145110</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2015-01-05T11:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Save command help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-save-command-help/m-p/5458564#M145111</link>
      <description>Perfect! Thank you! Any chance you could comment on it and how it works? I am trying to learn this stuff so that would be greatly appreciated. If not then thank you anyway, huge help!</description>
      <pubDate>Mon, 05 Jan 2015 12:57:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-save-command-help/m-p/5458564#M145111</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-01-05T12:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Save command help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-save-command-help/m-p/5458699#M145112</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;Perfect! Thank you! Any chance you could comment on it and how it works? I am trying to learn this stuff so that would be greatly appreciated. If not then thank you anyway, huge help!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You're welcome, MDub!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the code:&lt;/P&gt;
&lt;PRE&gt;(defun c:Qsave ( / layt_lst ss)
  ;; create a selection set with "VIEWPORT" entities
  ;; each layout is a "VIEWPORT"
  (setq ss (ssget "_X" (list '(0 . "VIEWPORT")))
  ;; create a layout list
      layt_lst (layoutlist))
  ;; test function...
  ;; test if number of layouts is not equal to
  ;; number of layouts
  ;; if number is not the same, there are VIEWPORTS
(if (/= (sslength ss) (length layt_lst))
  (progn;; if true the test function, do this
 (command"_PSPACE""")
 (command"_.layout""_Set""") ; Move to LAYOUT 1
 (command"_.regen")
 (command"_.Propulate""_Update""_Current") ; run Propulate command
 (command"_.ZOOM""_E") ; zoom extents before save
 (command"_.QSave") ; run standard save command
 );; progn
  ;; if not true the test function, do this
 (command"_.QSave") ; run standard save command
  );; if
  (princ)
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;As I&lt;/SPAN&gt; &lt;SPAN class="hps alt-edited"&gt;had previously said&lt;/SPAN&gt;, this test function is &lt;SPAN class="hps"&gt;one of several ways to do the test, another &lt;SPAN class="hps alt-edited"&gt;could be&lt;/SPAN&gt; just test a "VIEWPORT" selection set, using a filter for VPid "dxf 69",&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;(if (setq ss (ssget "_X" '((0 . "VIEWPORT") (-4 . "&amp;gt;") (69 . 1))))&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;test for a selection set with an id greater than 1 (1 is the "LAYOUT"), and the rest of the code &lt;SPAN class="hps"&gt;would be the same&lt;/SPAN&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;Hope that helps&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;Henrique&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jan 2015 14:40:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-save-command-help/m-p/5458699#M145112</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2015-01-05T14:40:08Z</dc:date>
    </item>
  </channel>
</rss>

