×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Create Text File via Reaction

Create Text File via Reaction

Create Text File via Reaction

(OP)
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!

RE: Create Text File via Reaction

(OP)
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?

RE: Create Text File via Reaction

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

RE: Create Text File via Reaction

(OP)
Hey Thanks! I just set a string to chr(010) and everything works great!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources