<?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: CREATE MACRO TO IMPORT STOCK MODEL in PowerMill Forum</title>
    <link>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9637618#M11071</link>
    <description>&lt;P&gt;ok, try this. I cleaned it up a little and added some better comments for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;//---------- initialize variables: ---------//
// -the filepath of the stock model folder  //
// -a list of all the .stkmd files only     //
// -the file name prefix                    //
// -declare empty variable to hold the path //
//------------------------------------------//
STRING filePath = "C:/Users/David/Desktop/test"
STRING LIST $stockFiles = list_files('files', $filePath, '.stkmd')
STRING fileName = INPUT "Enter File Name"
STRING stockModelPath = ""

// create a new list for only the 
// names with the input prefix
STRING LIST stockNames = {}

// loop through the directory and add 
// those to the list 
FOREACH file IN stockFiles {
	// if the name contains the prefix, add
	// it to the list
	IF position(file, fileName) &amp;gt; -1 {
        	INT $Ok = add_last(stockNames, TOKENS(file, "/")[SIZE(TOKENS(file, "/"))-1])
	}
}

// display desired in pulldown list
INT i = INPUT CHOICE $stockNames "Select Stock File"

// create the file path for the 
// selected stock model
$stockModelPath = $filePath + "/" + $stockNames[$i]

// import the stock model
IMPORT STOCKMODEL $stockModelPath&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 15 Jul 2020 19:27:55 GMT</pubDate>
    <dc:creator>TK.421</dc:creator>
    <dc:date>2020-07-15T19:27:55Z</dc:date>
    <item>
      <title>CREATE MACRO TO IMPORT STOCK MODEL</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9635985#M11063</link>
      <description>&lt;P&gt;Due to the wide variety of projects in various situations, we export stock models for other programmers to import if necessary.&lt;/P&gt;&lt;P&gt;Instead of looking in windows explorer, I would like to create a macro where I would type in the name of the project (first 4 digits of the file) and it would list only the files with these conditions where I would choose the one and import it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 02:41:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9635985#M11063</guid>
      <dc:creator>diegoverciano85</dc:creator>
      <dc:date>2020-07-15T02:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE MACRO TO IMPORT STOCK MODEL</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9636885#M11064</link>
      <description>&lt;P&gt;try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;STRING filePath = "C:/Users/David/Desktop/test"&lt;BR /&gt;STRING LIST $stockFiles = list_files('files', $filePath, '.stkmd')&lt;BR /&gt;STRING fileName = INPUT "Enter File Name"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;//create a new list stockNames &lt;BR /&gt;STRING LIST $stockNames = {}&lt;BR /&gt;FOREACH file IN stockFiles {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF position(file, fileName) &amp;gt; -1 {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INT $Ok = add_last($stockNames, TOKENS($File, "/")[SIZE(TOKENS($File, "/"))-1])&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;//display desired in pulldown list&lt;BR /&gt;INT $C = INPUT CHOICE $stockNames "Select Stock File"&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 13:51:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9636885#M11064</guid>
      <dc:creator>TK.421</dc:creator>
      <dc:date>2020-07-15T13:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE MACRO TO IMPORT STOCK MODEL</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9636925#M11065</link>
      <description>&lt;DIV class="tlid-input input"&gt;&lt;DIV class="source-wrap"&gt;&lt;DIV class="input-full-height-wrapper tlid-input-full-height-wrapper"&gt;&lt;DIV class="source-input"&gt;&lt;DIV class="source-footer-wrap source-or-target-footer"&gt;&lt;DIV class="character-count tlid-character-count"&gt;&lt;SPAN style="font-family: inherit;"&gt;Exactly, it worked, thank you very much.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 15 Jul 2020 14:12:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9636925#M11065</guid>
      <dc:creator>diegoverciano85</dc:creator>
      <dc:date>2020-07-15T14:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE MACRO TO IMPORT STOCK MODEL</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9636943#M11066</link>
      <description>&lt;P&gt;Great! you figured out the error? What was it?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 14:14:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9636943#M11066</guid>
      <dc:creator>TK.421</dc:creator>
      <dc:date>2020-07-15T14:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE MACRO TO IMPORT STOCK MODEL</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9636947#M11067</link>
      <description>&lt;P&gt;I had edited the wrong way. Then I saw the error and fixed it and then it worked. So I edited the response where it said it was wrong to correct. To import the chosen file as a stock model should I insert a command in the macro?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 14:16:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9636947#M11067</guid>
      <dc:creator>diegoverciano85</dc:creator>
      <dc:date>2020-07-15T14:16:47Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE MACRO TO IMPORT STOCK MODEL</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9637028#M11068</link>
      <description>&lt;P&gt;sorry, yes. put this at the end of your macro:&lt;/P&gt;
