Showing results for 
Search instead for 
Did you mean: 

Can't make lines with visual

Valued Contributor
Valued Contributor


I made an console application to make curves and line in Solid Edge with the methods Bsplinecurve2d and lines2d. I use data from a text file to make the curves. The problem is no line is drawn and i don't get whu, because visual basic isn't ging any errors. And the data does get calculated and stored into arrays.

Maybe the probelm is that i'm using visul basic 2003 with Solid Edge ST2?

Can some give a look at my code?

Thanks in advance.

[code type=vbnet]Imports System.IO

Imports System.Runtime.InteropServices

Imports System.Collections


Module Module1

Sub Main()


Dim strFileName As String = "U:\pompen.prn"

Dim objFS As New FileStream(strFileName, FileMode.Open, FileAccess.Read)

Dim objSR As New StreamReader(objFS)


Dim objApp As SolidEdgeFramework.Application = Nothing

Dim objDocuments As SolidEdgeFramework.Documents = Nothing

Dim objPart As SolidEdgePart.PartDocument = Nothing

Dim objProfileSets As SolidEdgePart.ProfileSets = Nothing

Dim objProfileSet As SolidEdgePart.ProfileSet = Nothing

Dim objProfiles As SolidEdgePart.Profiles = Nothing

Dim objProfile As SolidEdgePart.Profile = Nothing

Dim objRefplanes As SolidEdgePart.RefPlanes = Nothing

Dim objBspline As SolidEdgeFrameworkSupport.BSplineCurve2d = Nothing

Dim objBsplines As SolidEdgeFrameworkSupport.BSplineCurves2d = Nothing

Dim objLines2d As SolidEdgeFrameworkSupport.Lines2d = Nothing

Dim objLine2d As SolidEdgeFrameworkSupport.Line2d = Nothing


Dim strEmpRecord As String

Dim type As String

Dim N1 As Double

Dim QT As Double

Dim DW1 As Double

Dim EQ As Double

Dim EH As Double

Dim DWL As Double

Dim DHL As Double

Dim C1 As Double

Dim C2 As Double

Dim C3 As Double

Dim C4 As Double

Dim C5 As Double

Dim QFACTOR As Double


Dim q As Double

Dim h As Double

Dim qx As Double

Dim hx As Double

Dim qa As Double

Dim ha As Double

Dim qeind As Double

Dim qeind2 As Double



'connect to a Solid Edge file.

'Connect to a running instance of Solid Edge

objApp = Marshal.GetActiveObject("SolidEdge.Application")

'Get a reference to the documents collection

objDocuments = objApp.Documents

'Create a new part document

objPart = objDocuments.Add("SolidEdge.PartDocument")

'Get a reference to the profile sets collection

objProfileSets = objPart.ProfileSets

'Add a new profile set

objProfileSet = objProfileSets.Add()

'Get a reference to the profiles collection

objProfiles = objProfileSet.Profiles

'Get a reference to the ref planes collection

objRefplanes = objPart.RefPlanes

'Add a new profile

objProfile = objProfiles.Add(objRefplanes.Item(3))

'Get a reference to spline curve collection

objBsplines = objProfile.BSplineCurves2d

'Get a reference to the lines2d collection

objLines2d = objProfile.Lines2d



Dim nfi As Globalization.NumberFormatInfo = New Globalization.CultureInfo("en-US", False).NumberFormat

nfi.NumberGroupSeparator = " "

nfi.NumberDecimalSeparator = ","



Do While objSR.Peek <> -1

' read the current record (line) into the variable strEmpRecord

strEmpRecord = objSR.ReadLine


' break up the record into separate variables

type = strEmpRecord.Substring(1, 19)

N1 = CDbl(strEmpRecord.Substring(20, 9))

QT = CDbl(strEmpRecord.Substring(30, 9))

DW1 = CDbl(strEmpRecord.Substring(40, 9))

EQ = CDbl(strEmpRecord.Substring(50, 9))

EH = CDbl(strEmpRecord.Substring(60, 9))

DHL = CDbl(strEmpRecord.Substring(70, 9))

