Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Reading from a external file

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
177 Views, 2 Replies

Reading from a external file

Looking for way to pick up data from an external txt file and changing text
within idw. Job #, Customer name, qty etc
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

That is a pretty broad request. Is there a specific thing you are
having trouble with or ??

If you look through some of the results from this search you may get
some leads on reading and writing to text files.
http://www.google.com/search?sourceid=navclient&q=visual+basic+%22for+output%22+txt

--
Kent Keller
http://www.MyMcad.com/KWiK/Mcad.htm

Assistant Moderator
Autodesk Discussion Forum Moderator Program

"David Estabrooks" wrote in message
news:F61A3EE6DC90F2ABFDF0111ABD437FBF@in.WebX.maYIadrTaRb...
> Looking for way to pick up data from an external txt file and changing
text
> within idw. Job #, Customer name, qty etc
>
>
Message 3 of 3
Anonymous
in reply to: Anonymous

More than you need probably (and not cleaned up at all) but this is a
module I use to read info out of text file and apply the values to the
properties of an IDW:

Private Sub cmdApply_Click()

If cbGetFileInfo.Value = True Then

'this is the name of the project file...
'use it, strip off the ipj and replace by txt
strOpenName = ThisApplication.FileLocations.FileLocationsFile

strOpenName = Left$(strOpenName, Len(strOpenName) - 4) & ".txt"

On Error GoTo NoFileFound

If strOpenName <> "" Then
Open strOpenName For Input As #1
Line Input #1, tempstring
If tempstring <> "[WORK ORDER NUMBER]" Then
MsgBox "This is not a valid Project Info File"
Exit Sub
Else
Close #1
End If

'run thu file to record info
Open strOpenName For Input As #1
Do While (tempstring <> "***EOF***") And Not EOF(1)
Line Input #1, tempstring
If tempstring = "[WORK ORDER NUMBER]" Then
Line Input #1, WorkOrderNumber
If WorkOrderNumber = "*" Then
WorkOrderNumber = ""
End If
ElseIf tempstring = "[ASSET ID]" Then
Line Input #1, AssetID
If AssetID = "*" Then
AssetID = ""
End If
ElseIf tempstring = "[RA]" Then
Line Input #1, RA
If RA = "*" Then
RA = ""
End If
ElseIf tempstring = "[COST CENTER]" Then
Line Input #1, CC
If CC = "*" Then
CC = ""
End If
Else
End If

Loop

Close #1

Else
End If

'fill in the form values
tbProject.Value = AssetID
tbAuthority.Value = RA
tbCostcenter.Value = WorkOrderNumber
tbDept.Value = CC

End If

'assign variables to the values in the text boxes
'dont use the variables above directly as they are going to be used
elsewhere
Project = tbProject.Value
Comments = tbComments.Value
Authority = tbAuthority.Value
CostCenter = tbCostcenter.Value
Keyword = tbDept.Value

oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kProje
ctDesignTrackingProperties).Value = UCase(Project)
oPropsets.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}").ItemByPropId(kComme
ntsSummaryInformation).Value = UCase(Comments)
oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kCostC
enterDesignTrackingProperties).Value = UCase(CostCenter)
oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kAutho
rityDesignTrackingProperties).Value = UCase(Authority)
oPropsets.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}").ItemByPropId(kKeywo
rdsSummaryInformation).Value = UCase(Keyword)


tbProject.Value =
oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kProje
ctDesignTrackingProperties).Value
tbComments.Value =
oPropsets.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}").ItemByPropId(kComme
ntsSummaryInformation).Value
tbCostcenter.Value =
oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kCostC
enterDesignTrackingProperties).Value
tbAuthority.Value =
oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kAutho
rityDesignTrackingProperties).Value
tbDept.Value =
oPropsets.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}").ItemByPropId(kKeywo
rdsSummaryInformation).Value

Exit Sub

NoFileFound:
MsgBox ("The Project Information File Was Not Found")

End Sub

and the text file is formatted liek this:

[WORK ORDER NUMBER]
5512-45
[ASSET ID]
45144-78-78
[RA]
*
[COST CENTER]
12101
***EOF***

--
Sean Dotson, PE
http://www.sdotson.com
Check the Inventor FAQ for most common questions
www.sdotson.com/faq.html
-----------------------------------------------------------------------
"David Estabrooks" wrote in message
news:F61A3EE6DC90F2ABFDF0111ABD437FBF@in.WebX.maYIadrTaRb...
> Looking for way to pick up data from an external txt file and changing
text
> within idw. Job #, Customer name, qty etc
>
>

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report