<?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 Multiple Entity Export Macro in PowerMill Forum</title>
    <link>https://forums.autodesk.com/t5/powermill-forum/multiple-entity-export-macro/m-p/12777687#M1760</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14304290" target="_blank" rel="noopener"&gt;@icse&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;I'd like to add models to the Export macro but I get an error at line 146, could you help?&lt;/P&gt;&lt;P&gt;Appreciated!&lt;/P&gt;&lt;P&gt;So I deleted the rogue }&lt;/P&gt;&lt;P&gt;Well spotted by the way!&lt;/P&gt;&lt;P&gt;And this now fires ok.&lt;/P&gt;&lt;P&gt;I now get all sorts of errors from the Import macro??&lt;/P&gt;&lt;P&gt;But it does run through and import the entities.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;bool $query = 0
$query = query "Import Entities?"
if not $query {
	return
}

string $path = "C:/Temp/EntityExport"

if not dir_exists($path) {
	message warn "Project not found"
	macro abort
}

if length(project_pathname(0)) == 0 OR project_modified() == 1 {
	
	bool $save = 0
	$save = query 'Save?'
	
	if $save {
		project save
	} else { 
		macro abort
	}
}

PROJECT IMPORT PROJSELECTOR $path&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 16 May 2024 12:31:10 GMT</pubDate>
    <dc:creator>evo80</dc:creator>
    <dc:date>2024-05-16T12:31:10Z</dc:date>
    <item>
      <title>Multiple Entity Export Macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/multiple-entity-export-macro/m-p/12777687#M1760</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14304290" target="_blank" rel="noopener"&gt;@icse&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;I'd like to add models to the Export macro but I get an error at line 146, could you help?&lt;/P&gt;&lt;P&gt;Appreciated!&lt;/P&gt;&lt;P&gt;So I deleted the rogue }&lt;/P&gt;&lt;P&gt;Well spotted by the way!&lt;/P&gt;&lt;P&gt;And this now fires ok.&lt;/P&gt;&lt;P&gt;I now get all sorts of errors from the Import macro??&lt;/P&gt;&lt;P&gt;But it does run through and import the entities.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;bool $query = 0
$query = query "Import Entities?"
if not $query {
	return
}

string $path = "C:/Temp/EntityExport"

if not dir_exists($path) {
	message warn "Project not found"
	macro abort
}

if length(project_pathname(0)) == 0 OR project_modified() == 1 {
	
	bool $save = 0
	$save = query 'Save?'
	
	if $save {
		project save
	} else { 
		macro abort
	}
}