DWL = CDbl(strEmpRecord.Substring(80, 9))

C1 = CDbl(strEmpRecord.Substring(90, 19))

C2 = CDbl(strEmpRecord.Substring(110, 19))

C3 = CDbl(strEmpRecord.Substring(130, 19))

C4 = CDbl(strEmpRecord.Substring(150, 19))

C5 = CDbl(strEmpRecord.Substring(170, 19))

QFACTOR = CDbl(strEmpRecord.Substring(190, 3))

Catch ex As System.InvalidCastException

End Try




Dim i As Double

Dim listofdata As New ArrayList

For i = 0.2 To QFACTOR Step 0.1

q = (i * QT)

h = (((q ^ 4) * C1) + ((q ^ 3) * C2) + ((q ^ 2) * C3) + (q * C4) + C5)




Dim dataArray() As Double

dataArray = DirectCast(listofdata.ToArray(GetType(Double)), Double())



qx = ((DWL / DW1) ^ EQ)

hx = ((DWL / DW1) ^ EH)

Dim listofdata2 As New ArrayList

For i = 0.2 To 1.5 Step 0.1

q = (i * QT)

qa = (qx * q)

ha = (hx * (((q ^ 4) * C1) + ((q ^ 3) * C2) + ((q ^ 2) * C3) + (q * C4) + C5))




Dim data2Array() As Double

data2Array = DirectCast(listofdata2.ToArray(GetType(Double)), Double())




'make connection lines

qeind = (QFACTOR * QT)

qeind2 = (qx * qeind)

objLine2d = objLines2d.AddBy2Points(qeind2, (hx * (((qeind2 ^ 4) * C1) + ((qeind2 ^ 3) * C2) + ((qeind2 ^ 2) * C3) + (qeind2 * C4) + C5)), qeind, (((qeind ^ 4) * C1) + ((qeind ^ 3) * C2) + ((qeind ^ 2) * C3) + (qeind * C4) + C5))


objBspline = objBsplines.AddByPoints(2, 13, dataArray)

objBspline = objBsplines.AddByPoints(2, 14, data2Array)


' Close the profile

objProfile.End( _





If Not (objLine2d Is Nothing) Then


objLine2d = Nothing

End If

If Not (objLines2d Is Nothing) Then


objLines2d = Nothing

End If

If Not (objBspline Is Nothing) Then


objBspline = Nothing

End If

If Not (objBsplines Is Nothing) Then


objBsplines = Nothing

End If

If Not (objRefplanes Is Nothing) Then


objRefplanes = Nothing

End If

If Not (objProfile Is Nothing) Then


objProfile = Nothing

End If

If Not (objProfiles Is Nothing) Then


objProfiles = Nothing

End If

If Not (objProfileSet Is Nothing) Then


objProfileSet = Nothing

End If

If Not (objProfileSets Is Nothing) Then


objProfileSets = Nothing

End If

If Not (objPart Is Nothing) Then


objPart = Nothing

End If

If Not (objDocuments Is Nothing) Then


objDocuments = Nothing

End If

If Not (objApp Is Nothing) Then


objApp = Nothing

End If


End Try



Console.WriteLine("Press Enter to close this window.")



End Sub

End Module



Posted by: Andries
Post date: 11/21/2012 8:16:38 AM


Can't make lines with visual

Valued Contributor
Valued Contributor

Okay i managed to make it draw my lines and curves, but the problem now is that my data is stored as meters. In solid eddge i will get really big lines and curves. Can i convert my data in visual basic to millimeters?

Also i wnat to edit my sketch, but i cant acces my sketch. And when i save th file, the lines and curves just disappear.


Posted by: Andries
Post date: 11/22/2012 4:01:58 AM

Can't make lines with visual

Valued Contributor
Valued Contributor

SE works in meters internally. This will help going back and forth from meters to inches.

[code type=vbnet]

Public Const m_to_in = 39.3700787402

var.Value = varValue / m_to_in ' From app to SE.

varValue = var.Value * m_to_in ' From SE to app.



Posted by: Terry Tyson
Post date: 12/4/2012 8:16:46 AM