<?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 Macro/Script Assistance in PowerMill Forum</title>
    <link>https://forums.autodesk.com/t5/powermill-forum/macro-script-assistance/m-p/8284074#M19039</link>
    <description>&lt;P&gt;I am&amp;nbsp; really struggling in setting up a macro (if it is even possible) for this particular application.&amp;nbsp; Within a project I am wanting to rename toolpaths/folders/workplanes etc by replacing part of the name with alternative text.&amp;nbsp; Basically on the attached image I am wanting to replace anywhere in the project where the is the text "0001_AD" with something else that will be defined by the user with an input box&amp;nbsp;eg. "0003_AD".&amp;nbsp; The initial text "0001_AD" will be different in every instance, I was thinking that another user input box could be used to define the text that is to be replaced.&amp;nbsp; Apologies this is not that easy to explain.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically I am looking for -&lt;/P&gt;&lt;P&gt;- A popup user input box for the user to define the text they are wanting to replace (0001_AD).&lt;/P&gt;&lt;P&gt;- Then anywhere this text is featured in the project whether it be toolpath/folder/tool/workplane it is replaced with another item of text to be defined with a user input box.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have no idea if this in any way possible and was hoping someone out there may be doing something similar already.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Sep 2018 12:49:20 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-09-21T12:49:20Z</dc:date>
    <item>
      <title>Macro/Script Assistance</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-script-assistance/m-p/8284074#M19039</link>
      <description>&lt;P&gt;I am&amp;nbsp; really struggling in setting up a macro (if it is even possible) for this particular application.&amp;nbsp; Within a project I am wanting to rename toolpaths/folders/workplanes etc by replacing part of the name with alternative text.&amp;nbsp; Basically on the attached image I am wanting to replace anywhere in the project where the is the text "0001_AD" with something else that will be defined by the user with an input box&amp;nbsp;eg. "0003_AD".&amp;nbsp; The initial text "0001_AD" will be different in every instance, I was thinking that another user input box could be used to define the text that is to be replaced.&amp;nbsp; Apologies this is not that easy to explain.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically I am looking for -&lt;/P&gt;&lt;P&gt;- A popup user input box for the user to define the text they are wanting to replace (0001_AD).&lt;/P&gt;&lt;P&gt;- Then anywhere this text is featured in the project whether it be toolpath/folder/tool/workplane it is replaced with another item of text to be defined with a user input box.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have no idea if this in any way possible and was hoping someone out there may be doing something similar already.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 12:49:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-script-assistance/m-p/8284074#M19039</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-21T12:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: Macro/Script Assistance</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-script-assistance/m-p/8284915#M19040</link>
      <description>&lt;P&gt;you can try the below code.&amp;nbsp;&amp;nbsp; Copy and paste code for patterns, workplanes, whatever.&amp;nbsp; this should do what you want, let me know if it doesnt&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;reset localvars

//set text to replace and new text
STRING oldText = INPUT "Enter Text to Search"
STRING newText = INPUT "Enter Replacement Text"

