Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

How to create a 3D-Sketch along a iso-line ?

maurizio_manzi
Advocate

How to create a 3D-Sketch along a iso-line ?

maurizio_manzi
Advocate
Advocate

Hello,
I need a 3D-Sketch along a iso line.

I get the iso line and a reference to the sketches, but how can I "add" the iso line to a new sketch ?
It is possible ? If not, how can I linearize (with tolerance) the iso line, so that I can add many lines over point-3d to the sketch ?

 

Best regards

Maurizio Manzi

 

----------------------------------------------------------------

The script:

 

import adsk.core, adsk.fusion, adsk.cam, traceback

def run(context😞
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        ws: adsk.core.Workspace = ui.workspaces.itemById('FusionSolidEnvironment') # Referenz ws to design-Workspace

        if ws:
            ws.activate() # Activate design-Workspace
        design = adsk.fusion.Design.cast(app.activeProduct) # CAST - Design Document
        if not design:
            ui.messageBox("Keine Konstruktion / No design document found")
            return

       

       
        # Loop around all solids in root.bRepBodies
        root = design.rootComponent # Tree-root-directory
        for solid in root.bRepBodies:
            face = ui.selectEntity('Select a Face', 'Faces').entity
            isocurve = face.geometry.evaluator.getIsoCurve(.5,False)

            sketches = root.sketches # Get reference to root
            sketch = sketches.add(root.xYConstructionPlane) # Add new sketch
           
            # How to add 3D-Sketch along the isoline ?

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
0 Likes
Reply
Accepted solutions (1)
340 Views
2 Replies
Replies (2)

kandennti
Mentor
Mentor
Accepted solution

Hi @maurizio_manzi -San.

 

Iso Lines can be obtained by using the SurfaceEvaluator object.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-31dad9b2-ee1d-4216-8100-09ea44f9967a 

 

The following sample draws the Iso Line of the selected surface in a new sketch.

 

# Fusion360API Python script

import traceback
import adsk.core as core
import adsk.fusion as fusion


def run(context):
    ui: core.UserInterface = None
    try:
        app: core.Application = core.Application.get()
        ui = app.userInterface

        msg: str = 'Select Face'
        selFilter: str = 'Faces'
        sel: core.Selection = select_ent(msg, selFilter)
        if not sel:
            return

        create_iso_curves(sel.entity)

        ui.messageBox("Done")

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def create_iso_curves(
    face: fusion.BRepFace,
    count: int = 10,
) -> fusion.Sketch:

    # Evaluator
    eva: core.SurfaceEvaluator = face.evaluator
    parametricRange: core.BoundingBox2D = eva.parametricRange()

    # U Iso Curves
    unitU = (parametricRange.maxPoint.x -
             parametricRange.minPoint.x) / (count + 1)
    uList = [parametricRange.minPoint.x +
             unitU * idx for idx in range(1, count + 1)]

    crvs = []
    [crvs.extend(list(eva.getIsoCurve(prm, True))) for prm in uList]

    # V Iso Curves
    unitV = (parametricRange.maxPoint.y -
             parametricRange.minPoint.y) / (count + 1)
    vList = [parametricRange.minPoint.y +
             unitV * idx for idx in range(1, count + 1)]

    [crvs.extend(list(eva.getIsoCurve(prm, False))) for prm in vList]

    # Draw Sketch
    comp: fusion.Component = face.body.parentComponent
    skt: fusion.Sketch = comp.sketches.add(
        comp.xYConstructionPlane
    )

    splines: fusion.SketchFixedSplines = skt.sketchCurves.sketchFixedSplines
    for crv in crvs:
        if hasattr(crv, "asNurbsCurve"):
            crv = crv.asNurbsCurve()
        splines.addByNurbsCurve(crv)

    return skt


def select_ent(
    msg: str,
    filter: str
) -> core.Selection:

    try:
        app: core.Application = core.Application.get()
        ui: core.UserInterface = app.userInterface
        sel = ui.selectEntity(msg, filter)
        return sel
    except:
        return None

1.png

 

0 Likes

maurizio_manzi
Advocate
Advocate

thank you very much

1 Like