Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I would like to scale the selected item. However, executing the script below does not scale.
#include <Core/CoreAll.h>
#include <Fusion/FusionAll.h>
#include <CAM/CAMAll.h>
#include <iostream>
#include <format>
#include <string>
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;
// Have a body selected.
Ptr<Selection> select = ui->selectEntity("Select a body", "Bodies");
Ptr<BRepBody> body = select->entity();
Ptr<Product> product = app->activeProduct();
Ptr<Design> design = product;
// Get the root component of the active design
Ptr<Component> rootComp = design->rootComponent();
// Create an uniformed input for scale feature input
Ptr<ObjectCollection> inputColl = ObjectCollection::create();
inputColl->add(body);
// Point for scale
Ptr<Point3D> centerPoint = Point3D::create(0, 0, 0);
Ptr<ValueInput> scaleFactor = ValueInput::createByReal(10);
Ptr<Features> feats = rootComp->features();
Ptr<ScaleFeatures> scales = feats->scaleFeatures();
Ptr<ScaleFeatureInput> scaleUniformInput = scales->createInput(inputColl, centerPoint, scaleFactor);
Ptr<ScaleFeature> scaleUniform = scales->add(scaleUniformInput);
app->log("scale");
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
Solved! Go to Solution.