is there anyone that knows how to fix this error....
Could you post the whole code? It looks like you probably just defined something wrong
Imports System Imports System.IO Imports System.Drawing Imports System.Data Imports System.Collections Imports System.Windows.Forms Imports System.Drawing.Printing Imports Microsoft.VisualBasic Imports Inventor Public Class Form1 Public oApp As Inventor.Application = GetObject(, "Inventor.Application") Public oSketch As PlanarSketch Public InletHoleDia As Double Public oCompDef As PartComponentDefinition Public oUOM As UnitsOfMeasure Public SketchNumber As Integer Public WorkPlaneNumber As Integer Public r As String Public f As String Private Sub Button_SaveTo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_SaveTo.Click Dim FileSearchDialog As New OpenFileDialog() Dim SelectedFile As String Dim FilePath As String FileSearchDialog.InitialDirectory = "C:\My Documents" FileSearchDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*" If FileSearchDialog.ShowDialog() = DialogResult.OK Then SelectedFile = FileSearchDialog.FileName FilePath = IO.Path.GetFullPath(SelectedFile) TB_SaveTo.Text = FilePath End If End Sub Private Sub Button_InData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_InData.Click Dim FileSearchDialog As New OpenFileDialog() Dim SelectedFile As String Dim FilePath As String FileSearchDialog.InitialDirectory = "C:\My Documents" FileSearchDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*" If FileSearchDialog.ShowDialog() = DialogResult.OK Then SelectedFile = FileSearchDialog.FileName FilePath = IO.Path.GetFullPath(SelectedFile) TB_InData.Text = FilePath End If End Sub Private Sub Button_OutData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_OutData.Click Dim FileSearchDialog As New OpenFileDialog() Dim SelectedFile As String Dim FilePath As String FileSearchDialog.InitialDirectory = "C:\My Documents" FileSearchDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*" If FileSearchDialog.ShowDialog() = DialogResult.OK Then SelectedFile = FileSearchDialog.FileName FilePath = IO.Path.GetFullPath(SelectedFile) TB_OutData.Text = FilePath End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Create.Click Dim oPartDoc As PartDocument Dim oOriginSketchPoint As SketchPoint Dim PipeOD, PipeWT, PipeLen As Double Dim oCircle(0 To 2) As SketchCircle Dim i As Integer Dim oPoint As SketchPoint Dim oTG As TransientGeometry Dim oDims(0 To 10) As DimensionConstraint Dim oProfile As Profile Dim oExtrude As ExtrudeFeature '************************************************************************************************************************************* '********** CREATE NEW PART (PIPE, REFERENCE THE COMPONENT AND CREATE SKETCH ON "XY" WORK PLANE THEN PROJECT SKETCH ORIGIN * oPartDoc = oApp.Documents.Add(DocumentTypeEnum.kPartDocumentObject, _ oApp.FileManager.GetTemplateFile(DocumentTypeEnum.kPartDocumentObject)) oCompDef = oPartDoc.ComponentDefinition oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes.Item(3)) oOriginSketchPoint = oSketch.AddByProjectingEntity(oCompDef.WorkPoints.Item(1)) '************************************************************************************************************************************* '********** CONVERT FORM TEXTBOXES TO DOCUMENT UNITS ********************************************************************************* oUOM = oApp.ActiveDocument.UnitsOfMeasure 'TEXTBOX "TB_Dia" PipeOD = oUOM.GetValueFromExpression(Val(TB_Dia.Text), UnitsTypeEnum.kDefaultDisplayLengthUnits) 'TEXTBOX "TB_WT" PipeWT = oUOM.GetValueFromExpression(Val(TB_WT.Text), UnitsTypeEnum.kDefaultDisplayLengthUnits) 'TEXTBOX "TB_length" PipeLen = oUOM.GetValueFromExpression(Val(TB_Length.Text), UnitsTypeEnum.kDefaultDisplayLengthUnits) '************************************************************************************************************************************* '********** DRAW HOR/VER SKETCH LINES AND ACRS *************************************************************************************** 'PIPE PROFILE. oTG = oApp.TransientGeometry oPoint = oSketch.SketchPoints.Add(oTG.CreatePoint2d(0, 0), False) oCircle(1) = oSketch.SketchCircles.AddByCenterRadius( _ oPoint, Val(PipeOD) / 2) oCircle(2) = oSketch.SketchCircles.AddByCenterRadius( _ oPoint, Val(PipeOD - (PipeWT * 2)) / 2) '************************************************************************************************************************************** '********** DIMENSION SKETCH CIRCLE *************************************************************************************************** 'PIPE PROFILE. oDims(1) = oSketch.DimensionConstraints.AddDiameter( _ oCircle(1), oTG.CreatePoint2d(1, 1), False) i = oSketch.DimensionConstraints.Count oSketch.DimensionConstraints.Item(i).Parameter.Value = PipeOD oDims(2) = oSketch.DimensionConstraints.AddDiameter( _ oCircle(2), oTG.CreatePoint2d(-1, -1), False) i = oSketch.DimensionConstraints.Count oSketch.DimensionConstraints.Item(i).Parameter.Value = (PipeOD - (PipeWT * 2)) '************************************************************************************************************************************* '********** CONSTRAIN SKETCH CIRCLE ************************************************************************************************** With oSketch.GeometricConstraints 'LEFT TANGENT LINE. .AddCoincident(oCircle(1).CenterSketchPoint, oCircle(2).CenterSketchPoint) .AddCoincident(oCircle(1).CenterSketchPoint, oPoint) .AddCoincident(oPoint, oOriginSketchPoint) End With '************************************************************************************************************************************** '********** EXTRUDE SKETCH1 *********************************************************************************************************** oProfile = oSketch.Profiles.AddForSolid oExtrude = oCompDef.Features.ExtrudeFeatures.AddByDistanceExtent( _ oProfile, Val(PipeLen), PartFeatureExtentDirectionEnum.kSymmetricExtentDirection, _ PartFeatureOperationEnum.kJoinOperation) '************************************************************************************************************************************** '********** READ INLET DATA TEXT FILE *********************************************************************************************************** Dim FileName As String = TB_InData.Text Dim lines() As String = IO.File.ReadAllLines(FileName) Dim lineArray As New ArrayList() Dim s As String Dim substring() As String Dim Item As String Dim Cnt As Integer 'Dim LineNumber As Integer oApp.ActiveView.GoHome() For x As Integer = 0 To lines.GetUpperBound(0) lineArray.Add(lines(x)) Next For LineNumber = 0 To lineArray.Count - 2 s = lineArray.Item(LineNumber) substring = s.Split(vbTab) 'LineNumber = x Cnt = 0 For Each Item In substring If Item = "" Then ElseIf Item = vbTab Then ElseIf Cnt = 0 Then Dim oActiveDoc As PartDocument Dim oPartCompDef As PartComponentDefinition Dim BaseXY As WorkPlane Dim PreviousWorkPlane As WorkPlane Dim CurrentWorkPlane As WorkPlane Dim AxisX As WorkAxis Dim oANG1 As String Dim oNewWorkPlane As WorkPlane Dim oHole(0 To 2) As SketchCircle Dim AddSketch As Sketch Dim OriginPoint As SketchPoint oActiveDoc = oApp.ActiveDocument oPartCompDef = oPartDoc.ComponentDefinition BaseXY = oPartCompDef.WorkPlanes.Item(1) AxisX = oPartCompDef.WorkAxes.Item(3) oANG1 = Item & " grd" If LineNumber = 0 Then oPartCompDef.WorkPlanes.AddByLinePlaneAndAngle(AxisX, BaseXY, oANG1) Else PreviousWorkPlane = oPartCompDef.WorkPlanes.Item(LineNumber + 3) oPartCompDef.WorkPlanes.AddByLinePlaneAndAngle(AxisX, PreviousWorkPlane, oANG1) End If If LineNumber = 0 Then SketchNumber = 2 WorkPlaneNumber = 1 r = "Work Plane" & WorkPlaneNumber f = "Sketch" & SketchNumber CurrentWorkPlane = oCompDef.WorkPlanes.Item(r) AddSketch = oCompDef.Sketches.Add(CurrentWorkPlane, True) oSketch = oCompDef.Sketches.Item(f) Else CurrentWorkPlane = oCompDef.WorkPlanes.Item(r) AddSketch = oCompDef.Sketches.Add(CurrentWorkPlane, True) oSketch = oCompDef.Sketches.Item(f) End If Cnt = Cnt + 1 ElseIf Cnt >= 1 Then Dim InletHoleLocation As Double Dim ItemConvert As Integer Dim oHole(Cnt) As SketchCircle ItemConvert = Item / 25.4 InletHoleDia = oUOM.GetValueFromExpression(Val(TB_InletHoleDia.Text), UnitsTypeEnum.kDefaultDisplayLengthUnits) InletHoleLocation = oUOM.GetValueFromExpression(Val(ItemConvert), UnitsTypeEnum.kDefaultDisplayLengthUnits) Dim oCenterPoints As ObjectCollection oCenterPoints = oApp.TransientObjects.CreateObjectCollection oCenterPoints.Add(oSketch.SketchPoints.Add(oApp.TransientGeometry.CreatePoint2d(InletHoleLocation, 0))) oSketch.GeometricConstraints.AddGround(oCenterPoints.Item(1)) Cnt = Cnt + 1 End If Next Call Module2.CreateHoleByThroughAllExtent() SketchNumber = SketchNumber + 1 WorkPlaneNumber = WorkPlaneNumber + 1 Next End Sub Private Sub Button_Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Cancel.Click Me.Close() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Call Module3.AfterFirstWorkPlane() End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub End Class
Exactly what rjay said. So towards the beginning of that you say:
Dim Item as String
Which it looks like you need it to be, but you'll want to figure out how to get that string to change to an integer, because later on you say
:
Dim ItemConvert As Integer
It's recognizes your string as characters and your integers as numbers. To do the division, you need them both to be numbers.
Three articles that might help:
http://msdn.microsoft.com/en-us/library/s2dy91zy.aspx
http://msdn.microsoft.com/en-us/library/7sx7t66b.aspx
http://stackoverflow.com/questions/11595226/how-do-i-convert-an-integer-to-a-string-in-excel-vba
(reverse of what you need to do.