&lt;DIV style="color: #ffffff; background-color: #000000; font-family: Consolas, 'Courier New', monospace; font-weight: normal; font-size: 14px; line-height: 19px; white-space: pre;"&gt;
&lt;DIV&gt;&lt;SPAN style="color: #9cdcfe;"&gt;IMPORT&lt;/SPAN&gt;&lt;SPAN style="color: #ffffff;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;STOCKMODEL&lt;/SPAN&gt;&lt;SPAN style="color: #ffffff;"&gt;&amp;nbsp;${$&lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;stockFiles&lt;/SPAN&gt;&lt;SPAN style="color: #ffffff;"&gt;[$&lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;C&lt;/SPAN&gt;&lt;SPAN style="color: #ffffff;"&gt;]}&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 14:39:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9637028#M11068</guid>
      <dc:creator>TK.421</dc:creator>
      <dc:date>2020-07-15T14:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE MACRO TO IMPORT STOCK MODEL</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9637589#M11069</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3976796"&gt;@TK.421&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now testing the macro at work, I report the following problem. In the list that is created after typing, for example, 1404, I chose the fourth item in this list, but accepting it does not matter this item, but the fourth file in the folder in question (in alphabetical order).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached image with the reported error&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 19:09:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9637589#M11069</guid>
      <dc:creator>diegoverciano85</dc:creator>
      <dc:date>2020-07-15T19:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE MACRO TO IMPORT STOCK MODEL</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9637594#M11070</link>
      <description>&lt;P&gt;Yes, I see the error in my logic. Give me a few minutes to fix it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 19:14:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9637594#M11070</guid>
      <dc:creator>TK.421</dc:creator>
      <dc:date>2020-07-15T19:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE MACRO TO IMPORT STOCK MODEL</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9637618#M11071</link>
      <description>&lt;P&gt;ok, try this. I cleaned it up a little and added some better comments for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;//---------- initialize variables: ---------//
// -the filepath of the stock model folder  //
// -a list of all the .stkmd files only     //
// -the file name prefix                    //
// -declare empty variable to hold the path //
//------------------------------------------//
STRING filePath = "C:/Users/David/Desktop/test"
STRING LIST $stockFiles = list_files('files', $filePath, '.stkmd')
STRING fileName = INPUT "Enter File Name"
STRING stockModelPath = ""

// create a new list for only the 
// names with the input prefix
STRING LIST stockNames = {}

// loop through the directory and add 
// those to the list 
FOREACH file IN stockFiles {
	// if the name contains the prefix, add
	// it to the list
	IF position(file, fileName) &amp;gt; -1 {
        	INT $Ok = add_last(stockNames, TOKENS(file, "/")[SIZE(TOKENS(file, "/"))-1])
	}
}

// display desired in pulldown list
INT i = INPUT CHOICE $stockNames "Select Stock File"

// create the file path for the 
// selected stock model
$stockModelPath = $filePath + "/" + $stockNames[$i]

// import the stock model
IMPORT STOCKMODEL $stockModelPath&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 15 Jul 2020 19:27:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9637618#M11071</guid>
      <dc:creator>TK.421</dc:creator>
      <dc:date>2020-07-15T19:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE MACRO TO IMPORT STOCK MODEL</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9637677#M11072</link>
      <description>&lt;P&gt;Now it's perfect. You are awesome. Thank you very much.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 20:00:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9637677#M11072</guid>
      <dc:creator>diegoverciano85</dc:creator>
      <dc:date>2020-07-15T20:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE MACRO TO IMPORT STOCK MODEL</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9637679#M11073</link>
      <description>&lt;P&gt;great! sorry I messed up earlier, I should've paid more attention when I was testing it.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 20:01:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9637679#M11073</guid>
      <dc:creator>TK.421</dc:creator>
      <dc:date>2020-07-15T20:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE MACRO TO IMPORT STOCK MODEL</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9637741#M11074</link>
      <description>&lt;P&gt;Don't worry, your willingness to help those who are not easy with macros is the most important.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 20:43:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/create-macro-to-import-stock-model/m-p/9637741#M11074</guid>
      <dc:creator>diegoverciano85</dc:creator>
      <dc:date>2020-07-15T20:43:25Z</dc:date>
    </item>
  </channel>
</rss>

