Sweep length measurement

Sweep length measurement

G60Dub
Advocate Advocate
3,598 Views
4 Replies
Message 1 of 5

Sweep length measurement

G60Dub
Advocate
Advocate

Hi everyone

I have a conundrum here.  I am authoring a Bowden Cable assembly driven via a form.

 

In short the user keys in several parameters from the destination model such as inner distance between mounting brackets, axial offset between each end, both mounting bracket thicknesses, free length at each end and each end threaded length... and it works great... A user can copy design the part type if a few parameters and have a Bowden Cable representation that they can drop straight into their larger assembly model.

 

However, what I now wish to do is spit out a drawing with parameters that we can send to our cable supplier and this is where I am running into difficulty.

 

The inner cable is made from 3 sections -straight sectioned free end lengths at each and and an inner sweep.  I have two solids in the part - Inner cable and outer sheath. This ipt is then dropped into a Bowden assembly model containing the cable end jam nuts and bracket mounting nuts. It's not a correct assy per say as it only needs to visually represent the real purchased part. 

 

So what I need to do is calculate (via iLogic) the inner and outer cable length.  I had a look over the forum and saw one method for obtaining the sweep length   here:

https://forums.autodesk.com/t5/inventor-forum/loop-length/td-p/3121626

 

However the total fx length gets messed up when I try to add my straight sections onto the  total length - My total length when displayed in a messagebox seems to be out by a factor of '/10' before I ad my straight sections on.

 

Perhaps another way to implement it to to get the volume of the solids and divide out by the cable Ø and similar for the outer cable but I have no idea programatically how to query individual solid body volumes.

Inventor Professional 2025.3.2
Vault Professional 2025.3
0 Likes
Accepted solutions (2)
3,599 Views
4 Replies
Replies (4)
Message 2 of 5

imajar
Advisor
Advisor

When you say off by a factor of 10 - I assume you know that the inventor API units are cm regardless of what part units you have set?  But if you are reading in user input values, I assume you know that . . . (unless maybe the inventor form is automatically converting the units from document units to cm automatically?)

 

Outside of that, the guys on the customization forum are way better at ilogic and api stuff:  https://forums.autodesk.com/t5/inventor-customization/bd-p/120


Aaron Jarrett, PE
Inventor 2019 | i7-6700K 64GB NVidia M4000
LinkedIn

Life is Good.
0 Likes
Message 3 of 5

andrewiv
Mentor
Mentor
Accepted solution

I would check the units and verify that you have the correct conversions as @imajar mentioned.

 

Here is some code that I put together for getting the length of a spline and any lines attached at the ends.  This way you shouldn't have to add the line lengths after you get the spline length.

Dim oDoc As PartDocument
Dim oLine As SketchEntity3D
Dim oParameters As Inventor.Parameters
Dim oSketchName As String = "3D Sketch1"
Dim oParamName As String = "Length"

oDoc = ThisDoc.Document
oLine = oDoc.ComponentDefinition.Sketches3D(oSketchName).SketchLines3D(1)
oParameters = oDoc.ComponentDefinition.Parameters
oParameters.Item(oParamName).Value = ThisApplication.MeasureTools.GetLoopLength(oLine)

iLogicVb.UpdateWhenDone = True

 

Andrew In’t Veld
Designer / CAD Administrator

Message 4 of 5

G60Dub
Advocate
Advocate

Thanks @imajar ; I was not aware that the internal units are mm and it seems clear now that I'm adding my 'mm' parameters to internal 'cm' hence it's returning garbage values.

 

To be honest if it's anything other than basic manipulation of variables or writing out to custom iProperties then I'm pretty poor with iLogic as I've never found a decent reference or learning tools for the API.  

 

@andrewiv with regard to the code you kindly submitted- this is for a 3D sketch?   My sweep is along a 2D sketch and I am not any good at navigating the object models so how would I modify this for a 2D sweep?

Inventor Professional 2025.3.2
Vault Professional 2025.3
0 Likes
Message 5 of 5

andrewiv
Mentor
Mentor
Accepted solution

This is the code modified for a 2D sketch.  I also made it so that if the parameter doesn't exist it will create it first.

 

Dim oDoc As PartDocument
Dim oLine As SketchEntity
Dim oParameters As Inventor.Parameters
Dim oSketchName As String = "Sketch1"  'Change to match your sketch name
Dim oParamName As String = "Length"  'Change to match the name of the parameter

oDoc = ThisDoc.Document
oLine = oDoc.ComponentDefinition.Sketches(oSketchName).SketchSplines(1)
oParameters = oDoc.ComponentDefinition.Parameters

Try
	oParameters.Item(oParamName).Value = ThisApplication.MeasureTools.GetLoopLength(oLine)
Catch
	Dim oUserParam As UserParameter
	oUserParam = oParameters.UserParameters.AddByValue(oParamName, 1, "mm")
	oParameters.Item(oParamName).Value = ThisApplication.MeasureTools.GetLoopLength(oLine)
End Try

iLogicVb.UpdateWhenDone = True

 

Andrew In’t Veld
Designer / CAD Administrator