Here's the full code of a C++ script that works for me.
#include <Core/CoreAll.h>
#include <Fusion/FusionAll.h>
using namespace adsk::core;
using namespace adsk::fusion;
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;
// Get the root component from the active design and create a sketch.
Ptr<Design> des = app->activeProduct();
Ptr<Component> root = des->rootComponent();
Ptr<Sketch> sk = root->sketches()->add(root->xYConstructionPlane());
// Draw a circle.
Ptr<SketchCircles> circles = sk->sketchCurves()->sketchCircles();
Ptr<SketchCircle> circle = circles->addByCenterRadius(adsk::core::Point3D::create(0, 0, 0), 5);
// Offset the circle.
Ptr<GeometricConstraints> constraints = sk->geometricConstraints();
std::vector<Ptr<SketchCurve>> curves;
curves.push_back(circle);
Ptr<OffsetConstraintInput> input = constraints->createOffsetInput(curves, adsk::core::ValueInput::createByReal(1));
Ptr<OffsetConstraint> offset = constraints->addOffset2(input);
std::vector<Ptr<SketchCurve>> resultCurves = offset->childCurves();
Ptr<SketchCircle> newCircle = resultCurves[0];
ui->messageBox("The offset circle is " + std::to_string(newCircle->radius()) + " cm radius.");
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
---------------------------------------------------------------
Brian EkinsInventor and Fusion 360 API Expert
Website/Blog:
https://EkinsSolutions.com