Bendline information from selected bend extend line in drawing

Bendline information from selected bend extend line in drawing

LarsBJepsen
Advocate Advocate
448 Views
2 Replies
Message 1 of 3

Bendline information from selected bend extend line in drawing

LarsBJepsen
Advocate
Advocate

As a sub of a code i'm writing, I need to access the bendline information refered by a selected bend extendline. In other words: i select a bend extend line, and would like to get information about the bend. Any suggestions?

0 Likes
449 Views
2 Replies
Replies (2)
Message 2 of 3

JhoelForshav
Mentor
Mentor

Hi @LarsBJepsen 

I found some code here:
https://adndevblog.typepad.com/manufacturing/2013/08/inventor-access-sheet-metal-part-bend-informati...

 

, and rewrote it a bit for ilogic.

Try this ilogic rule to get bend information from bend line 🙂

 

Sub Main

	Dim oDoc As DrawingDocument

	oDoc = ThisApplication.ActiveDocument



	'Gets the selected curve segment

	Dim oDwCurveSegment As DrawingCurveSegment

	oDwCurveSegment = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select bend line")

	Try

		'Gets full drawing curve from the segment

		Dim oDrawingCurve As DrawingCurve

		oDrawingCurve = oDwCurveSegment.Parent



		'Gets edge

		Dim oEdge As Edge

		oEdge = oDrawingCurve.ModelGeometry



		'Retrieves component definition from the edge

		Dim oSMDef As SheetMetalComponentDefinition

		oSMDef = oEdge.Parent.ComponentDefinition



		Dim oFlatPattern As FlatPattern

		oFlatPattern = oSMDef.FlatPattern



		'Gets flat bend result corresponding to the edge

		Dim oBendResult As FlatBendResult

		oBendResult = oFlatPattern.FlatBendResults.Item(oEdge)


		Dim oReturnString As String = String.Empty
		'Prints Flat Bend Results

		oReturnString = oReturnString & "---------------- Flat Bend Infos ----------------" & vbCrLf

		oReturnString = oReturnString & "Internal Name: " & oBendResult.InternalName & vbCrLf

		If oBendResult.IsOnBottomFace Then

			oReturnString = oReturnString & "Bend On Bottom Face" & vbCrLf

		Else

			oReturnString = oReturnString & "Bend On Top Face" & vbCrLf

		End If



		Dim oUOM As UnitsOfMeasure

		oUOM = oDoc.UnitsOfMeasure



		oReturnString = oReturnString & "Bend Angle  = " & oUOM.GetStringFromValue(oBendResult.Angle, kDefaultDisplayAngleUnits) & vbCrLf

		oReturnString = oReturnString & "Bend Radius = " & oUOM.GetStringFromValue(oBendResult.InnerRadius, kDefaultDisplayLengthUnits) & vbCrLf



		If oBendResult.IsDirectionUp Then

			oReturnString = oReturnString & "Bend Direction: " & "Bend Up" & vbCrLf

		Else

			oReturnString = oReturnString & "Bend Direction: " & "Bend Down" & vbCrLf

		End If




		Beep
		MsgBox(oReturnString)

	Catch
		GoAgain = MessageBox.Show("This is not a bend line, select another line?", "Show bend info", MessageBoxButtons.YesNo)
		If GoAgain = 6 Then
			Main()
		Else
			Exit Sub
		End If
	End Try
End Sub

 

0 Likes
Message 3 of 3

LarsBJepsen
Advocate
Advocate

Thanks, but in this case i need to select the bend line in order to retrieve the information. I would like to select a bend extend line and then get the information from the corresponding bendline.

0 Likes