#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;
#define CHECK_PTR(ptr) \
if (!ptr) \
{ \
return false; \
}
extern "C" XI_EXPORT bool run(const char* context)
{
app = Application::get();
if (!app)
return false;
ui = app->userInterface();
if (!ui)
return false;
auto product = app->activeProduct();
CHECK_PTR(product);
auto design = product->cast<Design>();
CHECK_PTR(design);
auto rootComp = design->rootComponent();
CHECK_PTR(rootComp);
auto bodies = rootComp->bRepBodies();
if (!bodies || bodies->count() == 0)
return false;
auto body = bodies->item(0);
CHECK_PTR(body);
auto edges = body->edges();
if (!edges || edges->count() == 0)
return false;
auto dominantEdge = edges->item(66);
auto submissiveEdge = edges->item(7);
CHECK_PTR(dominantEdge);
CHECK_PTR(submissiveEdge);
auto features = rootComp->features();
CHECK_PTR(features);
auto cornerFeatures = features->cornerClosureFeatures();
CHECK_PTR(cornerFeatures);
// --- Create a three-bend corner closure feature ---
auto input = cornerFeatures->createInput(dominantEdge, submissiveEdge);
CHECK_PTR(input);
input->isWidthExtentAligned(false);
input->gap(ValueInput::createByReal(0.35));
auto threeBendFeature = cornerFeatures->add(input);
CHECK_PTR(threeBendFeature);
// --- Create a two-bend corner closure feature ---
dominantEdge = edges->item(55);
submissiveEdge = edges->item(97);
CHECK_PTR(dominantEdge);
CHECK_PTR(submissiveEdge);
input = cornerFeatures->createInput(dominantEdge, submissiveEdge);
CHECK_PTR(input);
input->isWidthExtentAligned(false);
input->gap(ValueInput::createByReal(0.45));
input->bendTransition(BendTransitionTypes::TrimToBendCornerBendTransitionType);
auto twoBendInputDef = input->closureDefinition();
CHECK_PTR(twoBendInputDef);
auto twoBendDef = twoBendInputDef->cast<TwoBendCornerClosureDefinition>();
CHECK_PTR(twoBendDef);
twoBendDef->isUseSheetMetalRuleDefaults(false);
twoBendDef->reliefPlacement(CornerTwoBendReliefPlacementTypes::IntersectionCornerTwoBendReliefPlacementType);
twoBendDef->reliefShape(CornerTwoBendReliefShapeTypes::LinearWeldCornerTwoBendReliefShapeType);
auto twoBendFeature = cornerFeatures->add(input);
CHECK_PTR(twoBendFeature);
// --- Edit the two-bend corner closure feature ---
auto timelineObj = twoBendFeature->timelineObject();
CHECK_PTR(timelineObj);
timelineObj->rollTo(true);
twoBendFeature->bendTransition(BendTransitionTypes::StraightLineCornerBendTransitionType);
auto closureDef = twoBendFeature->closureDefinition();
CHECK_PTR(closureDef);
auto editDef = closureDef->cast<TwoBendCornerClosureDefinition>();
CHECK_PTR(editDef);
editDef->reliefShape(CornerTwoBendReliefShapeTypes::RoundCornerTwoBendReliefShapeType);
timelineObj->rollTo(false);
return true;
}
#undef CHECK_PTR