By Adam Nagy
The SurfaceEvaluator object has a GetIsoCurve function that can return a curve on the surface running in the U or V parametric direction.
The function's UDirection parameter could be confusing. It tells the function if the curve should be along the U or V parametric direction, and not what the passed in parameter should be: i.e. in case of UDirection = True you get back a curve that runs in the U parametric direction, but the parameter you pass to the function should be a V parametric value.
Here is a function that goes along the U direction of a Face and creates WorkPoints there plus creates a circle based on what GetIsoCurve(UDirection = False) returns:
Sub GetIsoCurveTest() Dim doc As PartDocument Set doc = ThisApplication.ActiveDocument Dim cd As PartComponentDefinition Set cd = doc.ComponentDefinition Dim f As Face For Each f In cd.SurfaceBodies(1).Faces ' We only deal with the cylindrical side face now If TypeOf f.Geometry Is Cylinder Then Dim s As SurfaceEvaluator Set s = f.Evaluator Dim paramRange As Box2d Set paramRange = s.ParamRangeRect ' Create points along U direction Dim uDif As Double uDif = (paramRange.MaxPoint.x - paramRange.MinPoint.x) / 5 Dim tr As TransientGeometry Set tr = ThisApplication.TransientGeometry Dim wps As WorkPoints Set wps = cd.WorkPoints Dim i As Integer For i = 0 To 5 Dim pt() As Double Dim params(1) As Double params(0) = paramRange.MinPoint.x + (uDif * i) params(1) = paramRange.MinPoint.y Call s.GetPointAtParam(params, pt) Call wps.AddFixed(tr.CreatePoint(pt(0), pt(1), pt(2))) Next ' Get IsoCurve in the V direction (UDirection = False) ' at the mid U parametric position ' In case of our model this should provide a Circle Dim midU As Double midU = (paramRange.MinPoint.x + paramRange.MaxPoint.x) / 2# Dim oc As ObjectCollection Set oc = s.GetIsoCurve(midU, False) Dim circ As Inventor.Circle Set circ = oc(1) Dim s3d As Sketch3D Set s3d = cd.Sketches3D.Add() ' Show it in the UI by adding it to a 3d sketch Call s3d.SketchCircles3D.AddByCenterRadius( _ circ.Center, circ.Normal, circ.Radius) End If Next End Sub
The result is:
In case of the above cylinder's side Face if you call the GetIsoCurve with UDirection = True then you'll get back a straight LineSegment (and the passed in parameter should be along the V direction, Point2d.Y), but if pass in UDirection = False then the returned curve will be a Circle (and the passed in parameter should be along the U direction, Point2d.X) - this is highlighted in blue in the above picture.