Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Question: Extrude To length

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
405 Views, 3 Replies

Question: Extrude To length

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

3 REPLIES 3
Message 2 of 4
mrattray
in reply to: Anonymous

If no one come up with an answer here, you may also try posting this in the Inventor Customization Forum.

Mike (not Matt) Rattray

Message 3 of 4
Yijiang.Cai
in reply to: Anonymous

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!

Thanks,
River Cai

Inventor Quality Assurance Team
Autodesk, Inc.
Email: River-Yijiang.Cai@autodesk.com
Message 4 of 4
Anonymous
in reply to: Yijiang.Cai

Well not exactly, its for measuring tubes to get a correct length for my BOM. the minimum length is not usefull here.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report