How to use ilogic to measure length of edge ?

How to use ilogic to measure length of edge ?

Anonymous
Not applicable
2,401 Views
8 Replies
Message 1 of 9

How to use ilogic to measure length of edge ?

Anonymous
Not applicable

Capture.PNG

 I tried to find out but failed. Can help me with. When I do an edge like the picture below, it's ok, what if I convert it to ilogic code?

0 Likes
Accepted solutions (2)
2,402 Views
8 Replies
Replies (8)
Message 2 of 9

SharkDesign
Mentor
Mentor

What are you doing with that length? There may be an easier solution. 

 

I don't know how to do it with iLogic, but you will need to know the name of the edge. If you are doing this for multiple files you're probably best off naming the edge each time to make your code easier. 

 

  Inventor Certified Professional
Message 3 of 9

Anonymous
Not applicable

Thank you for your feedback

Body has 3 edges, I need to measure those three sides.

 

0 Likes
Message 4 of 9

SharkDesign
Mentor
Mentor

You want to measure the diameter of each end and the length of the sweep line?

 

What are you doing with these values afterwards?

 

  Inventor Certified Professional
0 Likes
Message 5 of 9

Anonymous
Not applicable

The problem is: I have a curved object, to know the length of this object, I proceed to use ilogic to measure the sides and get the appropriate length. when i perform edge measurement with measure tool in ilogic, i get this problem. can you help me? use ilogic

This object is a block imported from the *sat file, it will not have the feature...

0 Likes
Message 6 of 9

SharkDesign
Mentor
Mentor

OK, sorry I cannot help you, but there are other people who might be able to.

Not having any feature information or parameters is definitely going to make this more difficult. 

Do you have a lot of these files to measure?

 

 

  Inventor Certified Professional
0 Likes
Message 7 of 9

Anonymous
Not applicable

Since it has a lot i need to use ilogic to have it calculate automatically for me. Because if I do it manually, it will be wrong and take a long time. Thank you so much

0 Likes
Message 8 of 9

bhavik4244
Collaborator
Collaborator
Accepted solution

@Anonymous 

 

This link might useful to you,

https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/ilogic-to-get-lenght-of-line/td-p/6600489

 

You post this question to Inventor iLogic, API & VBA Forum where you could found the solution easily.

 

https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/bd-p/120

 


Bhavik Suthar
Message 9 of 9

torbjorn_heglum1
Collaborator
Collaborator
Accepted solution

If you are after the length of a sweep you could probably use this (From Inventor VBA, API help):

 

Sub TrueSweepLength()
    'Set a reference to the active part document
    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oDef As PartComponentDefinition
    Set oDef = oDoc.ComponentDefinition
    
    ' Check to make sure a sweep feature is selected.
    If Not TypeOf oDoc.SelectSet.Item(1) Is SweepFeature Then
        MsgBox "A sweep feature must be selected."
        Exit Sub
    End If

    ' Set a reference to the selected feature.
    Dim oSweep As SweepFeature
    Set oSweep = oDoc.SelectSet.Item(1)
    
    ' Get the centroid of the sweep profile in sketch space
    Dim oProfileOrigin As Point2d
    Set oProfileOrigin = oSweep.Profile.RegionProperties.Centroid
    
    ' Transform the centroid from sketch space to model space
    Dim oProfileOrigin3D As Point
    Set oProfileOrigin3D = oSweep.Profile.Parent.SketchToModelSpace(oProfileOrigin)
    
    ' Get the set of curves that represent the true path of the sweep
    Dim oCurves As ObjectsEnumerator
    Set 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
        Set 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
    
    ' Display total sweep length
    MsgBox "Total sweep length = " & ThisApplication.UnitsOfMeasure.GetStringFromValue(TotalLength, kInchLengthUnits)
End Sub

Torbjørn