Cancel
Showing results for 
Search instead for 
Did you mean: 

Need a VB Sample code for Bend table

Hi All,

I am the bigner of Solidedge API and i have tryed to get bend table data in solid edge.but i cont plz some to help and provide sample code (vb)

 

Vb code attached,

 

Dim objApp As SolidEdgeFramework.application
Dim objdoc As SolidEdgeFramework.documents
Dim objassemblyDocument As SolidEdgeAssembly.assemblyDocument
Dim objOccurrences As SolidEdgeAssembly.occurrences
Dim objtube As SolidEdgeAssembly.tube

Set objApp = CreateObject("SolidEdge.Application")
objApp.Visible = True

 


Set objassemblyDocument = objApp.documents.Open(selection_Path)

Set objOccurrences = objassemblyDocument.occurrences
Set objtube = objOccurrences.Item(1).GetTube


Dim CutLength As Object
Dim NumOfBends As Object
Dim FeedLength As Object
Dim RotationAngle As Object
Dim BendRadius As Object
Dim ReverseBendOrder As Object
Dim SaveToFileName As Object
SaveToFileName = "D:\Tube1.txt"
Dim BendAngle As Object
Dim getbendtable As Object

objtube.BendTable CutLength, NumOfBends, FeedLengthArray, RotationAngleArray, BendRadiusArray, ReverseBendOrder, SaveToFileName, BendAngleArrayse

8 REPLIES 8

Re: Need a VB Sample code for Bend table

Hi All, Some one help me...

Re: Need a VB Sample code for Bend table

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Hi @lmb_ramkumar_g,

you can find an example here:

https://github.com/SolidEdgeCommunity/Samples/tree/master/Assembly/ReportTubes

 

This is working for me

 

Edit:

Works also with modified variable declarations:

Snippet

Dim CutLength As Double
                    Dim NumOfBends As Integer
                    Dim FeedLengthArray(0) As Double
                    Dim RotationAngleArray(0) As Double
                    Dim BendRadiusArray(0) As Double
                    Dim ReverseBendOrder As Integer
                    Dim SaveToFileName As String = "c:\temp\bends.txt"
                    Dim BendAngleArray(0) As Double
 
                    tube.BendTable(CutLength:=CutLength, NumOfBends:=NumOfBends, FeedLength:=FeedLengthArray, RotationAngle:=RotationAngleArray, BendRadius:=BendRadiusArray, ReverseBendOrder:=ReverseBendOrder, SaveToFileName:=SaveToFileName, BendAngle:=BendAngleArray)

 

regards

JB
SE 2019, VS2017

Re: Need a VB Sample code for Bend table

Thanks, It is worked...

Re: Need a VB Sample code for Bend table

Genius
Genius

Hi @JB@lmb_ramkumar_g

 

I'm Trying to get the Bend Table information to ".txt" file.

As per the shared information about Github Code in the previous mail, I have modified the code and trying to get the details of the Tube. whatever the information saving to the text file is in meters & Radians like below shown.

Number of bends 	: 2
Cut Length 		: 0.286265
Bend Number 	 FeedLength 	 BendRadius 	 RotationAngle 	 BendAngle: 
1 	 	 0.084000  	 0.016000  	 0.000000 	 1.570796 
2 	 	 0.068000  	 0.016000  	 1.570796 	 1.570796 
3 	 	 0.084000  	 0.000000  	 0.000000 	 0.000000 

but I need the information in millimeters & degrees like below shown.

Cut Length = 286.27 mm
Bend Number         Feed Length         Rotation Angle      Bend Radius         Bend Angle          
1                   84.00 mm            0.00 °              16.00 mm            90.00 °             
2                   68.00 mm            90.00 °             16.00 mm            90.00 °             
3                   84.00 mm           

 so below is my code:

    Public Sub Main()
        Dim application As SolidEdgeFramework.Application = Nothing
        Dim documents As SolidEdgeFramework.Documents = Nothing
        Dim assemblyDocument As SolidEdgeAssembly.AssemblyDocument = Nothing
        Dim occurrences As SolidEdgeAssembly.Occurrences = Nothing
        Dim tube As SolidEdgeAssembly.Tube = Nothing

        ' Connect to or start Solid Edge.
        application = Marshal.GetActiveObject("SolidEdge.Application")

        ' Get the active document.
        assemblyDocument = application.ActiveDocument

        If assemblyDocument IsNot Nothing Then
            ' Get a reference to the Occurrences collection.
            occurrences = assemblyDocument.Occurrences

            For Each occurrence In occurrences.OfType(Of SolidEdgeAssembly.Occurrence)()
                If occurrence.IsTube() Then
                    tube = occurrence.GetTube()
                    Dim temp As String = occurrence.OccurrenceFileName
                    Dim Name As String = Path.getfilenamewithoutextension(temp)

                    Dim CutLength As Double
                    Dim NumOfBends As Integer
                    Dim FeedLengthArray As Object = New Double() {}
                    Dim RotationAngleArray As Object = New Double() {}
                    Dim BendRadiusArray As Object = New Double() {}
                    Dim ReverseBendOrder As Integer = 0
                    Dim SaveToFileName As Object = "C:\Users\sxv19\Desktop\Test\" & Name & ".txt"
                    Dim BendAngleArray As Object = New Double() {}

                    tube.BendTable(CutLength:=CutLength, NumOfBends:=NumOfBends, FeedLength:=FeedLengthArray, RotationAngle:=RotationAngleArray, BendRadius:=BendRadiusArray, ReverseBendOrder:=ReverseBendOrder, SaveToFileName:=SaveToFileName, BendAngle:=BendAngleArray)
                End If
            Next occurrence
        Else
            Throw New System.Exception("No active document.")
        End If
    End Sub

So, Please help to solve this issue.

 

Thanks & Regards

V.Sudheer

Re: Need a VB Sample code for Bend table

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Hi,

 

probably it is necessary to create the text file on your own by processing all returned array values as you like.

Kind regards,
Wolfgang Kunert - www.wksyspro.de

Re: Need a VB Sample code for Bend table

hi,

 

        If assemblyDocument IsNot Nothing Then
            ' Get a reference to the Occurrences collection.
            occurrences = assemblyDocument.Occurrences

            For Each occurrence In occurrences.OfType(Of SolidEdgeAssembly.Occurrence)()
                If occurrence.IsTube() Then
                    tube = occurrence.GetTube()
                    Dim temp As String = occurrence.OccurrenceFileName
                    Dim Name As String = Path.getfilenamewithoutextension(temp)

                    Dim CutLength As Double
                    Dim NumOfBends As Integer
                    Dim FeedLengthArray As Object = New Double() {}
                    Dim RotationAngleArray As Object = New Double() {}
                    Dim BendRadiusArray As Object = New Double() {}
                    Dim ReverseBendOrder As Integer = 0
                    Dim SaveToFileName As Object = "C:\Users\sxv19\Desktop\Test\" & Name & ".txt"
                    Dim BendAngleArray As Object = New Double() {}

 

tube.BendTable(CutLength:=CutLength, NumOfBends:=NumOfBends, FeedLength:=FeedLengthArray, RotationAngle:=RotationAngleArray, BendRadius:=BendRadiusArray, ReverseBendOrder:=ReverseBendOrder, SaveToFileName:=SaveToFileName, BendAngle:=BendAngleArray)

 

bt_part_array = 0

For i = 0 To NumOfBends
ReDim Preserve bendtable_part_array(bt_part_array)
If i = NumOfBends Then
bendtable_part_array(bt_part_array) = part_name & "|" & Round(CutLength * 1000, 2) & "|" & "P" & i + 1 & "|" & Round(FeedLengthArray(i) * 1000, 2) & "|" & 0 & "|" & 0 & "|" & 0
Else
bendtable_part_array(bt_part_array) = part_name & "|" & Round(CutLength * 1000, 2) & "|" & "P" & i + 1 & "|" & Round(FeedLengthArray(i) * 1000, 2) & "|" & Round(((RotationAngleArray(i) * 180) / 3.14159265358979), 2) & "|" & BendRadiusArray(i) * 1000 & "|" & Round(((BendAngleArray(i) * 180) / 3.14159265358979), 2)
End If
bt_part_array = bt_part_array + 1
Next i

ReDim Preserve bendtable_array(bt_array)
bendtable_array(bt_array) = bendtable_part_array
bt_array = bt_array + 1

 

  Next occurrence

 

Try this.....

 

 

Regards,

Ramkumar G

Re: Need a VB Sample code for Bend table

Genius
Genius

Hi @lmb_ramkumar_g,

 

Sorry for the late reply.

I tried incorporating your code in the existing code, it is not working, can you tell me how exactly it works.

 

Thanks & Regards

V.Sudheer

Re: Need a VB Sample code for Bend table

Genius
Genius

Hi @lmb_ramkumar_g,

 

Can you post your code for better understanding?

 

Thanks & Regards

V.Sudheer