GetPointAtParam SketchArc Not Working!

GetPointAtParam SketchArc Not Working!

florian_wenzel
Advocate Advocate
411 Views
2 Replies
Message 1 of 3

GetPointAtParam SketchArc Not Working!

florian_wenzel
Advocate
Advocate

Hi,

Inventor 2022

API VB.NET VisualStudio

 

i try to get a Point from a GetPointAtParam.

It works Fine for Line, Spline but not for SketchArcs!

 

Code:

 

       Dim oPartDoc As PartDocument = g_inventorApplication.ActiveDocument
        Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
        Dim oTO As TransientObjects = g_inventorApplication.TransientObjects
        Dim oTG As TransientGeometry = g_inventorApplication.TransientGeometry

        Dim oSketch As PlanarSketch = oCompDef.Sketches.Item(1)
        Dim oObjCollPoints As ObjectCollection = oTO.CreateObjectCollection

        Dim oArc As SketchArc = oSketch.SketchArcs.Item(1)
        Dim oParams As Double() = {0.1}
        Dim oDouble As Double() = {}
        oArc.Geometry.Evaluator.GetPointAtParam(oParams, oDouble)
        Dim oPoint As Point2d = oTG.CreatePoint2d(oDouble(0), oDouble(1))
        oObjCollPoints.Add(oPoint)


        MsgBox("oObjCollPoints = " & oObjCollPoints.Count)

 

Wrong Parameter ?

florian_wenzel_0-1670347254669.png

 

Anybody Know something?

 

Thanks For Any Suggestion

 

0 Likes
Accepted solutions (1)
412 Views
2 Replies
Replies (2)
Message 2 of 3

nmunro
Collaborator
Collaborator
Accepted solution

It appears you are assuming the parameters for the arc run from 0 - 1.0 (looking for point 10% along the arc)? It is always better to acquire the start and end parameters for the evaluator and then use those values in your call to get the point.  Your code modified in VBA below.

    Dim oPartDoc As PartDocument
    Set oPartDoc = ThisDocument
    Dim oCompDef As PartComponentDefinition
    Set oCompDef = oPartDoc.ComponentDefinition
    Dim oTO As TransientObjects
    Set oTO = ThisApplication.TransientObjects
    Dim oTG As TransientGeometry
    Set oTG = ThisApplication.TransientGeometry

    Dim oSketch As PlanarSketch
    Set oSketch = oCompDef.Sketches.Item(1)
    Dim oObjCollPoints As ObjectCollection
    Set oObjCollPoints = oTO.CreateObjectCollection

    Dim oArc As SketchArc
    Set oArc = oSketch.SketchArcs.Item(1)
    Dim oParams(0) As Double
    Dim oDouble(1) As Double
    
    Dim eval As curve2devaluator
    Set eval = oArc.Geometry.Evaluator
    
    Dim startParam As Double
    Dim endParam As Double
    
    ' get start and end parameter values
    Call eval.GetParamExtents(startParam, endParam)
    
    ' get parameter at 10% along arc - from start
    oParams(0) = startParam + 0.1 * (endParam - startParam)
        

    Call eval.GetPointAtParam(oParams, oDouble)
    Dim oPoint As Point2d
    Set oPoint = oTG.CreatePoint2d(oDouble(0), oDouble(1))
    Call oObjCollPoints.Add(oPoint)

    MsgBox ("oObjCollPoints = " & oObjCollPoints.Count)

 

        


https://c3mcad.com

Message 3 of 3

florian_wenzel
Advocate
Advocate

Hi @nmunro ,

 

Thank you for Solution.

ok, so it works.

Also, when you Project this Arc2D to Sketch3D, and then with CurveEvaluator for 3D The Method GetPointatParam  Works fine.

But as you show, for Arc2D works also.

Thanks.

0 Likes