PROJECT IMPORT PROJSELECTOR $path&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 12:31:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/multiple-entity-export-macro/m-p/12777687#M1760</guid>
      <dc:creator>evo80</dc:creator>
      <dc:date>2024-05-16T12:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Entity Export Macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/multiple-entity-export-macro/m-p/12777875#M1761</link>
      <description>&lt;P&gt;Ok,&lt;/P&gt;&lt;P&gt;Simply turned ERRORS OFF.&lt;/P&gt;&lt;P&gt;Hmmm, that just brings in an empty model.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 14:06:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/multiple-entity-export-macro/m-p/12777875#M1761</guid>
      <dc:creator>evo80</dc:creator>
      <dc:date>2024-05-16T14:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Entity Export Macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/multiple-entity-export-macro/m-p/12777992#M1762</link>
      <description>&lt;P&gt;There was another error not only the missing {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think you also need to copy the .pmlmz file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;if length(project_pathname(0)) == 0 OR project_modified() == 1 {
	message warn 'Save First'
	return
}

string $path = "C:/Temp/EntityExport"

if dir_exists($path) {
	bool $query = 0
	$query = query "Replace existing Entities?"
	if $query {
		delete directory $path
	} else {
		return
	}
}
string list $inputTypes = {'toolpath','tool','boundary','pattern','featureset','workplane','model'}
int list $indexer = input choice multiple $inputTypes 'Choose Type of Entity to Export'


entity list $entitiesToExport = {}

foreach $index in $indexer {
	
	entity list $entities = {}
	
	SWITCH $index {	
		Case 0
			$entities = input entity multiple toolpath 'Select Toolpaths to Export'
			Break
		Case 1
			$entities = input entity multiple tool 'Select Tools to Export'
			Break
		Case 2
			$entities = input entity multiple boundary 'Select Boundaries to Export'
			Break
		Case 3
			$entities = input entity multiple pattern 'Select Patterns to Export'
			Break
		Case 4
			$entities = input entity multiple featureset 'Select Featuresets to Export'
			Break
		Case 5
			$entities = input entity multiple workplane 'Select Workplanes to Export'
			Break
		Case 6
			$entities = input entity multiple model 'Select Models to Export'
			Break
		DEFAULT
			return
			BREAK
		}		
	foreach $ent in $entities {
		int $i = add_last($entitiesToExport, $ent)
	}
}


mkdir $path

//Active entity file
string $activeEntityFilePath = $path + '/active_entity.pmldat'
string $op = '0 1 # Active Entities (DO NOT EDIT!)'

if file_exists($activeEntityFilePath) {
	delete File $activeEntityFilePath
}
file open $activeEntityFilePath for write as output
file write $op to output
file close output

int $entCount = 0
string $content = ''
foreach $e in $entitiesToExport {

	if entity_exists($e) {	
		
		if $e.RootType == 'toolpath' {
		
			string $eHash = "x" + $e.ID + ".pmlent"
			string $e_full = project_pathname(0) + "/" + $eHash
			string $path_full = $path + "/" + $eHash
			if not file_exists($path_full) {
				$entCount = $entCount + 1
				$content = $content + $eHash + " pmlEntToolpath '" + $e.Name + "'" + CRLF
			}
			copy file $e_full $path_full
		
			$eHash = "x" + $e.ID + ".pmlgeom"
			$e_full = project_pathname(0) + "/" + $eHash
			$path_full = $path + "/" + $eHash
			copy file $e_full $path_full
			
			if entity_exists($e.Boundary) {
				$eHash = "x" + $e.Boundary.ID + ".pmlent"
				$e_full = project_pathname(0) + "/" + $eHash
				$path_full = $path + "/" + $eHash
				if not file_exists($path_full) {
					$entCount = $entCount + 1
					$content = $content + $eHash + " pmlEntBoundary '" + $e.Boundary.Name + "'" + CRLF
				}				
				copy file $e_full $path_full
			}
			if entity_exists($e.Pattern) {
				$eHash = "x" + $e.Pattern.ID + ".pmlent"
				$e_full = project_pathname(0) + "/" + $eHash
				$path_full = $path + "/" + $eHash
				if not file_exists($path_full) {
					$entCount = $entCount + 1
					$content = $content + $eHash + " pmlEntPattern '" + $e.Pattern.Name + "'" + CRLF
				}
				copy file $e_full $path_full
			}
			if entity_exists($e.Tool) {
				$eHash = "x" + $e.Tool.ID + ".pmlent"
				$e_full = project_pathname(0) + "/" + $eHash
				$path_full = $path + "/" + $eHash
				if not file_exists($path_full) {
					$entCount = $entCount + 1
					$content = $content + $eHash + " pmlEntTool '" + $e.Tool.Name + "'" + CRLF
				}
				copy file $e_full $path_full
			}
			if entity_exists($e.Workplane) {
				$eHash = "x" + $e.Workplane.ID + ".pmlent"
				$e_full = project_pathname(0) + "/" + $eHash
				$path_full = $path + "/" + $eHash
				if not file_exists($path_full) {
					$entCount = $entCount + 1
					$content = $content + $eHash + " pmlEntWorkplane '" + $e.Workplane.Name + "'" + CRLF
				}
				copy file $e_full $path_full
			}
			if entity_exists($e.Featureset) {
				$eHash = "x" + $e.Featureset.ID + ".pmlent"
				$e_full = project_pathname(0) + "/" + $eHash
				$path_full = $path + "/" + $eHash
				if not file_exists($path_full) {
					$entCount = $entCount + 1
					$content = $content + $eHash + " pmlEntFeature '" + $e.Featureset.Name + "'" + CRLF
				}
				copy file $e_full $path_full
			}			
			if entity_exists($e.Model) {
				$eHash = "x" + $e.Model.ID + ".pmlent"
				$e_full = project_pathname(0) + "/" + $eHash
				$path_full = $path + "/" + $eHash
				if not file_exists($path_full) {
					$entCount = $entCount + 1
					$content = $content + $eHash + " pmlEntModel '" + $e.Model.Name + "'" + CRLF
				}
				copy file $e_full $path_full
			}
			continue
		}					
		if $e.RootType == 'boundary' {
			string $eHash = "x" + $e.Boundary.ID + ".pmlent"
			string $e_full = project_pathname(0) + "/" + $eHash
			string $path_full = $path + "/" + $eHash
			if not file_exists($path_full) {
				$entCount = $entCount + 1
				$content = $content + $eHash + " pmlEntBoundary '" + $e.Name + "'" + CRLF
			}				
			copy file $e_full $path_full
			continue
		}
		if $e.RootType == 'pattern' {
			string $eHash = "x" + $e.Pattern.ID + ".pmlent"
			string $e_full = project_pathname(0) + "/" + $eHash
			string $path_full = $path + "/" + $eHash
			if not file_exists($path_full) {
				$entCount = $entCount + 1
				$content = $content + $eHash + " pmlEntPattern '" + $e.Name + "'" + CRLF
			}
			copy file $e_full $path_full
			continue
		}
		if $e.RootType == 'tool' {
			string $eHash = "x" + $e.Tool.ID + ".pmlent"
			string $e_full = project_pathname(0) + "/" + $eHash
			string $path_full = $path + "/" + $eHash
			if not file_exists($path_full) {
				$entCount = $entCount + 1
				$content = $content + $eHash + " pmlEntTool '" + $e.Name + "'" + CRLF
			}
			copy file $e_full $path_full
			continue
		}
		if $e.RootType == 'workplane' {
			string $eHash = "x" + $e.Workplane.ID + ".pmlent"
			string $e_full = project_pathname(0) + "/" + $eHash
			string $path_full = $path + "/" + $eHash
			if not file_exists($path_full) {
				$entCount = $entCount + 1
				$content = $content + $eHash + " pmlEntWorkplane '" + $e.Name + "'" + CRLF
			}
			copy file $e_full $path_full
			continue
		}
		if $e.RootType == 'featureset' {
			string $eHash = "x" + $e.Featureset.ID + ".pmlent"
			string $e_full = project_pathname(0) + "/" + $eHash
			string $path_full = $path + "/" + $eHash
			if not file_exists($path_full) {
				$entCount = $entCount + 1
				$content = $content + $eHash + " pmlEntFeature '" + $e.Name + "'" + CRLF
			}
			copy file $e_full $path_full
			continue
		}
		if $e.RootType == 'model' {
			string $eHash = "x" + $e.model.ID + ".pmlent"
			string $e_full = project_pathname(0) + "/" + $eHash
			string $path_full = $path + "/" + $eHash
			if not file_exists($path_full) {
				$entCount = $entCount + 1
				$content = $content + $eHash + " pmlEntModel '" + $e.Name + "'" + CRLF
			}
			copy file $e_full $path_full
			
			$eHash = "x" + $e.model.ID + ".pmlmz"
			$e_full = project_pathname(0) + "/" + $eHash
			$path_full = $path + "/" + $eHash
			
			copy file $e_full $path_full
			
			continue
		}
		
	}
}


if file_exists($activeEntityFilePath) {
	delete File $activeEntityFilePath
}
file open $activeEntityFilePath for write as output
file write $op to output
file close output




string $proj_name = "\" + project_pathname(1) + ".pmlprj"
string $path_full = project_pathname(0) + $proj_name
file open $path_full for read as input

string $line1 = ''
string $line2 = ''
string $line3 = ''

file read $line1 from input
file read $line2 from input
file read $line3 from input

file close input

$line1 = $entCount + substring($line1, position($line1, ' ', 0), length($line1))
string $dest_path_full = $path + $proj_name
file open $dest_path_full FOR WRITE AS output
file write $line1 to "output"
file write $line2 to "output"
file write $line3 to "output"
file write $content to "output"
file close output&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 16 May 2024 14:21:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/multiple-entity-export-macro/m-p/12777992#M1762</guid>
      <dc:creator>icse</dc:creator>
      <dc:date>2024-05-16T14:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Entity Export Macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/multiple-entity-export-macro/m-p/12778099#M1763</link>
      <description>&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;That works a treat.&lt;/P&gt;&lt;P&gt;Just a question, why do models need that&amp;nbsp;&lt;SPAN&gt;.pmlmz file to work?&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 14:57:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/multiple-entity-export-macro/m-p/12778099#M1763</guid>
      <dc:creator>evo80</dc:creator>
      <dc:date>2024-05-16T14:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Entity Export Macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/multiple-entity-export-macro/m-p/12778119#M1764</link>
      <description>&lt;P&gt;I dont know why,&lt;/P&gt;&lt;P&gt;toolpath's also need an additional file (.pmlgeom)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 15:06:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/multiple-entity-export-macro/m-p/12778119#M1764</guid>
      <dc:creator>icse</dc:creator>
      <dc:date>2024-05-16T15:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Entity Export Macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/multiple-entity-export-macro/m-p/12778134#M1765</link>
      <description>&lt;P&gt;Yes, I noticed that ext. was different to the others.&lt;/P&gt;&lt;P&gt;Thanks for the help once again!&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 15:14:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/multiple-entity-export-macro/m-p/12778134#M1765</guid>
      <dc:creator>evo80</dc:creator>
      <dc:date>2024-05-16T15:14:29Z</dc:date>
    </item>
  </channel>
</rss>

