Outer Offset

Outer Offset

bjoern79de
Participant Participant
752 Views
5 Replies
Message 1 of 6

Outer Offset

bjoern79de
Participant
Participant

How can I reliably create an outer offset curve to a profile?

 

If I use the centroid of the profile as the dirPoint and a negative value, I always get an inner offset:

 

curves = adsk.core.ObjectCollection.create()
crv = sketch.sketchCurves.sketchFittedSplines.add(targetSketchPoints)
crv.isClosed = True
curves.add(crv)
dirPoint = sketch.profiles[0].areaProperties().centroid
offsetCurves = sketch.offset(curves, dirPoint, -0.24)
 
Any suggestions?
0 Likes
753 Views
5 Replies
Replies (5)
Message 2 of 6

kandennti
Mentor
Mentor

Hi @bjoern79de .

 

Why not try setting the directionPoint to be slightly outside the boundingBox.maxPoint?

However, it didn't work with the self-published spline.

        curves = adsk.core.ObjectCollection.create()
        crv = sketch.sketchCurves.sketchFittedSplines.add(targetSketchPoints)
        crv.isClosed = True
        curves.add(crv)

        dirPoint = crv.boundingBox.maxPoint.copy()
        dirPoint.translateBy(adsk.core.Vector3D.create(1,1,0))

        offsetCurves = sketch.offset(curves, dirPoint, 0.24)

 

0 Likes
Message 3 of 6

bjoern79de
Participant
Participant
I’ve already tried that, but no success.
Seems to be a bug.
0 Likes
Message 4 of 6

kandennti
Mentor
Mentor

It could not be reproduced here because the state of targetSketchPoints is unknown.

0 Likes
Message 5 of 6

JeromeBriot
Mentor
Mentor

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()))
Message 6 of 6

bjoern79de
Participant
Participant

This doesn't work for the described cases.

 

Positive offset: Arrow against dirPointPositive offset: Arrow against dirPoint

 

The arrow heads into the opposite direction in both cases for:

innerPoint = sketch.profiles[0].areaProperties().centroid
sketch.offset(curves, innerPoint, 0.06)
 
AND
 
sketch.offset(curves, innerPoint, -0.06)
0 Likes