Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

In C++, Fillet Between A Spline and a Line Does Not Work

0 REPLIES 0
Reply
Message 1 of 1
tperam
564 Views, 0 Replies

In C++, Fillet Between A Spline and a Line Does Not Work

 

Hi,
      using C++, Fillet Between A Spline and a Line Does Not Work.

 

How do I accomplish it?

 

My C++ Code is as below.

 

Regards,
Thurai Moorthy

 

////////////////////////////////////////////

#include <Core/CoreAll.h>
#include <Fusion/FusionAll.h>
#include <CAM/CAMAll.h>

using namespace adsk::core;
using namespace adsk::fusion;
using namespace adsk::cam;

Ptr<Application> app;
Ptr<UserInterface> ui;

extern "C" XI_EXPORT bool run(const char* context)
{


Ptr<Application> app = Application::get();
if (!app)
return false;

ui = app->userInterface();
if (!ui)
return false;


Ptr<Documents> documents = app->documents();
if (!documents)
return false;

Ptr<Document> doc = documents->add(DocumentTypes::FusionDesignDocumentType);
if (!doc)
return false;

Ptr<Product> product = app->activeProduct();
if (!product)
return false;

Ptr<Design> design = product;
if (!design)
return false;

// Get the root component of the active design.
Ptr<Component> rootComp = design->rootComponent();
if(!rootComp)
return false;


// Create a new sketch on the xy plane.
Ptr<Sketches> sketches = rootComp->sketches();
if(!sketches)
return false;

Ptr<ConstructionPlane> xyPlane = rootComp->xYConstructionPlane();
if(!xyPlane)
return false;

Ptr<Sketch> sketch = sketches->add(xyPlane);
if(!sketch)
return false;


ui->messageBox(" sketch = ");

/* Create the Points */
Ptr<Point3D> Pts[4];
Pts[0] = Point3D::create(-5, 0, 0);
Pts[1] = Point3D::create(0, 5, 0);
Pts[2] = Point3D::create(5, 0, 0);
Pts[3] = Point3D::create(0, -10, 0);


/* Create the Spline */
Ptr<Sketches> sketchesSplines = rootComp->sketches();

Ptr<Sketch> sketchSpline = sketchesSplines->add(xyPlane);
if (!sketchSpline)
return false;


// Create the spline.
Ptr<ObjectCollection> SplineObjColPts = adsk::core::ObjectCollection::create();
if(!SplineObjColPts)
return false;

ui->messageBox(" After SplineObjColPts = ");

Ptr<SketchCurves> sketchCurvesSpline = sketchSpline->sketchCurves();
if (!sketchCurvesSpline)
return false;


Ptr<SketchFittedSplines> splines = sketchCurvesSpline->sketchFittedSplines();
if (!splines)
return false;


Ptr<SketchFittedSpline> spline = sketchCurvesSpline->sketchFittedSplines();
if (!splines)
return false;


/* Add Pts[0],Pts[1], Pts[2] to SplineObjColPts */
unsigned int I;
for(I = 0; I <=2; I++)
{//I
SplineObjColPts->add(Pts[I]);
}//I


splines->add(SplineObjColPts);

spline = splines->item(0);

bool ReturnValue = spline->isClosed(false);


// Draw two connected lines.
Ptr<SketchCurves> sketchCurves = sketch->sketchCurves();
if(!sketchCurves)
return false;


Ptr<SketchLines> sketchLines = sketchCurves->sketchLines();
if(!sketchLines)
return false;

ui->messageBox(" After sketchLines = ");

Ptr<SketchLine> MyLines[2];

MyLines[0] = sketchLines->addByTwoPoints(Pts[0], Pts[3]);
if (!MyLines[0])
return false;


MyLines[1] = sketchLines->addByTwoPoints(Pts[3], Pts[2]);
if (!MyLines[1])
return false;


/* Fillet Arcs */
Ptr<SketchArcs> sketchArcs = sketchCurves->sketchArcs();
if (!sketchArcs)
return false;


Ptr<SketchArc> Arc[2];

/* Fillet between MyLines[0] and MyLines[1] */
Arc[0] = sketchArcs->addFillet(MyLines[0], MyLines[0]->startSketchPoint()->geometry(), MyLines[1], MyLines[1]->endSketchPoint()->geometry(), 1.0);
if (!Arc[0])
return false;

ui->messageBox(" Arc[0] ");

/* Fillet between the spline and MyLines[0] */
Arc[1] = sketchArcs->addFillet(spline, Pts[1], MyLines[0], MyLines[0]->endSketchPoint()->geometry(), 1.0);
if (!Arc[1])
return false;

ui->messageBox(" Arc[1] ");


/* Fillet between the spline and MyLines[1] */
Arc[2] = sketchArcs->addFillet(spline, Pts[1], MyLines[1], MyLines[1]->startSketchPoint()->geometry(), 1.0);
if (!Arc[2])
return false;


ui->messageBox(" Arc[2] ");


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

Tags (4)
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report