TypeError: in method 'SurfaceEvaluator_getPointAtParameter', argument 2 of type 'adsk::core::Ptr< adsk::core::Point2D > const &'

TypeError: in method 'SurfaceEvaluator_getPointAtParameter', argument 2 of type 'adsk::core::Ptr< adsk::core::Point2D > const &'

2544173825
Enthusiast Enthusiast
567 Views
3 Replies
Message 1 of 4

TypeError: in method 'SurfaceEvaluator_getPointAtParameter', argument 2 of type 'adsk::core::Ptr< adsk::core::Point2D > const &'

2544173825
Enthusiast
Enthusiast

I used SurfaceEvaluator to get the parameter range of a face, that is, to generate a 2D bounding box of the face, and did interpolation in both directions of this 2D bounding box, and finally divided this bounding box into a 10*10 grid. Then when I tried to get the 3D point through this grid point, I encountered the above error when using SurfaceEvaluator.getPointAtParameter(uv), it looks like a parameter type error, but I don't know how to fix it, my uv parameter is a numpy type. Also I want to get the tangent information from this separated 2D point coordinates, but I can't find the related API, is it not available?

0 Likes
568 Views
3 Replies
Replies (3)
Message 2 of 4

BrianEkins
Mentor
Mentor

I've attached a sample program I wrote several years ago that uses this functionality extensively, and I haven't seen any problems. Maybe there's a case-specific issue you're running into? If you load this add-in, it will add a new command into the INSPECT drop-down, as shown below. When the command is running, you can choose for it to draw a U-V mesh or draw normals on the selected face.

 

ee8e7131-aa94-4f32-887b-19ca8bc75649.png

UV2.png

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

2544173825
Enthusiast
Enthusiast

I think I've found the problem, thank you!

0 Likes
Message 4 of 4

kandennti
Mentor
Mentor

Hi @2544173825 .

 

The parameter of the getPointAtParameter method is a Point2D object.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-761b2324-dc33-42b5-b6a9-b3a1305b8341 

 

Also, I believe that you can get the normal vector from a point on the surface, but you should not be able to define the tangent information.
If you have another vector, you should be able to get the tangent by using the outer product.

 

Here is a sample of drawing normals on a 10x10 selected surface.

# Fusion360API Python script

import traceback
import adsk.fusion
import adsk.core

SPLIT_COUNT = 10

def run(context):
    ui = adsk.core.UserInterface.cast(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

        # select face
        msg: str = 'Select Face'
        selFilter: str = 'Faces'
        sel: adsk.core.Selection = selectEnt(msg, selFilter)
        if not sel:
            return

        selectFace: adsk.fusion.BRepFace = sel.entity

        # create parameter
        eva: adsk.core.SurfaceEvaluator = selectFace.evaluator
        bBox: adsk.core.BoundingBox2D = eva.parametricRange()

        ratio = 1 / SPLIT_COUNT
        pichX = (bBox.maxPoint.x - bBox.minPoint.x) * ratio
        pichY = (bBox.maxPoint.y - bBox.minPoint.y) * ratio

        prms = []
        for idxX in range(SPLIT_COUNT + 1):
            for idxY in range(SPLIT_COUNT + 1):
                prms.append(
                    adsk.core.Point2D.create(
                        pichX * idxX,
                        pichY * idxY
                    )
                )

        # get points 
        _, points = eva.getPointsAtParameters(prms)

        # get normals
        _, normals = eva.getNormalsAtParameters(prms)

        # create sketch
        skt: adsk.fusion.Sketch = root.sketches.add(root.xYConstructionPlane)

        # draw normals
        sktLines: adsk.fusion.SketchLines = skt.sketchCurves.sketchLines
        targetPoints = [p.copy() for p in points]
        [p.translateBy(v) for p, v in zip(targetPoints, normals)]

        skt.isComputeDeferred = True
        [sktLines.addByTwoPoints(p1, p2) for p1, p2 in zip(points, targetPoints)]
        skt.isComputeDeferred = False


        ui.messageBox('done')

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

def selectEnt(
    msg: str,
    filterStr: str) -> adsk.core.Selection:

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

1.png

 

You seem to have created something that looks like fun. Looking forward to it.

0 Likes