<?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 : Plot PDF named after attributes in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6733441#M125904</link>
    <description>&lt;P&gt;Sorry, I had to express myself badly.&lt;BR /&gt;I asked for a dwg as an example to understand the need&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;@+&lt;/P&gt;</description>
    <pubDate>Wed, 07 Dec 2016 13:17:42 GMT</pubDate>
    <dc:creator>patrick_35</dc:creator>
    <dc:date>2016-12-07T13:17:42Z</dc:date>
    <item>
      <title>Plot PDF named after attributes</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6731720#M125899</link>
      <description>&lt;P&gt;Hello Everybody,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;after more than a day search, I still didn´t manage to put together a code that would work for the following purpose:&lt;/P&gt;&lt;P&gt;I´d like use LISP/Script to create PDF from each layout, but the filename of that should be made up from 3 attributes in a title block in paper space.&lt;/P&gt;&lt;P&gt;Something similar to this:&lt;/P&gt;&lt;P&gt;I have one block on the layout which is called Title_block.&lt;/P&gt;&lt;P&gt;Inside this there are 3 attributes:&lt;/P&gt;&lt;P&gt;Name1, Name2 and Name3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After running the command the created PDF should be named like this: Name1-Name2-Name3.pdf&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did manage to plot the layouts, but I cannot get the those variables out of the attributes. That´s why I´m reaching out for advice.&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2016 20:30:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6731720#M125899</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-12-06T20:30:11Z</dc:date>
    </item>
    <item>
      <title>Re : Plot PDF named after attributes</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6732610#M125900</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have &lt;A href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/print-multiple-sheets-from-model-space/m-p/6685007/highlight/true#M346846" target="_self"&gt;this post&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;@+&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 07:06:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6732610#M125900</guid>
      <dc:creator>patrick_35</dc:creator>
      <dc:date>2016-12-07T07:06:36Z</dc:date>
    </item>
    <item>
      <title>Re : Plot PDF named after attributes</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6732784#M125901</link>
      <description>&lt;P&gt;Hi Patrick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for the answer. However it seems the user in the other post had a different method by having all the sheets the model space. And I couldn´t figure out where to define the block name and attributes in your code (I have very basic knowledge of this).&lt;/P&gt;&lt;P&gt;In my case to be more specific, should be more simple:&lt;/P&gt;&lt;P&gt;We use the same plot for each layout. Every layout has the same title_block with the same attributes inside.&lt;/P&gt;&lt;P&gt;The code should just grab these text values from these attributes and use them in the filename.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 08:59:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6732784#M125901</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-12-07T08:59:15Z</dc:date>
    </item>
    <item>
      <title>Re : Plot PDF named after attributes</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6732972#M125902</link>
      <description>&lt;P&gt;The easiest way is to give an example to adapt the code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;@+&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 10:15:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6732972#M125902</guid>
      <dc:creator>patrick_35</dc:creator>
      <dc:date>2016-12-07T10:15:43Z</dc:date>
    </item>
    <item>
      <title>Re : Plot PDF named after attributes</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6733389#M125903</link>
      <description>&lt;P&gt;So I started off with this example I found before.&lt;/P&gt;&lt;P&gt;It´s simple and does the job creating PFDs. The thing I would skip here is having the "Save as..." window popping up.&lt;/P&gt;&lt;P&gt;But the goal would be that the variable "PDFNAME" would contain the text values of 3 attributes inside Title_Block (instead of Ctab or filepath, etc).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(DEFUN c:PDF ()
  (setq FILEPATHNAME (getvar "DWGPREFIX"))
  (setq PDFPREFIX (substr FILEPATHNAME 13 5))
  (setq PDFEND (getvar "CTAB"))
  (setq PDFNAME (strcat PDFPREFIX " " PDFEND))
(SETVAR "CMDECHO" 0)
 (COMMAND "-PLOT"
    "Y"
    ""
    "DWG TO PDF.PC3"
    "ISO A3 (420.00 x 297.00 MM)"
    "M"
    "L"
    "N"
    "E"
    "1:1"
    "CEN"
    "Y"
    "monochrome.ctb"
    "Y"
    "N"
    "N"
    "N"
    (getfiled "Save File as..." PDFNAME "pdf" 1)
       
    "N"
    "Y"
  )
  (SETVAR "CMDECHO" 1)
  (PRINC)
)&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Dec 2016 13:01:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6733389#M125903</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-12-07T13:01:18Z</dc:date>
    </item>
    <item>
      <title>Re : Plot PDF named after attributes</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6733441#M125904</link>
      <description>&lt;P&gt;Sorry, I had to express myself badly.&lt;BR /&gt;I asked for a dwg as an example to understand the need&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;@+&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 13:17:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6733441#M125904</guid>
      <dc:creator>patrick_35</dc:creator>
      <dc:date>2016-12-07T13:17:42Z</dc:date>
    </item>
    <item>
      <title>Re : Plot PDF named after attributes</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6734272#M125905</link>
      <description>&lt;P&gt;Ah, sorry. &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I misunderstood. I´ve attached the dwg that I´d like to work with.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So in this particular case the printed pdf should be named as: ID01-A0001-P0001-01-00.pdf&lt;/P&gt;&lt;P&gt;Which is made up from the following attributes inside "titleblock_fabr":&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROJ_ID, ASSEMBLY-NO, PART-NO, SHEET, REV&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 17:01:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6734272#M125905</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-12-07T17:01:19Z</dc:date>
    </item>
    <item>
      <title>Re : Plot PDF named after attributes</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6736102#M125906</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example&lt;/P&gt;
&lt;PRE&gt;(defun c:imp(/ att blo doc nom fil plt sel lst2str)
  (defun lst2str (lst sep)
    (if (cadr lst)
      (strcat (vl-princ-to-string (car lst))
	      sep
	      (lst2str (cdr lst) sep)
      )
      (vl-princ-to-string (car lst))
    )
  )

  (setq doc (vla-get-activedocument (vlax-get-acad-object))
	bck (getvar "backgroundplot")
  )
  (vla-startundomark doc)
  (and (ssget "_x" (list (cons 0 "insert") (cons 2 "titleblock_fabr") (cons 410 (getvar "ctab"))))
    (progn
      (and bck
	(setvar "backgroundplot" 0)
      )
      (vlax-for blo (setq sel (vla-get-activeselectionset doc))
	(setq att (vlax-invoke blo 'getattributes)
	      nom (strcat (getvar "dwgprefix")
			  (lst2str (mapcar '(lambda(x)(vla-get-textstring (nth x att))) '(9 4 3 14 15)) "-")
			  ".pdf"
		  )
	      plt (vla-get-plot doc)
	)
	(and (setq fil (findfile nom))
	  (vl-file-delete fil)
	)
	(vlax-invoke plt 'plottofile nom)
      )
      (vla-delete sel)
      (and bck
	(setvar "backgroundplot" bck)
      )
    )
  )
  (vla-endundomark doc)
  (princ)
)&lt;/PRE&gt;
&lt;P&gt;@+&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 11:15:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6736102#M125906</guid>
      <dc:creator>patrick_35</dc:creator>
      <dc:date>2016-12-08T11:15:04Z</dc:date>
    </item>
    <item>
      <title>Re : Plot PDF named after attributes</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6737146#M125907</link>
      <description>&lt;P&gt;I´ll be honest Patrick, I have no idea what you did, but it works like a charm. &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I can´t see any of the attribute IDs or the plotter settings in your code, but it still works. A little education would be highly appreciated. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How different would this look like, if I wanted it to run the same code on every available layouts inside the DWG?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help and patience so far.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 17:13:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6737146#M125907</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-12-08T17:13:43Z</dc:date>
    </item>
    <item>
      <title>Re : Plot PDF named after attributes</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6738756#M125908</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;I will try to be explicit.&lt;BR /&gt;I will give the logic and you will be able to do directly to the keyboard the pieces of codes that I will give you, and so see the why of how&lt;/P&gt;
&lt;P&gt;01) I started on the basis that the layout had its page setup ok.&lt;BR /&gt;02) You indicate that you work in the current drawing&lt;/P&gt;
&lt;PRE&gt;(setq doc (Vla-get-activedocument (vlax-get-acad-object)))&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;03) You make a selection of the block "titleblock_fabr" of the active layout&lt;/P&gt;
&lt;PRE&gt;(ssget "_x" (list (cons 0 "insert") (cons 2 "titleblock_fabr") (cons 410 (getvar "ctab"))))&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;04) You retrieve the selection filtered in vlisp by this property&lt;/P&gt;
&lt;PRE&gt;(vla-get-activeselectionset doc)&lt;/PRE&gt;
&lt;P&gt;05) What you put in the sel's variable&lt;/P&gt;
&lt;PRE&gt;(setq sel (vla-get-activeselectionset doc))&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;06) To see the selection, the number of elements found, you can do&lt;/P&gt;
&lt;PRE&gt;(vlax-dump-object sel t)&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;07) To see the 1st element of the selection, you can do&lt;/P&gt;
&lt;PRE&gt;(vlax-dump-object (vla-item sel 0))&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;08) Remains to make a loop to browse the selection with a vlax-for&lt;/P&gt;
&lt;PRE&gt;(vlax-for blo (setq sel (vla-get-activeselectionset doc))
...
)&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;09) For our example, I will take directly the 1st object of the selection&lt;/P&gt;
&lt;PRE&gt;(setq blo (vla-item sel 0))&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;10) I now have my block in vlisp. To verify&lt;/P&gt;
&lt;PRE&gt;(vlax-dump-object blo)&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;11) Now I need to retrieve the attributes of the block, which I will put in the variable att&lt;/P&gt;
&lt;PRE&gt;(setq att (vlax-invoke blo 'getattributes))&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;12) I got a list that contains all the attributes of my block. To get the first attribute, I do&lt;/P&gt;
&lt;PRE&gt;(nth 0 att)&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;13) And to see its characteristics, I do&lt;/P&gt;
&lt;PRE&gt;(vlax-dump-object (nth 0 att))&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;14) I edit the block (_attedit) and I count the position of the attributes that interests me, namely the 9em, 4em, 3em, 14em and 15em attribute.&lt;BR /&gt;15) So, logically, a (nth 9 att) should give me my 1st value. Check&lt;/P&gt;
&lt;PRE&gt;(vlax-dump-object (nth 9 att))&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;16) I look at the result and notice that the TextString property gives me the desired value. Check&lt;/P&gt;
&lt;PRE&gt;(vla-get-textstring (nth 9 att))&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;17) I have my value. Let's check with the 4th value&lt;/P&gt;
&lt;PRE&gt;(vla-get-textstring (nth 4 att))&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;18) It looks good. To avoid entering several times a vla-get-textstring and give flexibility to the code, I will use the lisp mapcar function. An example that illustrates this function well. Add 1 to the values ​​in this list '(1 2 3 4 5 6)&lt;/P&gt;
&lt;PRE&gt;(mapcar '1+' (1 2 3 4 5 6))&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;19) I have the expected result. It remains to apply it to the attributes.&lt;/P&gt;
&lt;PRE&gt;(mapcar '(lambda(x)(vla-get-textstring (nth x att))) '(9 4 3 14 15))&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;20) Great. I have the desired value of the attributes that interests me. It remains to group this list into a string of characters with a separator. For this, I will use the function given by &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;, lst2str. Check&lt;/P&gt;
&lt;PRE&gt;(defun lst2str (lst sep)
  (if (cadr lst)
    (strcat (vl-princ-to-string (car lst))
	    sep
	    (lst2str (cdr lst) sep)
    )
    (vl-princ-to-string (car lst))
  )
)
(lst2str (mapcar '(lambda(x)(vla-get-textstring (nth x att))) '(9 4 3 14 15)) "-")&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;21) Ok. That works, I now have the name. It remains to give him the location and extension.&lt;/P&gt;
&lt;PRE&gt;(setq nom (strcat (getvar "dwgprefix")
		  (lst2str (mapcar '(lambda(x)(vla-get-textstring (nth x att))) '(9 4 3 14 15)) "-")
		  ".pdf"
	  )
)&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;22) It remains to check if the file already exists and if yes, delete it&lt;/P&gt;
&lt;PRE&gt;(and (setq fil (findfile nom))
  (vl-file-delete fil)
)&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;23) Then print. To access the plotter, which you range in a variable, you do&lt;/P&gt;
&lt;PRE&gt;(setq plt (vla-get-plot doc))&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;24) Verify with the methods&lt;/P&gt;
&lt;PRE&gt;(vlax-dump-object plt t)&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;25) And I see the PlotToFile method which allows to write to a file my print.&lt;BR /&gt;26) Remains to print.&lt;/P&gt;
&lt;PRE&gt;(Vla-plottofile plt name)&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;27) Since I do not want the printing to be background of my task, I modify the variable backgroundplot&lt;/P&gt;
&lt;PRE&gt;(setvar "backgroundplot" 0)&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;28) And that I see the scroll bar of printing&lt;/P&gt;
&lt;PRE&gt;(vlax-invoke plt 'plottofile nom)&lt;/PRE&gt;
&lt;P&gt;This is the lisp explained. I hope this is clear and understandable, despite my English translated with Google&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;@+&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2016 08:52:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6738756#M125908</guid>
      <dc:creator>patrick_35</dc:creator>
      <dc:date>2016-12-09T08:52:38Z</dc:date>
    </item>
    <item>
      <title>Re : Plot PDF named after attributes</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6738989#M125909</link>
      <description>&lt;P&gt;Patrick, this is very &amp;nbsp;good. I learned a lot. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2016 10:48:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/plot-pdf-named-after-attributes/m-p/6738989#M125909</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-12-09T10:48:33Z</dc:date>
    </item>
  </channel>
</rss>

