Fillet and Draft in ADD-INS on Python
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Good day to all. I have a task to program this model, and I did the main part, but there was a problem.
I don't know how to write Fillet and Draft tools.
I already looked at the documentation examples but they did not help me.
Maybe something will help with the code or throw off an easier example?
Here is my code:
#Author-
#Description-
from asyncio import constants
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
# Create a document.
doc = app.documents.add(
adsk.core.DocumentTypes.FusionDesignDocumentType)
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
# Get the root component of the active design.
rootComp = design.rootComponent
# Create sketch
sketches = rootComp.sketches
sketch = sketches.add(rootComp.xYConstructionPlane)
Lines = sketch.sketchCurves.sketchLines
startPoint = adsk.core.Point3D.create(0, 0, 0)
endPoint = adsk.core.Point3D.create(6, 11, 0)
Rect = Lines.addTwoPointRectangle(startPoint,endPoint)
prof = sketch.profiles.item(0)
# Create an extrusion input.
features = rootComp.features
extrudes = features.extrudeFeatures
extInput = extrudes.createInput(
prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
# Define that the extent is a distance extent of 5 cm.
distance = adsk.core.ValueInput.createByReal(3)
extInput.setDistanceExtent(False, distance)
ext = extrudes.add(extInput)
# CUT CYLINDER
sketches = rootComp.sketches
sketch = sketches.add(rootComp.xYConstructionPlane)
circles1 = sketch.sketchCurves.sketchCircles
CentPoint = adsk.core.Point3D.create(1.5, 1.5, 0)
oCirc = circles1.addByCenterRadius(CentPoint, 0.5)
# Get the profile defined by the rectangle.
prof1 = sketch.profiles.item(0)
extInput = extrudes.createInput(prof1, adsk.fusion.FeatureOperations.CutFeatureOperation)
distance = adsk.core.ValueInput.createByReal(3)
extInput.setDistanceExtent(False, distance)
ext = extrudes.add(extInput)
##
sketches = rootComp.sketches
sketch = sketches.add(rootComp.xYConstructionPlane)
circles1 = sketch.sketchCurves.sketchCircles
CentPoint = adsk.core.Point3D.create(4.5, 1.5, 0)
oCirc = circles1.addByCenterRadius(CentPoint, 0.5)
# Get the profile defined by the rectangle.
prof1 = sketch.profiles.item(0)
extInput = extrudes.createInput(prof1, adsk.fusion.FeatureOperations.CutFeatureOperation)
distance = adsk.core.ValueInput.createByReal(3)
extInput.setDistanceExtent(False, distance)
ext = extrudes.add(extInput)
sketches = rootComp.sketches
sketch = sketches.add(rootComp.xYConstructionPlane)
circles1 = sketch.sketchCurves.sketchCircles
CentPoint = adsk.core.Point3D.create(1.5, 9.5, 0)
oCirc = circles1.addByCenterRadius(CentPoint, 0.5)
# Get the profile defined by the rectangle.
prof1 = sketch.profiles.item(0)
extInput = extrudes.createInput(prof1, adsk.fusion.FeatureOperations.CutFeatureOperation)
distance = adsk.core.ValueInput.createByReal(3)
extInput.setDistanceExtent(False, distance)
ext = extrudes.add(extInput)
sketches = rootComp.sketches
sketch = sketches.add(rootComp.xYConstructionPlane)
circles1 = sketch.sketchCurves.sketchCircles
CentPoint = adsk.core.Point3D.create(4.5, 9.5, 0)
oCirc = circles1.addByCenterRadius(CentPoint, 0.5)
# Get the profile defined by the rectangle.
prof1 = sketch.profiles.item(0)
extInput = extrudes.createInput(prof1, adsk.fusion.FeatureOperations.CutFeatureOperation)
distance = adsk.core.ValueInput.createByReal(3)
extInput.setDistanceExtent(False, distance)
ext = extrudes.add(extInput)
# ADD CYLINDER
sketches = rootComp.sketches
sketch = sketches.add(rootComp.xYConstructionPlane)
circles1 = sketch.sketchCurves.sketchCircles
CentPoint = adsk.core.Point3D.create(3, 4, 0)
oCirc = circles1.addByCenterRadius(CentPoint, 1.25)
# Get the profile defined by the rectangle.
prof1 = sketch.profiles.item(0)
extInput = extrudes.createInput(prof1, adsk.fusion.FeatureOperations.JoinFeatureOperation)
distance = adsk.core.ValueInput.createByReal(6)
extInput.setDistanceExtent(False, distance)
ext = extrudes.add(extInput)
#AND CUT CENTER
sketches = rootComp.sketches
sketch = sketches.add(rootComp.xYConstructionPlane)
circles1 = sketch.sketchCurves.sketchCircles
CentPoint = adsk.core.Point3D.create(3, 4, 0)
oCirc = circles1.addByCenterRadius(CentPoint, 0.75)
# Get the profile defined by the rectangle.
prof1 = sketch.profiles.item(0)
extInput = extrudes.createInput(prof1, adsk.fusion.FeatureOperations.CutFeatureOperation)
distance = adsk.core.ValueInput.createByReal(6)
extInput.setDistanceExtent(False, distance)
ext = extrudes.add(extInput)
# CUT Diagonal
# Create sketch
sketches = rootComp.sketches
sketch = sketches.add(rootComp.xYConstructionPlane)
Lines = sketch.sketchCurves.sketchLines
startPoint = adsk.core.Point3D.create(0.4, 2.5, 0)
endPoint = adsk.core.Point3D.create(5.6, 8.5, 0)
Rect = Lines.addTwoPointRectangle(startPoint,endPoint)
prof2 = sketch.profiles.item(0)
# Create an extrusion input.
features = rootComp.features
extrudes = features.extrudeFeatures
extInput = extrudes.createInput(prof2, adsk.fusion.FeatureOperations.CutFeatureOperation)
# Define that the extent is a distance extent of 5 cm.
distance = adsk.core.ValueInput.createByReal(0.8)
extInput.setDistanceExtent(False, distance)
ext = extrudes.add(extInput)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))