Message 1 of 6
Incomplete result of official 'True length of sweep feature' Code Sample
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've discovered that official 'True length of sweep feature' Code Sample returns wrong (?path length to one direction from the profile?) value on some samples (see attached for 2024)
Here is the code converted from VBA to iLogic (the sweep feature is supposed to be pre-selected):
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition
oDef = oDoc.ComponentDefinition
' If Not TypeOf oDoc.SelectSet.Item(1) Is SweepFeature Then
If Not TypeOf oDoc.SelectSet.Item(1) Is SweepFeature Then
MsgBox("A sweep feature must be selected.")
Exit Sub
End If
Dim oSweep As SweepFeature
oSweep = oDoc.SelectSet.Item(1)
Dim oProfileOrigin As Point2d
oProfileOrigin = oSweep.Profile.RegionProperties.Centroid
Dim oProfileOrigin3D As Point
oProfileOrigin3D = oSweep.Profile.Parent.SketchToModelSpace(oProfileOrigin)
Dim oCurves As ObjectsEnumerator
oCurves = oDef.Features.SweepFeatures.GetTruePath(oSweep.Path, oProfileOrigin3D)
Dim TotalLength As Double
TotalLength = 0
Dim oCurve As Object
For Each oCurve In oCurves
Dim oCurveEval As CurveEvaluator
oCurveEval = oCurve.Evaluator
Dim MinParam As Double
Dim MaxParam As Double
Dim Length As Double
Call oCurveEval.GetParamExtents(MinParam, MaxParam)
Call oCurveEval.GetLengthAtParam(MinParam, MaxParam, Length)
TotalLength = TotalLength + Length
Next
MsgBox("Total sweep length, mm = " & ThisApplication.UnitsOfMeasure.GetStringFromValue(TotalLength, kMillimeterLengthUnits)) ' kInchLengthUnits))
It returns value ~161mm (while expected value is ~300mm)
What I'm missing? How should the code be modified to return full sweep path length?
Dear @MjDeck could you, please, study this case?
Please vote for Inventor-Idea Text Search within Option Names