Message 1 of 9
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
I'm trying to define a spline (degree 3) through the API, which is fairly straight forward:
#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) { app = Application::get(); if (!app) return false; ui = app->userInterface(); if (!ui) return false; Ptr<Design> design = app->activeProduct(); Ptr<Component> rootComp = design->rootComponent(); Ptr<Sketches> sketches = design->rootComponent()->sketches(); Ptr<Sketch> sketch = sketches->add(rootComp->xYConstructionPlane()); Ptr<SketchCurves> sketchCurves = sketch->sketchCurves(); std::vector<double> knots = { 0,0,0,0, 1,1,1,1 }; int degree = 3; Ptr<Point3D> P0 = Point3D::create(0, 0, 0); Ptr<Point3D> P1 = Point3D::create(1, 0, 0); Ptr<Point3D> P2 = Point3D::create(1, 1, 0); Ptr<Point3D> P3 = Point3D::create(0, 1, 0); const std::vector<Ptr<Point3D>> controlPoints = { P0,P1,P2,P3 }; sketchCurves->sketchFittedSplines()->addByNurbsCurve(NurbsCurve3D::createNonRational(controlPoints, degree, knots, false)); 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
After having executed the script in Fusion 360, the spline looks like this:
However, when I move any of the control points, the Nurbs curve is converted to a "Fit Point Spline", which transforms it to this:
So just to underline the change - here are the two overlaid:
What I want is the expected curve, which I've shown here: (Generated using the "Control Point Spline" command within Fusion):
Is there any way to create a spline through the API, which allows me to move the nodes without converting the curve to a "Fit Point Spline"?
Thanks!
Anders
Solved! Go to Solution.