Demonstrates creates a constant radius fillet on the selected edge. If there are tangent contiguous edges that will also be included in the fillet.
Before running: Run from Scripts and Add-Ins. This sample may open dialogs or require interactive choices; keep Fusion in the foreground.
/** * Constant Radius Fillet API Sample * Creates a constant radius fillet on the selected edge. If there are tangent contiguous edges that will also be included in the fillet. */ import { adsk } from '@adsk/fusion' function run() { // Get the Fusion API's application object const app = adsk.core.Application.get(); if (!app) throw Error("No adsk.core.Application."); // Create a document. const doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType) const design = app.activeProduct as adsk.fusion.Design // Get the root component of the active design. const rootComp = design.rootComponent // Have the edge selected and add it to an ObjectCollection. const body = createBox(rootComp, 4, 4) const edge = body.edges.item(0) // Create the FilletInput object. const fillets = rootComp.features.filletFeatures const filletInput = fillets.createInput() filletInput.edgeSetInputs.addConstantRadiusEdgeSet([edge], adsk.core.ValueInput.createByString('.25 in'), true) // Create the fillet. const fillet = fillets.add(filletInput) } function createBox(rootComp: adsk.fusion.Component, sizeX: number, sizeY: number): adsk.fusion.BRepBody{ // Create sketch const sketches = rootComp.sketches const sketch = sketches.add(rootComp.xZConstructionPlane) const sketchCircles = sketch.sketchCurves.sketchCircles const lines = sketch.sketchCurves.sketchLines lines.addTwoPointRectangle(adsk.core.Point3D.create(0, 0, 0), adsk.core.Point3D.create(sizeX, sizeY, 0)) // Get the profile defined by the circle. const prof = sketch.profiles.item(0) // Create an extrusion input const extrudes = rootComp.features.extrudeFeatures const extInput = extrudes.createInput(prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation) // Define that the extent is a distance extent of 5 cm. const distance = adsk.core.ValueInput.createByReal(5) const distanceExtentDef = adsk.fusion.DistanceExtentDefinition.create(distance) extInput.setOneSideExtent(distanceExtentDef, adsk.fusion.ExtentDirections.PositiveExtentDirection) // Create the extrusion. const ext = extrudes.add(extInput) return ext.bodies.item(0) } run();
#include <Core/Application/Application.h>
#include <Core/Application/ObjectCollection.h>
#include <Core/Application/ValueInput.h>
#include <Core/UserInterface/Selection.h>
#include <Core/UserInterface/UserInterface.h>
#include <Fusion/BRep/BRepEdge.h>
#include <Fusion/Components/Component.h>
#include <Fusion/Features/Features.h>
#include <Fusion/Features/FilletFeatureInput.h>
#include <Fusion/Features/FilletFeatures.h>
#include <Fusion/Fusion/Design.h>
using namespace adsk::core;
using namespace adsk::fusion;
Ptr<UserInterface> ui;
extern "C" XI_EXPORT bool run(const char* context)
{
Ptr<Application> app = Application::get();
if (!app)
return false;
ui = app->userInterface();
if (!ui)
return false;
Ptr<Design> design = app->activeProduct();
if (!design)
return false;
// Get the root component of the active design
Ptr<Component> root = design->rootComponent();
if (!root)
return false;
// Have the edge selected and add it to an ObjectCollection.
Ptr<Selection> selection = ui->selectEntity("Select edge to fillet", "Edges");
if (!selection)
return false;
Ptr<BRepEdge> edge = selection->entity();
if (!edge)
return false;
Ptr<ObjectCollection> edgeCollection = ObjectCollection::create();
if (!edgeCollection)
return false;
edgeCollection->add(edge);
Ptr<Features> feats = root->features();
if (!feats)
return false;
Ptr<FilletFeatures> fillets = feats->filletFeatures();
if (!fillets)
return false;
Ptr<FilletFeatureInput> filletInput = fillets->createInput();
if (!filletInput)
return false;
filletInput->addConstantRadiusEdgeSet(edgeCollection, ValueInput::createByString(".25 in"), true);
Ptr<FilletFeature> fillet = fillets->add(filletInput);
return true;
}
import adsk.core, adsk.fusion, traceback
def createFillet():
ui = None
try:
# Get the Application object.
app = adsk.core.Application.get()
# Get various top-level Fusion objects.
ui = app.userInterface
design = app.activeProduct
root = design.rootComponent
# Have the edge selected and add it to an ObjectCollection.
selection = ui.selectEntity("Select edge to fillet", "Edges")
edge = selection.entity
edgeCollection = adsk.core.ObjectCollection.create()
edgeCollection.add(edge)
# Create the FilletInput object.
fillets = root.features.filletFeatures
filletInput = fillets.createInput()
filletInput.addConstantRadiusEdgeSet(edgeCollection, adsk.core.ValueInput.createByString('.25 in'), True)
# Create the fillet.
fillet = fillets.add(filletInput)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def main():
createFillet()
main()