Cancel
Showing results for 
Search instead for 
Did you mean: 

XpressRoute Tubing with VB.net

Genius
Genius

Hello Dev. Team, Happy New Year.

 

I'm trying to create tubes in Xpressroute by using Vb.net.

 

Check the below image for reference.

line.JPG

 

I have 7 Line segments with different item id's,

 

Please find the below code what I'm using:

 

Imports System.IO
Imports System.Runtime.InteropServices
Imports SolidEdgeFramework
Imports SolidEdgeConstants
Imports SolidEdgeAssembly

Public Class Form1
    Dim oApp As SolidEdgeFramework.Application = Nothing
    Dim oDoc As SolidEdgeFramework.SolidEdgeDocument = Nothing
    Dim oAsm As SolidEdgeAssembly.AssemblyDocument = Nothing
    Dim Occs As SolidEdgeAssembly.Occurrences = Nothing
    Dim Occ As SolidEdgeAssembly.Occurrence = Nothing
    Dim sb As New System.Text.StringBuilder

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    End Sub
    Private Sub ExecuteBtn_Click(sender As Object, e As EventArgs) Handles ExecuteBtn.Click

        RanNum()
        Dim MAT As String = "copper"
        Dim BR As Integer = 20 / 1000
        Dim OD As Integer = 12 / 1000
        Dim WT As Integer = 1.5 / 1000

        oApp = Marshal.GetActiveObject("SolidEdge.Application")
        oDoc = oApp.ActiveDocument
        Dim TFN As String = "C:\Program Files\Solid Edge ST8\Template\ANSI Metric\ansi metric part.par"
        Dim PFN As String = oDoc.Path & "\" & sb.ToString() + ".par"
        Dim LineSegments As SolidEdgeAssembly.LineSegments = oDoc.LineSegments
        Dim Linesegment As SolidEdgeAssembly.LineSegment = oDoc.ActiveSketch
        Dim Lcount As Integer = Nothing
        Dim Selset As SolidEdgeFramework.SelectSet = Nothing

        Selset = oDoc.SelectSet
        Lcount = Selset.Count - 1

        Dim Lin(Lcount) As Object
        For i = 0 To Lcount
            Lin(i) = LineSegments(i)
        Next

        Occs = oDoc.Occurrences
        Occ = Occs.AddTube(TubeSegments:=Lin, PartFileName:=PFN, TemplateFileName:=TFN, IsSolid:=False, Material:=MAT, BendRadius:=BR, OuterDiameter:=OD, WallThickness:=WT)
    End Sub

Sub RanNum()
        Dim s As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
        Dim r As New Random
        'Dim sb As New System.Text.StringBuilder
        For i As Integer = 1 To 8
            Dim idx As Integer = r.Next(0, 35)
            sb.Append(s.Substring(idx, 1))
        Next
        'MsgBox(sb.ToString())
    End Sub
End Class

Yes, with this code, I'm able to create New Tubes with Random Name in XpressRoute.

 

in the above code, I wrote a For Loop from '0' to Lcount (No.of Line segments selected), here is my problem, this code is not generating tube for what I have selected line segments. 

 

Example: If I select Item(5) & (6), tube is generating for Item(1) & (2). 

 

I guess I forgot to add selected line segment Item id's to the selection set.

 

Can anyone, please suggest me whereI'm getting a problem.

 

Thanks & Regards

V.Sudheer

7 REPLIES 7

Re: XpressRoute Tubing with VB.net

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Hi @VSudheer,

in your code from the select set you are only using the count of the selected elements.

But then you are using the LineSegments collection. I would suppose that accessing LineSegments(0) will throw an excepetion. The LineSegments collection is sorted in the order you noted in your picture and not in the order you selected with the mouse.

If you want to use the selected elemenet, fill the array from the SelSet variable. Check if every element is a LineSegment. 

So the loop should at least look like:

        For i = 0 To Lcount
            Lin(i) = SelSet(i+1)
        Next

 

regards

JB
SE 2019, VS2017

Re: XpressRoute Tubing with VB.net

Genius
Genius

Hi @JB,

 

Awesome, your solution fulfills my code in crossing the hurdles.

Now My program able to create the Tubes for the selected sketch in XpressRoute Module.

Thank you so much for your immediate Help.

 

Thanks & Regards

V.Sudheer.

Re: XpressRoute Tubing with VB.net

Genius
Genius

Hi @JB,

 

I got one more problem when line segments are not in sequence, just like below shown.

Please check the Item(id) numbers and also like arrow marks. Here each line-segment have key points like start point (S) and end point (E). In general sequence, Keypoints are like S:E: S:E: S:E. But in this case we have S:E: S:E: ESmiley Frustrated .

 

 

Capture-5.JPG

 

When I'm generating the tube for this kind of line segments, the entire path is getting failed, like below shown.Capture-2.JPG For that, I gave dimensions to the line-segments like below shown.Capture-3.JPG

If I do like this, my program generating the Tube, but again all constraints of the line-segments are getting failed and also dimensions too, as below shown.Capture-4.JPG

 

But this is not the correct procedure, so, Please let me know if we have any solution for this issue?

 

Thanks & Regards

V.Sudheer

 

Re: XpressRoute Tubing with VB.net

Genius
Genius

Hi @JB,

 

If the line segments are in sequence, my program generating the tube. If the line segments are not in the sequence like as shown below.Capture-5.JPG

If you check the Item(Id) of line segment Item(1) & (2) from one direction and Item(3)-(5) are in another direction.

so here each line segment has respective key points like Start Point(S) and End Point (E). in general sequence key points should be like this S-E-S-E-S-E, but in this case, key points are like this S-E-S-E-E-S-E-S.

when I'm trying to create the tube this path, all constraints are failing and not at all generating the tube like as shown below.

Capture-2.JPG

for that, I gave the dimensions to the line segments and trying to generate the Tube, here providing the dimensions are not in my scope.

 

Capture-3.JPG

now my program generated the tube with failed constraints and dimensions like shown below.Capture-4.JPG

 

 

So, is there any solution to avoid failing the constraints of the selected path.

 

Thanks & Regards

V.Sudheer

ST8 - VS2017 - Windows-10

Re: XpressRoute Tubing with VB.net

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Hi @VSudheer, 

in what order are you selecting?

1-2-3-4-5 or 1-2-5-4-3

regards

JB
SE 2019, VS2017

Re: XpressRoute Tubing with VB.net

Genius
Genius

Hi @JB,

 

When I'm selecting 1-2-3-4-5, the tube is generating for 1-2-5 as shown below.Capture-6.JPG

 

 

When I'm selecting 1-2-5-4-3, the path is failing.

 

Thanks & Regards

V.Sudheer

 

Re: XpressRoute Tubing with VB.net

Genius
Genius

Hi @JB,

 

I got the solution for this issue.

I have added "AddConnectRelations:=False" in AddTube Method, now it is working fine.

 

AddTube Method from SDK.

-AddConnectRelations: Specifies whether or not connect relationships are placed at all of the points where any two segments meet. If connect relationships are already present, AddConnectRelations should be False.

 

Thanks & Regards

V. Sudheer