There was another error not only the missing {
I think you also need to copy the .pmlmz file
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