Evaluator of EdgeUse vs Edge

By Adam Nagy

EdgeUse is an object that provides information in context of one of the Face’s the Edge belongs to. The Curve2dEvaluator you get from this object’s Evaluator property also provides information in context of the Face, which also means that the returned coordinates are in the parametric space of the Face (u, v)
If you want to get the model coordinates of a point then you can use the Face’s Evaluator to convert the u,v coordinates to model coordinates (x, y, z) 

Edge on the other hand provides information in context of the model space, and the Curve2dEvaluator you get from its Evaluator property returns model space coordinates.

The following is a sample with made up coordinates – in a real case the 0 u,v coordinates might not be at the start of a Face or Edge – you need to retrieve the minimum/maximum values using the appropriate functions.

EdgeUse

 

Here is a VBA code that shows the relation between the EdgeUse Evaluator‘s u coordintate, the Face‘s u, v coordinates and the model space coordinates – select a face before running the code:

Sub PlaceParametricPoints()
  Dim oDoc As PartDocument
  Set oDoc = ThisApplication.ActiveDocument
  Dim oFace As Face
  Set oFace = oDoc.SelectSet(1)
  Dim oCompDef As PartComponentDefinition
  Set oCompDef = oDoc.ComponentDefinition
  Dim oWPs As WorkPoints
  Set oWPs = oCompDef.WorkPoints
  Dim oEdgeLoop As EdgeLoop
  For Each oEdgeLoop In oFace.EdgeLoops
    Dim oEdgeUse As EdgeUse
    For Each oEdgeUse In oEdgeLoop.EdgeUses
      Dim oEval As Curve2dEvaluator
      Set oEval = oEdgeUse.Evaluator
      ' Get min and max point in
      ' parametric space of curve
      Dim oMinU As Double
      Dim oMaxU As Double
      Call oEval.GetParamExtents(oMinU, oMaxU)
      ' Get the same points in the parametric
      ' space of the face
      Dim oParams(1) As Double
      Dim oFaceUV() As Double
      oParams(0) = oMinU
      oParams(1) = oMaxU
      Call oEval.GetPointAtParam(oParams, oFaceUV)
      ' Get the same points in the model coordinate
      ' system
      Dim oModel() As Double
      Call oFace.Evaluator.GetPointAtParam(oFaceUV, oModel)
      Dim oTG As TransientGeometry
      Set oTG = ThisApplication.TransientGeometry
      Call oWPs.AddFixed(oTG.CreatePoint( _
        oModel(0), oModel(1), oModel(2)))
      Debug.Print _
        "> Min Point >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + vbCrLf + _
        " Edge  u = " + str(oMinU) + vbCrLf + _
        " Face  u = " + str(oFaceUV(0)) + _
        ", v = " + str(oFaceUV(1)) + vbCrLf + _
        " Model x = " + str(oModel(0)) + _
        ", y = " + str(oModel(1)) + _
        ", z = " + str(oModel(2)) + vbCrLf + _
        "> Max Point >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + vbCrLf + _
        " Edge  u  = " + str(oMaxU) + vbCrLf + _
        " Face  u  = " + str(oFaceUV(2)) + _
        ", v = " + str(oFaceUV(3)) + vbCrLf + _
        " Model x = " + str(oModel(3)) + _
        ", y = " + str(oModel(4)) + _
        ", z = " + str(oModel(5))
    Next
  Next
End Sub

Have a look at the following document for more information: mathgeometry.pdf 


Comments

2 responses to “Evaluator of EdgeUse vs Edge”

  1. Kari Holgarsson Avatar
    Kari Holgarsson

    Hi
    Thanks for sharing.
    Are the following commands available through iLogic?
    -Call oEval.GetPointAtParam(oParams, oFaceUV)
    -Call oFace.Evaluator.GetPointAtParam(oFaceUV, oModel)
    I get the following error
    “Type mismatch”

  2. Kari Holgarsson Avatar
    Kari Holgarsson

    Hi
    I found the solution:
    http://adndevblog.typepad.com/manufacturing/2014/07/type-mismatch-error-with-vba-code-in-net.html
    Arrays of variable size are handled differently in VB.Net
    Thanks for sharing

Leave a Reply to Kari HolgarssonCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading