Hi,
I'm making a tube that is connected on another tube. I did this by skeleton modeling, for my tube extrusion i used Extrude To surface.
Is there any way to get the length of that extrude?
I know its possible to get the sweep length like this. Is there a way to get the extrude length as well?
'Set a reference to the active part document Dim oDoc As PartDocument oDoc = ThisApplication.ActiveDocument Dim oDef As PartComponentDefinition oDef = oDoc.ComponentDefinition Dim opath As Path opath = oDef.Features.SweepFeatures.Item("TheSweep").Path Dim TotalLength As Double TotalLength = 0 Dim oCurve As Object Dim i As Integer For i = 1 To opath.Count oCurve = opath.Item(i).Curve 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 i Dim oparams As Parameters Dim oparam As Parameter oparams = oDoc.ComponentDefinition.Parameters Dim exists As Boolean exists = False 'Find out if parameter exists For Each oparam In oparams If oparam.Name = "Sweeplength" Then exists = True Next oparam 'Change the value if the parameter exists otherwise add the parameter If exists Then oparams.Item("Sweeplength").Value = TotalLength Else oparams.UserParameters.AddByValue( "Sweeplength", TotalLength, 11266) End If oDoc.Update
Thanks
If no one come up with an answer here, you may also try posting this in the Inventor Customization Forum.
Please see the code lines below, which is used to get the minumum distance between two faces, one is the start face of extrude, and the other is end face.
Sub test()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition
Set oCompDef = oDoc.ComponentDefinition
Dim oExtrude As ExtrudeFeature
Dim L As Double
For Each oExtrude In oCompDef.Features.ExtrudeFeatures
If oExtrude.Definition.ExtentType = kToExtent Then
L = ThisApplication.MeasureTools.GetMinimumDistance(oExtrude.StartFaces(1), oExtrude.Extent.ToFace(1))
MsgBox L * 10 & "mm"
End If
Next
End Sub
Hope it helpful for you!
Well not exactly, its for measuring tubes to get a correct length for my BOM. the minimum length is not usefull here.