I Tried the following C++ Code, which did not work.
Can you post a sample code that works in Fusion 360 please?
Thanks,
Thurai
#include <Core/CoreAll.h>
#include <Fusion/FusionAll.h>
#include <CAM/CAMAll.h>
#include <stdio.h>
#include <io.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
#include <assert.h>
#include <math.h>
#include <memory.h>
#include <errno.h>
//#include <iostream>
#include <complex>
using namespace adsk::core;
using namespace adsk::fusion;
using namespace adsk::cam;
using namespace std;
Ptr<Application> app;
Ptr<UserInterface> ui;
extern "C" XI_EXPORT bool run(const char* context)
{
app = Application::get();
if (!app)
return false;
ui = app->userInterface();
if (!ui)
return false;
ui->messageBox("Hello script");
/* create a file */
/* Test Writing to a file */
ofstream outflm;
outflm.open("outflm.txt");
double a = 10.0;
char aStr[16]; // string which will contain the number
sprintf_s ( aStr, "%f", a ); // %d makes the result be a decimal integer
string SaStr;
SaStr += "Test aStr";
SaStr += " ";
SaStr += aStr;
ui->messageBox(SaStr);
outflm << SaStr;
outflm.close();
char str[100];
ifstream inflm;
inflm.open("inflm.txt");
inflm.getline(str, 100, '#');
ui->messageBox("str", str);
string x = "fred";
int d = 3;
char dStr[16]; // string which will contain the number
sprintf_s ( dStr, "%d", d ); // %d makes the result be a decimal integer
ui->messageBox("Test messageBox");
string msg;
msg = "Test 2";
msg += " ";
msg += x;
msg += " ";
msg += dStr;
ui->messageBox(msg);
return true;
}
#ifdef XI_WIN
#include <windows.h>
BOOL APIENTRY DllMain(HMODULE hmodule, DWORD reason, LPVOID reserved)
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
#endif // XI_WIN