//loop through toolpath folders
STRING LIST tpFolders = get_folders('Toolpath')
FOREACH fld IN tpFolders {
	IF position(fld, oldText) &amp;gt;= 0 {
		STRING nameOnly = replace(fld, "Toolpath\", "")
		STRING newName = replace(nameOnly, oldText, newText)
		RENAME FOLDER $fld  $newName
	}
}

//loop through toolpaths
FOREACH tp IN Folder ('Toolpath') {
	IF position(tp.name, oldText) &amp;gt;= 0 {
		STRING newName = replace(tp.name, oldText, newText)
		RENAME TOOLPATH $tp.name $newName
	}
}

//loop through boundary folders
STRING LIST bnFolders = get_folders('Boundary')
FOREACH fld IN bnFolders {
	IF position(fld, oldText) &amp;gt;= 0 {
		STRING nameOnly = replace(fld, "Boundary\", "")
		STRING newName = replace(nameOnly, oldText, newText)
		RENAME FOLDER $fld  $newName
	}
}

//loop through boundaries
FOREACH bn IN Folder ('Boundary') {
	IF position(bn.name, oldText) &amp;gt;= 0 {
		STRING newName = replace(bn.name, oldText, newText)
		RENAME TOOLPATH $bn.name $newName
	}
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 18:08:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-script-assistance/m-p/8284915#M19040</guid>
      <dc:creator>TK.421</dc:creator>
      <dc:date>2018-09-21T18:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: Macro/Script Assistance</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-script-assistance/m-p/8287493#M19041</link>
      <description>&lt;P&gt;Works an absolute treat.&amp;nbsp; Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2018 07:55:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-script-assistance/m-p/8287493#M19041</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-24T07:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: Macro/Script Assistance</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-script-assistance/m-p/8288537#M19042</link>
      <description>&lt;P&gt;ok, so another quick question, am I able to search as above for only folders named the exact search value.&amp;nbsp; For example, search for "_0001_AD" and only replace the name of folders called this exact name only,&amp;nbsp;as opposed to any folders that have that anywhere in the name eg&amp;nbsp; it would ignore a folder called "xyz_0001_AD"&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried replacing the &amp;gt;= with == and this wasn't the quick fix I was hoping for!&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2018 15:45:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-script-assistance/m-p/8288537#M19042</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-24T15:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro/Script Assistance</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-script-assistance/m-p/8288636#M19043</link>
      <description>&lt;P&gt;I am sorry it isnt working as expected. Are you sure you copied the code exactly? I ask because I tested it with such a case as you're describing before I posted it. As you can see in the screen shots below, I have it working for me. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could I be misunderstanding you?&lt;/P&gt;
&lt;P&gt;Could you post a screen shot of your folders?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 232px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/549726iA9507C553BC07724/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture1.PNG" style="width: 562px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/549727iF3985506D13EBA58/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture1.PNG" alt="Capture1.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture2.PNG" style="width: 472px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/549729i7C128C436EECE55E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture2.PNG" alt="Capture2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture3.PNG" style="width: 233px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/549728i7EE5E2A93815F065/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture3.PNG" alt="Capture3.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2018 16:19:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-script-assistance/m-p/8288636#M19043</guid>
      <dc:creator>TK.421</dc:creator>
      <dc:date>2018-09-24T16:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: Macro/Script Assistance</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-script-assistance/m-p/8288653#M19044</link>
      <description>&lt;P&gt;It is working as I asked in the first post but since then I have tried to move it on slightly.&lt;/P&gt;&lt;P&gt;In a project I may have multiple toolpath folders -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"0001_AD"&lt;/P&gt;&lt;P&gt;"0001_AD_xyz"&lt;/P&gt;&lt;P&gt;"0001_AD_dog"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the macro to search for "0001_AD" and only replace the name of the folder that has that exact same name, thus ignoring the folders "0001_AD_xyz" and "0001_AD_dog".&amp;nbsp; At present it replaces the "0001_AD" part in any folder name where it sees it (which is what I originally asked for but not what I am trying to do now).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that makes sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2018 16:25:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-script-assistance/m-p/8288653#M19044</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-24T16:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: Macro/Script Assistance</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-script-assistance/m-p/8288683#M19045</link>
      <description>&lt;P&gt;so i did misunderstand your post! try the code below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;reset localvars

//set text to replace and new text
STRING oldText = INPUT "Enter Text to Search"
STRING newText = INPUT "Enter Replacement Text"

//loop through toolpath folders
STRING LIST tpFolders = get_folders('Toolpath')
FOREACH fld IN tpFolders {
	STRING nameOnly = replace(fld, "Toolpath\", "")
	IF $nameOnly == $oldText {		
		RENAME FOLDER $fld  $newText
	}
}&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Sep 2018 16:36:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-script-assistance/m-p/8288683#M19045</guid>
      <dc:creator>TK.421</dc:creator>
      <dc:date>2018-09-24T16:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: Macro/Script Assistance</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-script-assistance/m-p/8289161#M19046</link>
      <description>&lt;P&gt;is this working for you now?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2018 19:40:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-script-assistance/m-p/8289161#M19046</guid>
      <dc:creator>TK.421</dc:creator>
      <dc:date>2018-09-24T19:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: Macro/Script Assistance</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/macro-script-assistance/m-p/8290267#M19047</link>
      <description>&lt;P&gt;Yes it works exactly as I wanted, thanky you, you have been most helpful&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2018 08:51:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/macro-script-assistance/m-p/8290267#M19047</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-25T08:51:12Z</dc:date>
    </item>
  </channel>
</rss>

