Ilogic to get lenght of line

Ilogic to get lenght of line

Anonymous
Not applicable
1,813 Views
2 Replies
Message 1 of 3

Ilogic to get lenght of line

Anonymous
Not applicable

Hi,

 

My Ilogic knowledge is basic, so I am probable doing something wrong that is obvious to you experts...

 

I want to select a line in a assembly document and get the length of the selected line. The line would be a model edge of a part in the top level assembly or a model edge of a part in a sub assembly.

 

So far I am selecting 2 points and trying to measure between them (ideally I would like to select a line)

 

 

Dim Point1 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.KPartVertexFilter,"Select lenght start")
Dim Point2 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.KPartVertexFilter,"Select lenght end")

dis = Measure.MinimumDistance(Point1, Point2)

MessageBox.Show(dis, "Title")

 

0 Likes
Accepted solutions (1)
1,814 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

mikey,

 

I have a piece of code, posted below, that I use which accomplishes what you are trying to do. In this code, instead of prompting the user to select an edge, the user would select an edge then run the rule to get the length. It works within the Part and Assembly environment. I hope this helps.

 

iLogic Code

 

Sub Main()

Dim oApp As Application
oApp = ThisApplication

Dim oDoc As Document
oDoc = oApp.ActiveDocument

' Get selection set
Dim oSelSet As SelectSet
oSelSet = oDoc.SelectSet

' If no objects are selected, then exit
If oSelSet.Count = 0 Then Exit Sub

Dim oEdge As Object
' Get Edge or EdgeProxy object (Edge for part environment and EdgeProxy for assembly environment)
oEdge = oSelSet.Item(1)

' If selected object is not of type Edge or EdgeProxy then exit
If (Not TypeOf oEdge Is Edge) And (Not TypeOf oEdge Is EdgeProxy) Then
	Exit Sub
End If

' Get length between endpoints of edge [cm]
Dim dLength As Double
dLength = oApp.MeasureTools.GetMinimumDistance(oEdge.StartVertex, oEdge.StopVertex)

' Display length of line
MsgBox(dLength & " cm",vbOKOnly, "Edge Length")

End Sub
Message 3 of 3

Anonymous
Not applicable

Brilliant! Thank you!!! 🙂

0 Likes