<?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: Export model macro in PowerMill Forum</title>
    <link>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11496350#M5256</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4385145"&gt;@artur.boszczyk&lt;/a&gt;&amp;nbsp;&amp;nbsp;Powermill macros are intended to automate processes and reduce the amount of clicks that a user has to make while working, as well as extend it's functionality a tad bit. Writing a small macro to automatically export multiple models to the same location as the project while also renaming them is a perfectly reasonable goal for a macro.&lt;BR /&gt;&lt;BR /&gt;Now, if I was actually using the API, and not the macro language then I would probably not be creating an application solely to export models in this fashion.&lt;/P&gt;</description>
    <pubDate>Thu, 20 Oct 2022 14:06:18 GMT</pubDate>
    <dc:creator>Sean571</dc:creator>
    <dc:date>2022-10-20T14:06:18Z</dc:date>
    <item>
      <title>Export model macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11494088#M5248</link>
      <description>&lt;P&gt;I am working on a macro that exports a model from a list to my project directory.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 problem I have is it does not export the model I selected from the list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;ENTITY LIST $Selected_Model = INPUT ENTITY MULTIPLE MODEL "Select Models For Export"

FOREACH Mod IN $Selected_Model {
STRING projName = project_pathname (0) 
STRING $savePath = $projName + ".dgk"
IF dir_exists ($savePath) { 
MESSAGE WARN "Project with this path already exists" + crlf + $savePath 
RETURN 
} 
STRING $com = "EXPORT MODEL $Selected_Model FILESAVE '" + $savePath + "'" 
DOCOMMAND $com&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I replace line 10 with&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;STRING $com = "EXPORT MODEL ALL FILESAVE '" + $savePath + "'"&lt;/LI-CODE&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;it works but it does every model I have in the project.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;What do I need to get the selected model from the list?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Problem #2 is when it does export all the models it uses my Powermill project name as the model name. I would like it to use the actual model name listed inside Powermill.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 17:09:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11494088#M5248</guid>
      <dc:creator>iamcdn79</dc:creator>
      <dc:date>2022-10-19T17:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Export model macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11494135#M5249</link>
      <description>&lt;LI-CODE lang="general"&gt;    // Reset any local variables
    reset localvars

    // Variables
    string $prompt = ""
    real $exportTolerence = 0
    bool err = 0    
    string saveFolder = INPUT "Enter Directory path to Export Models:"
    string saveFilePath = ""

    // Save original export tolerence
    real originalExportTolerence = $powermill.Export.TriangleTolerance

    // SET TO WORLD COORIDATES
    DEACTIVATE Workplane

    FOREACH mod IN folder('model') {
        $prompt = "Export Tolerence for " + $mod.name
        
        // Error checking on export tolerence
        DO {
            $exportTolerence = INPUT $prompt
            $err = ERROR $exportTolerence
            IF $err {
                MESSAGE ERROR "Input not a number! Try again."
            }
        } WHILE $err == true
        
        // Set tolerence
        EDIT PAR Powermill.Export.TriangleTolerance $exportTolerence

        // build export file path
        $saveFilePath = $saveFolder + $mod.name + ".dmt"
        DELETE FILE $saveFilePath
        EXPORT MODEL $mod.name $saveFilePath
 
    }&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Here is a different macro I made for exporting models. Maybe this can help you.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 17:28:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11494135#M5249</guid>
      <dc:creator>Sean571</dc:creator>
      <dc:date>2022-10-19T17:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Export model macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11494174#M5250</link>
      <description>&lt;P&gt;Thanks Sean,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After tweaking your macro it's a little bit better but I still can't get the selected model to export, it writes out every model in the project and now it combines the project name and model name as the export filename.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;// Reset any local variables
    reset localvars

    // Variables
    string $prompt = ""
    real $exportTolerence = 0
    bool err = 0    
    string saveFolder = project_pathname (0) 
    string saveFilePath = ""
ENTITY LIST $Selected_Model = INPUT ENTITY MULTIPLE MODEL "Select Models For Export"
    // Save original export tolerence
    real originalExportTolerence = $powermill.Export.TriangleTolerance

    // SET TO WORLD COORIDATES
    DEACTIVATE Workplane

    FOREACH mod IN folder('model') {
       // $prompt = "Export Tolerence for " + $mod.name
        
        // Error checking on export tolerence
        // DO {
        //     $exportTolerence = INPUT $prompt
        //     $err = ERROR $exportTolerence
        //     IF $err {
        //         MESSAGE ERROR "Input not a number! Try again."
        //     }
        // } WHILE $err == true
        
        // Set tolerence
        EDIT PAR Powermill.Export.TriangleTolerance $exportTolerence

        // build export file path
        $saveFilePath = $saveFolder + $mod.name + ".dgk"
        DELETE FILE $saveFilePath
        EXPORT MODEL $mod.name $saveFilePath
 
    }&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 19 Oct 2022 17:48:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11494174#M5250</guid>
      <dc:creator>iamcdn79</dc:creator>
      <dc:date>2022-10-19T17:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: Export model macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11494611#M5251</link>
      <description>&lt;P&gt;You should be doing that foreach loop with the list of selected models, not with all the models and that should work for you.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// Reset any local variables
reset localvars

// Variables
string saveFolder = project_pathname (0) 
string saveFilePath = ""
ENTITY LIST $Selected_Model = INPUT ENTITY MULTIPLE MODEL "Select Models For Export"

// SET TO WORLD COORIDATES
DEACTIVATE Workplane

FOREACH mod IN $Selected_Model {
    // build export file path
    $saveFilePath = $saveFolder + $mod.name + ".dgk"
    DELETE FILE $saveFilePath
    EXPORT MODEL $mod.name $saveFilePath
}&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 19 Oct 2022 21:27:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11494611#M5251</guid>
      <dc:creator>Sean571</dc:creator>
      <dc:date>2022-10-19T21:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Export model macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11495349#M5252</link>
      <description>&lt;P&gt;why do waste your time building something which already exists in PowerMill??? Surely you know how to export models using PowerMill interface without using API&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Use API to extend the functionality of the PowerMill and then share it with all people over here.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 07:08:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11495349#M5252</guid>
      <dc:creator>artur.boszczyk</dc:creator>
      <dc:date>2022-10-20T07:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: Export model macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11495918#M5253</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to develop a macro that is going to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Export&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;as&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;"Autodesk Geometry(*.dgk)"&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;AND&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;"Autodesk Geometry + Features (*.dgk)"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;a selected component (or model).&lt;/P&gt;&lt;P&gt;The MAJOR PROBLEM is that i cannot get for each case the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Save as type&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;option.&lt;/P&gt;&lt;P&gt;I've recorded 2 seperate macros in order to export as (1st)&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;"Autodesk Geometry(*.dgk)"&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;and (2nd)&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;"Autodesk Geometry + Features (*.dgk)"&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;These to macros have exactly the same code.&lt;/P&gt;&lt;P&gt;Does anyone have any idea on how to get Save as type "value" for exporting as&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;"Autodesk Geometry + Features (*.dgk)"&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 11:31:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11495918#M5253</guid>
      <dc:creator>kmarkopouliotis</dc:creator>
      <dc:date>2022-10-20T11:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: Export model macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11495921#M5254</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;My purpose is to Export a selected Solid or Component in 4 formats [Save as type] :&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Parasolid(*.x_t)&lt;/LI&gt;&lt;LI&gt;Adobe Acrobat Document (*.pdf)&lt;/LI&gt;&lt;LI&gt;Autodesk Geometry (*.dgk)&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Autodesk Geometry + Features (*.dgk) [provides an *.xml with all features]&lt;/STRONG&gt;I want to Export Solid's/Component's Feature's in order to make use of the in PowerMill.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Does anyone have another option in order to export features ???&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 11:32:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11495921#M5254</guid>
      <dc:creator>kmarkopouliotis</dc:creator>
      <dc:date>2022-10-20T11:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Export model macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11495980#M5255</link>
      <description>&lt;P&gt;It exports the selected models from the list but it still adds the project name to the exported model name.&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-1666267255388.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1129791i49D1BFDD29B29BA6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="iamcdn79_0-1666267255388.png" alt="iamcdn79_0-1666267255388.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, it is missing a warning to say that the file\files exists, do you want to overwrite it?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 12:22:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11495980#M5255</guid>
      <dc:creator>iamcdn79</dc:creator>
      <dc:date>2022-10-20T12:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: Export model macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11496350#M5256</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4385145"&gt;@artur.boszczyk&lt;/a&gt;&amp;nbsp;&amp;nbsp;Powermill macros are intended to automate processes and reduce the amount of clicks that a user has to make while working, as well as extend it's functionality a tad bit. Writing a small macro to automatically export multiple models to the same location as the project while also renaming them is a perfectly reasonable goal for a macro.&lt;BR /&gt;&lt;BR /&gt;Now, if I was actually using the API, and not the macro language then I would probably not be creating an application solely to export models in this fashion.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 14:06:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11496350#M5256</guid>
      <dc:creator>Sean571</dc:creator>
      <dc:date>2022-10-20T14:06:18Z</dc:date>
    </item>
    <item>
      <title>Re: Export model macro</title>
      <link>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11516180#M5257</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3960527"&gt;@iamcdn79&lt;/a&gt;&amp;nbsp;, I have a macro that does a similar functionality to what you want. I hope it will be helpful to you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) It creates a folder in your PowerMill project (If not created already).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) It asks the user to choose whether to export some models from the list or export all of them. And, of course, it names the models according to their names in the PM project.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;// Checking if the project contain models or not
RESET LOCALVARS
ENTITY List currentModels = folder('model')
IF (is_empty(currentModels)) {
  MESSAGE ERROR "The models folder is empty!"
  MACRO ABORT
}


// Creating a folder to export models into
// and Changing the save Directory to it
STRING projectPath = project_pathname(0)
STRING exportedModelsFolder = $projectPath + "/Exported_Models"
IF (dir_exists($exportedModelsFolder)==0) {
  MKDIR $exportedModelsFolder
}
CD $exportedModelsFolder


// Choose the export mode (Selected models/All models)
ENTITY LIST modelsToExport = {}
STRING ARRAY modelsExportMode[] = {"Select models to export", "Export all models"}
INT exportMode = INPUT CHOICE $modelsExportMode "Select the export mode:"
SWITCH $exportMode {
  CASE 0
	// Select certain models to export
	$modelsToExport = INPUT ENTITY MULTIPLE model "Select models to export:"
	BREAK
  CASE 1
	// Select all models 
	$modelsToExport = folder('model')	
	BREAK
}


// Exporting models
FOREACH model IN modelsToExport {
	STRING modelToExport = $model.name		
	STRING modelSaveName = $modelToExport + ".dgk" // you may change ".dgk" to ".dmt" if needed

	// Checking if file already exists &amp;amp; requesting permession to overwrite
	IF (file_exists($modelSaveName)) {
		STRING queryMSG = "File (" + $modelSaveName + ") already exist, Overwite it?"
		BOOL queryAnswer = 0
		$queryAnswer = Query $queryMSG
		IF (queryAnswer==1) {
			DELETE FILE $modelSaveName
		} ELSE {
			CONTINUE
		}
	}
	EXPORT MODEL $modelToExport $modelSaveName
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6314535384112w1014h540r754" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6314535384112" data-account="6057940548001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6057940548001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6314535384112w1014h540r754');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://forums.autodesk.com/t5/video/gallerypage/video-id/6314535384112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2022 19:33:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/powermill-forum/export-model-macro/m-p/11516180#M5257</guid>
      <dc:creator>Y.Mahran</dc:creator>
      <dc:date>2022-10-28T19:33:28Z</dc:date>
    </item>
  </channel>
</rss>

