Message 1 of 2
Possible bug: extrude feature
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I encountered a weird behavior while with extrude features through API. It only reproduces on specific model.
Screencast showing the issue:
As you can see in the screen cast, when running the code it fails to create the extrude feature - the error is shown in the message box. However when editing the feature in Fusion you can see it shows everything is fine with it and after clicking ok - the extrude is made. Therefore I can only conclude that this is an API bug.
Demo code to reproduce the issue:
#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();
Ptr<Component> activeObj = app->activeEditObject();
for (const auto& occ : activeObj->allOccurrences())
{
const auto name = occ->component()->name();
if (name == "Virs_sp_virsus (1)")
{
const auto body = occ->bRepBodies()->item(0);
const auto face = body->faces()->item(0);
const auto extrudeFeatures = occ->component()->features()->extrudeFeatures();
const auto input = extrudeFeatures->createInput(face, CutFeatureOperation);
const auto distanceExtent = DistanceExtentDefinition::create(ValueInput::createByReal(2));
input->setOneSideExtent(distanceExtent, NegativeExtentDirection);
input->participantBodies({ body });
const auto feature = extrudeFeatures->add(input);
if (!feature)
{
std::string description;
const auto errorNumber = app->getLastError(&description);
app->userInterface()->messageBox(description);
}
break;
}
}
return true;
}
extern "C" XI_EXPORT bool stop(const char* context)
{
return true;
}
Link to the model: