<?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: Move model to multiple workplanes macro in PowerMill Forum</title>
    <link>https://forums.autodesk.com/t5/powermill-forum/move-model-to-multiple-workplanes-macro/m-p/12840869#M1667</link>
    <description>&lt;P&gt;Sometimes powermill get stuck/behaves strange after you got some errors while debugging.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jun 2024 20:38:46 GMT</pubDate>
    <dc:creator>icse</dc:creator>
    <dc:date>2024-06-14T20:38:46Z</dc:date>
    <item>
      <title>Move model to multiple workplanes macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/move-model-to-multiple-workplanes-macro/m-p/12837091#M1662</link>
      <description>&lt;P&gt;I have an existing macro that I want to change to move the model to multiple workplane locations instead of just one that I currently have.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This macro works if I just select one workplane but if I select more than one it errors on line&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;ACTIVATE&lt;/SPAN&gt; &lt;SPAN&gt;WORKPLANE&lt;/SPAN&gt;&lt;SPAN&gt; $&lt;/SPAN&gt;&lt;SPAN&gt;wp&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Name&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;This is what I have currently&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;STRING yourworkplanename = "G54","G55","G56","G57","G58","G59"
IF ENTITY_EXISTS('workplane', $yourworkplanename) {
//Do Nothing
	} ELSE {
		GRAPHICS LOCK
      // 	CREATE WORKPLANE AT G54
MODE WORKPLANE_CREATE "G54" INTERACTIVE POINT
MODE COORDINPUT COORDINATES -6.0493 -14.5758 0
	
		// CREATE WORKPLANE AT G55
MODE WORKPLANE_CREATE "G55" INTERACTIVE POINT
MODE COORDINPUT COORDINATES -6.0493 -6.7024 0
 //CREATE WORKPLANE AT G56
MODE WORKPLANE_CREATE "G56" INTERACTIVE POINT
MODE COORDINPUT COORDINATES -15.8944 -14.5758 0

//CREATE WORKPLANE AT G57
MODE WORKPLANE_CREATE "G57" INTERACTIVE POINT
MODE COORDINPUT COORDINATES -15.8944 -6.7024 0

//CREATE WORKPLANE AT G58
MODE WORKPLANE_CREATE "G58" INTERACTIVE POINT
MODE COORDINPUT COORDINATES -25.3346 -12.3245 0

//CREATE WORKPLANE AT G59
MODE WORKPLANE_CREATE "G59" INTERACTIVE POINT
MODE COORDINPUT COORDINATES -25.3346 -7.4026 0

UNDRAW WORKPLANE ALL

GRAPHICS UNLOCK
    }
/ ENTITY LIST
ENTITY LIST $Model = INPUT ENTITY MODEL "Select Which Model To Copy To Fixture Offset"

STRING $Newmodel = new_entity_name('model')
STRING $folderFull = "Model\" + $Model.Name

// Allow selection of multiple workplanes
ENTITY LIST $wpNames = INPUT ENTITY MULTIPLE WORKPLANE "Select The Fixture Offsets To Move The Model To"

FOREACH wp IN $wpNames {
  // Activate current workplane
  ACTIVATE WORKPLANE $wp.Name &amp;lt;----- THIS LINE ERRORS ON ME WHEN NEEDING TO ACTIVATE SECOND SELECTED WORKPLANE FROM INPUT LIST

  // Store workplane name for later use
  STRING $currentWpName = $wp.Name 


  IF NOT folder_exists($folderFull) {
    CREATE FOLDER "Model" $Model.Name
  }
  ACTIVATE FOLDER $folderFull

  EDIT MODEL $Model.Name CLIPBOARD COPY
  CREATE MODEL CLIPBOARD
  TRANSFORM TYPE WORKPLANE TRANSFORM MODEL $Newmodel
  DEACTIVATE WORKPLANE

  // Unique naming based on model and workplane
  STRING $newName = $Model.Name + "_" + $currentWpName
  INT $i = 1
  WHILE ENTITY_EXISTS('model', $newName) {
    $newName = $newName + "_" + $i
    $i = $i + 1
  }
  RENAME MODEL $Newmodel $newName

  EDIT MODEL $newName SELECT ALL

  // Check if "Moved" level exists
 IF NOT ENTITY_EXISTS('level',"Moved Models to Fixture Offset") {
   CREATE LEVEL "Moved Models to Fixture Offset" Level
}
 EDIT LEVEL "Moved Models to Fixture Offset" ACQUIRE SELECTED
 DEACTIVATE FOLDER $folderFull
}
QUIT&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&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="iamcdn79_0-1718277360511.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1375434iE5658638C3CECE2A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="iamcdn79_0-1718277360511.png" alt="iamcdn79_0-1718277360511.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 11:16:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/move-model-to-multiple-workplanes-macro/m-p/12837091#M1662</guid>
      <dc:creator>iamcdn79</dc:creator>
      <dc:date>2024-06-13T11:16:36Z</dc:date>
    </item>
    <item>
      <title>Betreff: Move model to multiple workplanes macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/move-model-to-multiple-workplanes-macro/m-p/12838459#M1663</link>
      <description>&lt;P&gt;i currently dont have a powermill licence so i can't debug your code...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This lines confuses me, it looks like you try to create a list of string but the LIST keyword is missing so do the {}.&lt;/P&gt;&lt;P&gt;In your state the IF statement probably only checks the if the G54 Workplane exists(i guess the yourworkplane variable is just "G54")&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;STRING yourworkplanename = "G54","G55","G56","G57","G58","G59"
