Hello,
Here is a different approach that creates two offsets, one with positive distance and one with negative distance and then keeps the one with the larger length.
import adsk.core, adsk.fusion, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
design = app.activeProduct
# Get the root component of the active design.
rootComp = design.rootComponent
# Create a new sketch on the xy plane.
sketches = rootComp.sketches
xyPlane = rootComp.xYConstructionPlane
sketch = sketches.add(xyPlane)
# Draw two connected lines.
lines = sketch.sketchCurves.sketchLines
line1 = lines.addByTwoPoints(adsk.core.Point3D.create(0, 0, 0), adsk.core.Point3D.create(3, 1, 0))
line2 = lines.addByTwoPoints(line1.endSketchPoint, adsk.core.Point3D.create(1, 4, 0))
line3 = lines.addByTwoPoints(line1.startSketchPoint, line2.endSketchPoint)
# Add a fillet.
arc = sketch.sketchCurves.sketchArcs.addFillet(line1, line1.endSketchPoint.geometry, line2, line2.startSketchPoint.geometry, 1)
# Add the geometry to a collection. This uses a utility function that
# automatically finds the connected curves and returns a collection.
curves = sketch.findConnectedCurves(line1)
# Create the offsets.
dirPoint = adsk.core.Point3D.create(0, .5, 0)
offsetDistance = 0.25
offsetCurves1 = sketch.offset(curves, dirPoint, offsetDistance)
offsetCurves2 = sketch.offset(curves, dirPoint, -offsetDistance)
# Compute the length of the first offset.
length1 = 0.0
for sketchCurve in offsetCurves1:
length1 += sketchCurve.length
# Compute the length of the second offset.
length2 = 0.0
for sketchCurve in offsetCurves2:
length2 += sketchCurve.length
# Delete the shorter one.
if length1 < length2:
for sketchCurve in offsetCurves1:
sketchCurve.deleteMe()
else:
for sketchCurve in offsetCurves2:
sketchCurve.deleteMe()
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))