Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Text File via Reaction

Status
Not open for further replies.

Klogg96

New member
Nov 23, 2005
7
I am a novice VB programmer an have NO real object oriented programming experiance.

Overall Goal: I need a reaction that will check if some geometry changes and update a text file with measured values when changes occure.

Current status: I am writing a VB script in the VB editor that will accomplish the above task when run manually. I will put it into a reaction later. I have tought my self how to retreive parameters but I dont know how to create the text file. Can anyone help me? Here is my VB code:


Language="VBSCRIPT"

Sub CATMain()

sqmTOsqin = (100/2.54)^2
mmTOin = 1/25.4

' Set the active document to CATIA
Set myDoc = CATIA.ActiveDocument

' Determine if the active document is a "CATPart"
Dim strPartName, strCATPart, myPos
strPartName = myDoc.Name
if (InStrRev(strPartName,".CATPart",-1) = 0)_
then MsgBox("Your document should be a .CATPart") : Exit Sub

' Get the parameters from the active part
Set part1 = myDoc.Part
Set parameters1 = part1.Parameters

'Interrogate Parameters for Input Values
Set temp = parameters1.Item("Wing_Area")
Sref = temp.Value * sqmTOsqin
'this will be done many more times for other values

'Create a file containing inputs
'Here is where I would like to write Sref to the text doc
'Dim FileObj as File
'Set FileObj = FileSys.CreateFile("D:\TestFile.txt", True)

End Sub

THANKS FOR YOUR HELP!
 
Replies continue below

Recommended for you

I figured this part out ... I needed to set the CATIA file system object. I am now able to create a text file and write to it using a textstream however now I am stuck trying to format the output. I cant make CATIA write to the next line. Does anyone have a reference on how to do this?
 
Dont you need to get the script to put in a Carriage return?

The Vb command would be vbCrLf not sure for vbscript

but bCrLf is equivalent to Chr(13) + Chr(10)

So I guess you just need to include Chr(13) + Chr(10)

after every line of text you want to create a new line
 
Hey Thanks! I just set a string to chr(010) and everything works great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor