Dear Gurus :)

Dear Gurus :)

Anonymous
Not applicable
316 Views
4 Replies
Message 1 of 5

Dear Gurus :)

Anonymous
Not applicable
To start this thread, I'm going to ask a simple question 🙂

How complicated is it to pass a text value from excel into a custom
iproperty in Inventor?

It stinks that parameters have to be numbers. I can't link parameters to the
spreadsheet because some of the values are text.

Replies are much appreciated!
0 Likes
317 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
It is pretty simple when you use VB/VBA/.Net, BUT excel spreadsheets use different objects with each version. So to make an application universal and work in the long run, it is easier to use TAB delimited files containg all needed information. They can be opened by Excel straight away for editing if you like, and are easy to read/handle by your app.
0 Likes
Message 3 of 5

Anonymous
Not applicable
Thanks for the pointer. I really appreciate it. Would you happen to know of
any good resources for Inventor VBA? Tutorials, WEBinars, books, etc.?

Thanks again.

wrote in message news:5867970@discussion.autodesk.com...
It is pretty simple when you use VB/VBA/.Net, BUT excel spreadsheets use
different objects with each version. So to make an application universal and
work in the long run, it is easier to use TAB delimited files containg all
needed information. They can be opened by Excel straight away for editing if
you like, and are easy to read/handle by your app.
0 Likes
Message 4 of 5

Anonymous
Not applicable
These groups and the Inventor help should do it. To get started (not tested):

Private Sub GetText()
'create a textfile that has multiple lines
'each line starts with the property name
'then a TAB (chr(9)) then the property value

Dim FileContents As String
FileContents = ReadFile("c:\Myfile.txt")

Dim Lines() As String
Dim Vals() As String
Lines = Split(FileContents, vbCrLf)

For Each Line In Lines
Vals = Split(Line, Chr(9))
If Vals(0) = "MyPropName" Then
Debug.Print "Prop value: " & Vals(1)
'grab the property in inventor and fill in the value
End If
Next
End Sub


Private Function ReadFile(FileName As String) As String
'requires a reference to the Windows Script Host Object Model
Dim FSO As New FileSystemObject
Dim tsInput As TextStream
Dim strLine As String

Set tsInput = FSO.OpenTextFile(FileName, 1)
Dim FileStr As String
Do While Not tsInput.AtEndOfStream
strLine = tsInput.ReadLine
FileStr = FileStr & strLine
Loop
tsInput.Close
Set FSO = Nothing

ReadFile = FileStr
End Function
0 Likes
Message 5 of 5

Anonymous
Not applicable
Thanks again!

wrote in message news:5868237@discussion.autodesk.com...
These groups and the Inventor help should do it. To get started (not
tested):

Private Sub GetText()
'create a textfile that has multiple lines
'each line starts with the property name
'then a TAB (chr(9)) then the property value

Dim FileContents As String
FileContents = ReadFile("c:\Myfile.txt")

Dim Lines() As String
Dim Vals() As String
Lines = Split(FileContents, vbCrLf)

For Each Line In Lines
Vals = Split(Line, Chr(9))
If Vals(0) = "MyPropName" Then
Debug.Print "Prop value: " & Vals(1)
'grab the property in inventor and fill in the value
End If
Next
End Sub


Private Function ReadFile(FileName As String) As String
'requires a reference to the Windows Script Host Object Model
Dim FSO As New FileSystemObject
Dim tsInput As TextStream
Dim strLine As String

Set tsInput = FSO.OpenTextFile(FileName, 1)
Dim FileStr As String
Do While Not tsInput.AtEndOfStream
strLine = tsInput.ReadLine
FileStr = FileStr & strLine
Loop
tsInput.Close
Set FSO = Nothing

ReadFile = FileStr
End Function
0 Likes