cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Sweep Length To Parameter

Sweep Length To Parameter

This time the question from a key Autodesk Inventor user was if it was possible to create a add-in that represents the sweep length in a parameter.
With the command "Sweep length" a User parameter is created with the name of the sweep and with the value the length of the selected sweep feature path.
Maybe this is a good addition for future releases of Autodesk Inventor.

4 Comments

For those who want to test the add-in for Inventor 2025 please install/copy the unzipped folder "KnoorsInventorToolsCalculateSweepLength" to :

%AppData%\Roaming\Autodesk\ApplicationPlugins

swalton
Mentor

I often need the length of sweeps or even closed profiles as a parameter.  Lately, I've been working on a chain mechanism and need the path length so I can ensure that it uses an integer number of chain links.  We also use sweeps to represent flexible conduit and hoses. 

 

Anyway, I tried to test the code above and it wants some sort of license.  I don't see a way to request one.

 

 

I just send you a message with the explanation.

CStilesCARE
Advocate

For those of you not averse to using iLogic as a work-around in the meantime, I've cobbled together the below code which is intended to be placed as a rule into a part file with one or more sweep features, and will add their lengths to user parameters when triggered.

 

I generally set the rule to trigger "before save", so the values are updated every time I save the file. 

 

' Internal rule for Part files that will attempt to find all SWEEP features and copy their length into 
' User parameters.


'Set a bunch of variables.
Dim oMTools As Inventor.MeasureTools = ThisApplication.MeasureTools
Dim oDoc As PartDocument = ThisDoc.Document
Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim oFeats As PartFeatures = oCompDef.Features
Dim oSweeps As SweepFeatures = oFeats.SweepFeatures
Dim oParams As Parameters = oCompDef.Parameters
Dim oParam As Inventor.Parameter

'Quit Rule if no sweep features are found.
If oSweeps.Count = 0 Then
    MsgBox("No sweeps found. Cancelling rule.")
    Exit Sub
End If

'Set base name for added user parameter(s).
Dim oPBaseName As String = "Sweep_L" ' ** Change this text to change base name for sweeps. **

Dim oPName As String = ""
Dim oPCmnt As String = ""
Dim dLength As Double
Dim oSCnt As Integer = 0

For Each oSweep As SweepFeature In oSweeps
	oSCnt = oSCnt + 1
	oPName = oPBaseName & oSCnt.ToString
	dLength = Round(oMTools.GetLoopLength(oSweep.Path), 3)

	Try
		oParam = oParams.UserParameters(oPName)
		
		If oParam.Value <> dLength Then oParam.Value = dLength
			
	Catch
	    oParam = oParams.UserParameters.AddByValue(oPName, dLength, Inventor.UnitsTypeEnum.kInchLengthUnits)
	End Try
	
	oPCmnt = "Pulled From Sweep Feature - " & oSweep.Name
	If oParam.Comment <> oPCmnt Then oParam.Comment = oPCmnt
'	If oParam.ExposedAsProperty <> True Then oParam.ExposedAsProperty = True
Next oSweep

RuleParametersOutput()
InventorVb.DocumentUpdate()

 

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

Submit Idea