#usage "Export PCB board to ecad.io (Create a 3D PCB for use in MCAD)\n" "

" "Author: ecadio@autodesk.com" int hor = 1; int ver = 1; string fileName; string userName; string password; string cfgToolName="ecadio"; string session; string productionAuthUrl="https://[user]:[password]@www.ecad.io"; //Base authorization url for production (used in api calls) string productionUrl="https://www.ecad.io"; //Base url for production string uploadUrl="/api/Upload/UploadEagle"; //URL for upload file api. Returns id of file uploaded if successful string showUrl="/PCB/ShowSession?session=[session]"; //URL for viewing the PCB in ecad.io. Session id corresponds to return from the upload call. string url=""; string Message; string fileText; string netResult; string fName; int nText; int agreeToS=0; int dialogAccepted=0; string termsAndConditionsHtml="\ \ Simple online ECAD to MCAD file conversion with ecad.io\ \ \ \

\

\ Simple online ECAD to MCAD file conversion with ecad.io
\

\

This tool uploads the active EAGLE board file to the ecad.io \ online Electrical to Mechanical CAD translation service. 

\

 

\

Once the file has been uploaded, you can view the board \ online in 3D, add detailed 3D component models if required, and then convert it \ to a STEP file. The STEP file can be sent directly to Autodesk Fusion 360, \ Autodesk A360 or downloaded for use with any other MCAD system that supports \ STEP.

\

 

\

Use of ecad.io requires registering for a free Autodesk user \ account, and acceptance of Autodesk’s terms of service.

\

 

\

For more information about ecad.io please visit the Resources \ section of the website at www.ecad.io.

\

 

\
\ "; string footerHtml=" \ \ \ \ "; string macFooterHtml=" \ \ \ \ "; //**************************************************FUNCTIONS*************************************************** int writeToFile(string fileName,string contents) { output(fileName,"wt") { printf(contents); } return 1; } int isWindows() { if(strstr(strupr(OS_SIGNATURE),"WINDOWS")>=0) { return 1; } return 0; } int isMac() { if(strstr(strupr(OS_SIGNATURE),"MAC")>=0) { return 1; } return 0; } int isLinux() { if(isWindows()==0 && isMac()==0) { return 1; } return 0; } int getWindowWidth() { if(isWindows()) { return 1000; } else if(isMac()) { return 400; } else { return 600; } } int getWindowHeight() { if(isWindows()) { return 700; } else if(isMac()) { return 300; } else { return 500; } } string getFooterHtml() { if(isWindows()) { return footerHtml; } else if(isMac()) { return macFooterHtml; } else return macFooterHtml; } string strReplace(string srcString,string toReplace, string replaceWith) { string curStr=srcString; int pos = strstr(curStr,toReplace); while(pos >= 0) { if(pos==0){ curStr=replaceWith + strsub(curStr,strlen(toReplace)); } else{ curStr=strsub(curStr,0,pos) + replaceWith + strsub(curStr,pos+strlen(toReplace)); } pos = strstr(curStr,toReplace); } return curStr; } string urlEncode(string strToEncode) { string retEncode=strToEncode; retEncode=strReplace(retEncode,"@","%40"); return retEncode; } string getAuthUrl(string userName, string password) { string retUrl=""; string encodedUserName=urlEncode(userName); string encodedPassword=urlEncode(password); string baseUrl=productionAuthUrl; retUrl=strReplace(baseUrl,"[user]",encodedUserName); retUrl=strReplace(retUrl,"[password]",encodedPassword); return retUrl; } string getUrl() { string retUrl=productionUrl; return retUrl; } string getUploadUrl(string userName, string password) { return getUrl()+uploadUrl; //return getAuthUrl(userName,password)+uploadUrl; } string getShowUrl(string session) { return getUrl()+strReplace(showUrl,"[session]",session); } string getBrowserCommand(string session) { string cmd=""; if(isWindows()){ cmd="explorer \"[url]\""; } else if (isLinux()){ cmd="xdg-open '[url]'"; } else{ cmd="open \"[url]\""; } return strReplace(cmd,"[url]",getShowUrl(session)); } string getValueFromKeyValueList(string list, string key, char listSeperator) { string keyVals[]; string curKeyVal[]; int noEntries=strsplit(keyVals,list,listSeperator); int noCurEntries=0; if(noEntries>0) { for(int i=0;i=2) { if(curKeyVal[0]==key) { return strReplace(keyVals[i],key + "=",""); } } } } return ""; } string getCfgValue(string name) { return cfgget(cfgToolName + "." + name); } void setCfgValue(string name,string value) { cfgset(cfgToolName + "." + name,value); } //************************************************************************************************************** //Save file if not already saved.. if(argv[1] != "saved") { if(dlgMessageBox("!The Document will be saved before exporting to ecad.io. Click 'OK' to continue and save the document","OK","Cancel")==1) { exit(0); } exit("write; run ecadio saved;"); } int Result = dlgDialog("EAGLE MCAD/ECAD Interface") { dlgVBoxLayout { dlgHBoxLayout dlgSpacing( getWindowWidth() ); dlgHBoxLayout{ dlgTextView(termsAndConditionsHtml); dlgVBoxLayout{ dlgSpacing(getWindowHeight()); } } } dlgVBoxLayout { dlgHBoxLayout dlgSpacing( getWindowWidth() ); dlgHBoxLayout { dlgCheckBox("", agreeToS) { } dlgLabel("I accept the Terms of Service"); dlgStretch(1); dlgPushButton("+OK") { if(agreeToS) { dialogAccepted=1; dlgAccept(); } else { dlgMessageBox("!You must agree to the terms of use to upload the PCB to ecad.io","OK"); } } dlgPushButton("Cancel") { dlgReject(); exit(0); } } dlgSpacing(20); dlgLabel(getFooterHtml()); } }; if(!agreeToS || !dialogAccepted) { exit(0); } board(B) { fName=B.name; } fileread(fileText, fName); fileText=filename(fName)+"|"+fileText; if (netpost(netResult,getUploadUrl(userName,password), fileText,100,"multipart/form-data;") >= 0) { // process Result session=getValueFromKeyValueList(netResult,"session",';'); system(getBrowserCommand(session)); } else dlgMessageBox(neterror());