Create surface from points

Create surface from points

ebunn3
Advocate Advocate
1,722 Views
4 Replies
Message 1 of 5

Create surface from points

ebunn3
Advocate
Advocate

Is there a way to create a surface from a series of points or point coordinates that are not planer?   Alternatively from a series of spline curves?

 

Eric

0 Likes
Accepted solutions (1)
1,723 Views
4 Replies
Replies (4)
Message 2 of 5

JeromeBriot
Mentor
Mentor

@ebunn3  a écrit :

Alternatively from a series of spline curves?

 


Hello,

 

Did you try with a loft feature: Loft Feature API Sample

 

 

Message 3 of 5

ebunn3
Advocate
Advocate

I actually did since posting.   This may be what I ultimately use.  Thanks. 

Eric

0 Likes
Message 4 of 5

BrianEkins
Mentor
Mentor

Fitting curves through the points and then lofting through the curves will be your best option.  Fusion doesn't have a command for creating a surface directly through a set of points.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 5 of 5

kandennti
Mentor
Mentor
Accepted solution

@ebunn3 .

 

We have created a sample that creates a surface passing through a point from a sketch point in the attached f3d file.

1.png

 

# Fusion360API Python script

import traceback
import adsk.fusion
import adsk.core

def run(context):
    ui: adsk.core.UserInterface = None
    try:
        app: adsk.core.Application = adsk.core.Application.get()
        ui = app.userInterface
        des: adsk.fusion.Design = app.activeProduct
        root: adsk.fusion.Component = des.rootComponent

        # ref sketch
        refSkt: adsk.fusion.Sketch = root.sketches[0]

        # points
        pnts = [p.worldGeometry for p in refSkt.sketchPoints][1:]
        if len(pnts) < 2:
            return

        # sort
        pnts=sorted(pnts, key=lambda x:x.x)

        # BoundingBox
        bBox: adsk.core.BoundingBox3D = adsk.core.BoundingBox3D.create(
            pnts[0],
            pnts[1]
        )
        [bBox.expand(p) for p in pnts[2:]]

        # loft sections lines
        skt: adsk.fusion.Sketch = root.sketches.add(root.xYConstructionPlane)
        lines: adsk.fusion.SketchLines = skt.sketchCurves.sketchLines

        for p in pnts:
            lines.addByTwoPoints(
                adsk.core.Point3D.create(p.x, bBox.minPoint.y, p.z),
                adsk.core.Point3D.create(p.x, bBox.maxPoint.y, p.z),
            )

        # surface loft
        initSurfaceLoft(skt.sketchCurves.sketchLines)

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


def initSurfaceLoft(lines: list):
    app: adsk.core.Application = adsk.core.Application.get()
    ui: adsk.core.UserInterface = app.userInterface
    sels: adsk.core.Selections = ui.activeSelections
    sels.clear()

    for line in lines:
        sels.add(line)

    app.executeTextCommand(u'Commands.Start SurfaceLoft')
    app.executeTextCommand(u'NuCommands.CommitCmd')

 

Since we have not done a detailed check, depending on the placement of the points, there should be cases where it stops with an error.

 

 

I could not figure out how to create a surface loft with sketch lines, etc. instead of a profile in the API.
Therefore, I am using text commands.