Reply

GetParamAtPoint does not work

hi, i had some problems with the GetParamAtPoint of Edge:

       'get the start and end points of the edge
       Dim sPnt(2) As Double, ePnt(2) As Double
       objEdge.GetEndPoints(sPnt, ePnt)

 

       'get the parameter corresponding to sPnt
       Dim dblGuessParams(0) As Double
       Dim dParams(0) As Double
       Dim dblMaxDev(0) As Double
       Dim lngFlags(0) As Long
       objEdge.GetParamAtPoint(NumPoints:=1, Points:=sPnt, _  

                            GuessParams:=dblGuessParams, _

                            MaxDeviations:=dblMaxDev, Params:=dParams, Flags:=lngFlags)


A "DISP_E_TYPEMISMATCH" exception was thrown at line objEdge.GetParamAtPoint...
vb.net and solidEdgeST3 were used.

 

Thanks in advance

2 REPLIES

Re: GetParamAtPoint does not work

[ Edited ]

You should use an Integer array for the Flags, instead of Long!

If you don't need all return parameters, you may use the simpler GetParamAtPointEx method.

 

Spoiler
'----------------------------------------------------------------------
' PAR: Get the parameter of the start point of an edge
'----------------------------------------------------------------------
  Dim objDoc As PartDocument = objApp.ActiveDocument
  
  ' Get the first edge of the active design model
  Dim objModel As Model = objDoc.Models.Item(1)
  Dim objBody As Body = objModel.Body
  Dim objEdges As Edges = objBody.Edges(FeatureTopologyQueryTypeConstants.igQueryAll)
  Dim objEdge1 As Edge = objEdges.Item(1)
  
  ' Get the end points of the edge
  Dim sPnt(2) As Double
  Dim ePnt(2) As Double
  objEdge1.GetEndPoints(sPnt, ePnt)

  ' Get the curve parameter of the start point
  ' NOTE: both ways of array allocation was working for me!
#If 0
  Dim dblParams As Array = Array.CreateInstance(GetType(Double), 1) ' Create an array of 1 double
  Dim dblGuessParams As Array = Array.CreateInstance(GetType(Double), 1) ' Create an array of 1 double
  Dim dblMaxDevs As Array = Array.CreateInstance(GetType(Double), 1) ' Create an array of 1 double
  Dim intFlags As Array = Array.CreateInstance(GetType(Integer), 1) ' Create an array of 1 integer
#Else
  Dim dblParams(0) As Double
  Dim dblGuessParams(0) As Double
  Dim dblMaxDevs(0) As Double
  Dim intFlags(0) As Integer
#End If
  Try
    objEdge1.GetParamAtPoint(1, sPnt, dblGuessParams, dblMaxDevs, dblParams, intFlags)
    Debug.WriteLine(String.Format("Parameter = {0}", dblParams(0)))
  Catch ex As Exception
    MessageBox.Show("Exception caught:" & vbCrLf & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  End Try
  
  Try
    objEdge1.GetParamAtPointEx(1, sPnt, dblParams)
    Debug.WriteLine(String.Format("Parameter = {0}", dblParams(0)))
  Catch ex As Exception
    MessageBox.Show("Exception caught:" & vbCrLf & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  End Try

 

Re: GetParamAtPoint does not work

hi MartinBernhard, thank you. It can work for parts constructed using SolidEdge commands. But i found that it sometimes failed for those imported through neutral files, like step.

In this case, for example, the boundary edges of a hole may be spline curves, instead of circle type.  Later, i use GetParamExtents method to get parameters on curves, for it can work for both kinds of parts above. In addition,   the function in the second method,  GetParamAtPointEx, is not supported in SolidEdge ST3.