IF ENTITY_EXISTS('workplane', $yourworkplanename) {&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;next this,&lt;/P&gt;&lt;P&gt;first line misses one /&lt;/P&gt;&lt;P&gt;second got the list keyword but on the right side the MULTIPLE keyword is missing.&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;/ ENTITY LIST
ENTITY LIST $Model = INPUT ENTITY MODEL "Select Which Model To Copy To Fixture Offset"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for the line that errors you you could try to set the wp.Name into {} like this:&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;ACTIVATE WORKPLANE ${wp.Name}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hope this helps, can't do more atm sorry.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 20:37:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/move-model-to-multiple-workplanes-macro/m-p/12838459#M1663</guid>
      <dc:creator>icse</dc:creator>
      <dc:date>2024-06-13T20:37:15Z</dc:date>
    </item>
    <item>
      <title>Betreff: Move model to multiple workplanes macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/move-model-to-multiple-workplanes-macro/m-p/12838574#M1664</link>
      <description>&lt;P&gt;1) Ok good catch, made the necessary change to&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;STRING LIST yourworkplanenames = {"G54","G55","G56","G57","G58","G59"}

FOREACH wpname IN yourworkplanenames {
  IF ENTITY_EXISTS('workplane', $wpname) {
// ... rest of code ...
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) I missed highlighting the second / in the code&lt;/P&gt;&lt;P&gt;I only want to select one model instead of multiple&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;ACTIVATE WORKPLANE ${wp.Name}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;also errors when activating the second workplane&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="iamcdn79_0-1718314390320.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1375779i6B9FA9A75EC1E44A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="iamcdn79_0-1718314390320.png" alt="iamcdn79_0-1718314390320.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 21:36:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/move-model-to-multiple-workplanes-macro/m-p/12838574#M1664</guid>
      <dc:creator>iamcdn79</dc:creator>
      <dc:date>2024-06-13T21:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: Move model to multiple workplanes macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/move-model-to-multiple-workplanes-macro/m-p/12840726#M1665</link>
      <description>&lt;P&gt;Hmm I know it's not the syntax that is causing an error like this as a simplified foreach loop will work just fine if this is all that is in a macro:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// Allow selection of multiple workplanes
ENTITY LIST $wpNames = INPUT ENTITY MULTIPLE WORKPLANE "Select The Fixture Offsets To Move The Model To"

FOREACH wp IN $wpNames {
    // Activate current workplane
    ACTIVATE WORKPLANE $wp.Name
    message info $wp.Name
    deactivate workplane
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;So the only thing I that comes to mind is that something in your foreach loop is putting PowerMill into some type of error state or a state in which Activating a workplane isn't allowed. Might be similar to what happens when you try to save your project when you are in the curve editor. You'd get this error:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sean571_0-1718391600116.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1376242i787A159CA1C26CF9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sean571_0-1718391600116.png" alt="Sean571_0-1718391600116.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Can you repost the entire macro with all the changes you made, so I can test with what you have right now?&lt;BR /&gt;&lt;BR /&gt;Otherwise I'd be curious if you got the same error if you replaced your foreach loop with this loop instead-keeping all the other commands above it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;FOREACH wp IN $wpNames {
    // Activate current workplane
    ACTIVATE WORKPLANE $wp.Name
    message info $wp.Name
    deactivate workplane
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If you still get an error then we know that it's being caused by something that you are doing in the previous lines in the macro. If you don't get an error then we know that the issues is to do with something in the foreach loop.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2024 19:05:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/move-model-to-multiple-workplanes-macro/m-p/12840726#M1665</guid>
      <dc:creator>Sean571</dc:creator>
      <dc:date>2024-06-14T19:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: Move model to multiple workplanes macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/move-model-to-multiple-workplanes-macro/m-p/12840777#M1666</link>
      <description>&lt;P&gt;So I don't know what happened but this works for me now unless I had a messed up line that I didn't change after using&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14304290"&gt;@icse&lt;/a&gt;&amp;nbsp;recommendation&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;STRING LIST yourworkplanenames = {"G54","G55","G56","G57","G58","G59"}

FOREACH wpname IN yourworkplanenames {
  IF ENTITY_EXISTS('workplane', $wpname) {
//Do Nothing
	} ELSE {
		GRAPHICS LOCK
      // 	CREATE WORKPLANE AT G54
MODE WORKPLANE_CREATE "G54" INTERACTIVE POINT
MODE COORDINPUT COORDINATES -6.0493 -14.5758 0
	
		// CREATE WORKPLANE AT G55
MODE WORKPLANE_CREATE "G55" INTERACTIVE POINT
MODE COORDINPUT COORDINATES -6.0493 -6.7024 0
 //CREATE WORKPLANE AT G56
MODE WORKPLANE_CREATE "G56" INTERACTIVE POINT
MODE COORDINPUT COORDINATES -15.8944 -14.5758 0

//CREATE WORKPLANE AT G57
MODE WORKPLANE_CREATE "G57" INTERACTIVE POINT
MODE COORDINPUT COORDINATES -15.8944 -6.7024 0

//CREATE WORKPLANE AT G58
MODE WORKPLANE_CREATE "G58" INTERACTIVE POINT
MODE COORDINPUT COORDINATES -25.3346 -12.3245 0

//CREATE WORKPLANE AT G59
MODE WORKPLANE_CREATE "G59" INTERACTIVE POINT
MODE COORDINPUT COORDINATES -25.3346 -7.4026 0

UNDRAW WORKPLANE ALL

GRAPHICS UNLOCK
    }
}

// ENTITY LIST
ENTITY LIST $Model = INPUT ENTITY MODEL "Select Which Model To Copy To Fixture Offset"

STRING $Newmodel = new_entity_name('model')
STRING $folderFull = "Model\" + $Model.Name

// Allow selection of multiple workplanes
ENTITY LIST $wpNames = INPUT ENTITY MULTIPLE WORKPLANE "Select The Fixture Offsets To Move The Model To"

FOREACH wp IN $wpNames {
  // Activate current workplane
  ACTIVATE WORKPLANE ${wp.Name}

  // Store workplane name for later use
  STRING $currentWpName = $wp.Name


  IF NOT folder_exists($folderFull) {
    CREATE FOLDER "Model" $Model.Name
  }
  ACTIVATE FOLDER $folderFull

  EDIT MODEL $Model.Name CLIPBOARD COPY
  CREATE MODEL CLIPBOARD
  TRANSFORM TYPE WORKPLANE TRANSFORM MODEL $Newmodel
  DEACTIVATE WORKPLANE

  // Unique naming based on model and workplane
  STRING $newName = $Model.Name + "_" + $currentWpName
  INT $i = 1
  WHILE ENTITY_EXISTS('model', $newName) {
    $newName = $newName + "_" + $i
    $i = $i + 1
  }
  RENAME MODEL $Newmodel $newName

  EDIT MODEL $newName SELECT ALL

  // Check if "Moved" level exists
 IF NOT ENTITY_EXISTS('level',"Moved Models to Fixture Offset") {
   CREATE LEVEL "Moved Models to Fixture Offset" Level
}
}
EDIT LEVEL "Moved Models to Fixture Offset" ACQUIRE SELECTED
EDIT MODEL ALL DESELECT ALL

DEACTIVATE FOLDER $folderFull

QUIT
DEACTIVATE WORKPLANE $wpName
QUIT&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2024 19:53:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/move-model-to-multiple-workplanes-macro/m-p/12840777#M1666</guid>
      <dc:creator>iamcdn79</dc:creator>
      <dc:date>2024-06-14T19:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: Move model to multiple workplanes macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/move-model-to-multiple-workplanes-macro/m-p/12840869#M1667</link>
      <description>&lt;P&gt;Sometimes powermill get stuck/behaves strange after you got some errors while debugging.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2024 20:38:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/move-model-to-multiple-workplanes-macro/m-p/12840869#M1667</guid>
      <dc:creator>icse</dc:creator>
      <dc:date>2024-06-14T20:38:46Z</dc:date>
    </item>
  </channel>
</rss>

