How to get parameter value of a sketch 3D point - GetParamAtPoint() does not work well?

How to get parameter value of a sketch 3D point - GetParamAtPoint() does not work well?

liminma8458
Collaborator Collaborator
676 Views
5 Replies
Message 1 of 6

How to get parameter value of a sketch 3D point - GetParamAtPoint() does not work well?

liminma8458
Collaborator
Collaborator

Hi, experts,

 

It is a 3D spline in a sweep which has non-evenly distributed sketch points in it. I want to extract parameter values (in parameter space) of these sketch points. I try to use "CurveEvaluator.GetParamAtPoint Method". But It does not work through. See the code below and the part is attached.

Please help! Thank you very much!

liminma8458_0-1641418819585.png

Public Sub Curve_evaluator()

'On Error Resume Next
Dim oSpline3D As SketchSpline3D

Set oSpline3D = ThisApplication.CommandManager.Pick(kSketch3DCurveSplineFilter, "Select a sketch 3D Spline. Esc to quit.")

'----go through each point and get its parameter
Dim oFitPoint_Count As Integer
oFitPoint_Count = oSpline3D.FitPointCount

Dim oParam() As Double
ReDim oParam(1 To oFitPoint_Count) As Double

' Get the evaluator from the curve.
Dim oCurveEval As CurveEvaluator
'Set oCurveEval = oEdge.evaluator
Set oCurveEval = oSpline3D.Geometry.evaluator

' Get the parametric range of the curve.
Dim dMinParam As Double
Dim dMaxParam As Double
Call oCurveEval.GetParamExtents(dMinParam, dMaxParam)
Debug.Print vbCr & "dMinParam : " & dMinParam & vbCr & "dMaxParam : " & dMaxParam

Dim currentParam As Double
Dim i As Integer
For i = 1 To oFitPoint_Count

currentParam = dMinParam + ((dMaxParam - dMinParam) / oFitPoint_Count) * (i - 1)

Dim fst_point(2) As Double
Dim fst_param(0) As Double
Dim deviate_param(0) As Double
Dim sec_param(0) As Double
Dim sol_param(0) As SolutionNatureEnum

fst_param(0) = currentParam - 0.2

fst_point(0) = oSpline3D.FitPoint(i).Geometry.x
fst_point(1) = oSpline3D.FitPoint(i).Geometry.y
fst_point(2) = oSpline3D.FitPoint(i).Geometry.Z

 

'----There is problem with this line when runing---

Call oCurveEval.GetParamAtPoint(fst_point, fst_param, deviate_param, sec_param, sol_param)
oParam(i) = fst_param(0)

Debug.Print "currentParam: " & Format(currentParam, "0.00") & _
" first_param: " & Format(fst_param(0), "0.00") & _
" first_point: " & Format(fst_point(0), "0.00") & "," & _
Format(fst_point(1), "0.00") & "," & _
Format(fst_point(2), "0.00") & _
" second_param: " & Format(sec_param(0), "0.00") & _
" solution_no: " & Format(sol_param(0), "0.00")

Next i

End Sub

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes
Accepted solutions (1)
677 Views
5 Replies
Replies (5)
Message 2 of 6

JelteDeJong
Mentor
Mentor

this is how i would do it in ilogic

Dim doc As PartDocument = ThisDoc.Document

Dim oSpline3D As SketchSpline3D = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketch3DCurveSplineFilter, "Select a sketch 3D Spline. Esc to quit.")

For i = 1 To oSpline3D.FitPointCount
    Dim sketchPoint3D As SketchPoint3D = oSpline3D.FitPoint(i)
    Dim geo As Point = sketchPoint3D.Geometry

    Logger.Info(String.Format("{0} - {1} - {2}", geo.X, geo.Y, geo.Z))
Next

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 6

liminma8458
Collaborator
Collaborator

Hi, Jone,

Thanks

I am not looking for the coordinate information of the sketch points. Instead, I am looking for the parameter value of these points in the parametric space on the spline edge. something like below:

liminma8458_0-1641424051145.png

liminma8458_1-1641424117313.png

 

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes
Message 4 of 6

YuhanZhang
Autodesk
Autodesk
Accepted solution

:The output array needs not to be declared with size, so the code can be modified as below:

Public Sub Curve_evaluator()

'On Error Resume Next
Dim oSpline3D As SketchSpline3D

Set oSpline3D = ThisApplication.CommandManager.Pick(kSketch3DCurveSplineFilter, "Select a sketch 3D Spline. Esc to quit.")

'----go through each point and get its parameter
Dim oFitPoint_Count As Integer
oFitPoint_Count = oSpline3D.FitPointCount

Dim oParam() As Double
ReDim oParam(1 To oFitPoint_Count) As Double

' Get the evaluator from the curve.
Dim oCurveEval As CurveEvaluator
'Set oCurveEval = oEdge.evaluator
Set oCurveEval = oSpline3D.Geometry.Evaluator

' Get the parametric range of the curve.
Dim dMinParam As Double
Dim dMaxParam As Double
Call oCurveEval.GetParamExtents(dMinParam, dMaxParam)
Debug.Print vbCr & "dMinParam : " & dMinParam & vbCr & "dMaxParam : " & dMaxParam

Dim currentParam As Double
Dim i As Integer
For i = 1 To oFitPoint_Count

currentParam = dMinParam + ((dMaxParam - dMinParam) / oFitPoint_Count) * (i - 1)

Dim fst_point(2) As Double
Dim fst_param(0) As Double
'Dim deviate_param(0) As Double
'Dim sec_param(0) As Double
'Dim sol_param(0) As SolutionNatureEnum


Dim deviate_param() As Double
Dim sec_param() As Double
Dim sol_param() As SolutionNatureEnum

fst_param(0) = currentParam - 0.2

fst_point(0) = oSpline3D.FitPoint(i).Geometry.X
fst_point(1) = oSpline3D.FitPoint(i).Geometry.Y
fst_point(2) = oSpline3D.FitPoint(i).Geometry.Z

 

'----There is problem with this line when runing---

Call oCurveEval.GetParamAtPoint(fst_point, fst_param, deviate_param, sec_param, sol_param)
oParam(i) = fst_param(0)

Debug.Print "currentParam: " & Format(currentParam, "0.00") & _
" first_param: " & Format(fst_param(0), "0.00") & _
" first_point: " & Format(fst_point(0), "0.00") & "," & _
Format(fst_point(1), "0.00") & "," & _
Format(fst_point(2), "0.00") & _
" second_param: " & Format(sec_param(0), "0.00") & _
" solution_no: " & Format(sol_param(0), "0.00")

Next i

End Sub


If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 5 of 6

liminma8458
Collaborator
Collaborator

Perfect! Thank you so much!

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes
Message 6 of 6

Stakin
Collaborator
Collaborator

Hi,

Is there a way to get the BsplineCurve fitpointData of a BSplineSurface?

After obtain the BsplineCurve fitpointdata,is there a way to  recreate the SplineCurve in the sketch3d ?

 

 

0 Likes