Jump to content


- - - - -

export result in excel though batch mode


  • Please log in to reply
6 replies to this topic

#1 Ms. Haipeng Liu

Ms. Haipeng Liu

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 11 August 2017 - 10:58 AM

Hi Caeses Team,

 

I used the batch file to export geometry before. Now I want to export a x value of the point into an excel or text. How could I write this programming command inside the .fsc file?

 

Many thanks!


  • 0

#2 Mr. Carsten Fuetterer

Mr. Carsten Fuetterer

    Moderator

  • Moderators
  • 145 posts

Posted 11 August 2017 - 11:32 AM

Hi Haipeng,

 

you have to write a feature inside the project, which writes a file. This can be the code for the feature:

ffile file(getResultsDir()+"/"+filename)
if (!file.openWrite())
  echo("Failed to open file \"" + file.getAbsolutePath() + "\" for writing")
  break()
endif

// use file.write() or file.writeLine() to write to the file.

file.writeLine(""+p:x+"\t"+p:y+"\t"+p:z)


//close file when done with it
file.close()

To write this code I simply used the feature templates.

 

Then in the fsc script you have to write a line:

exportFile.run()

 

This will update the feature and trigger the export.

 

best regards

 

Carsten

Attached Files


  • 0

Carsten Fütterer
M.Sc. Energy & Process Engineering
CAE Applications Engineer
www.friendship-systems.com
Tel. +49 (0)331 967 66 28

 


#3 Jörg

Jörg

    Moderator

  • Moderators
  • 503 posts
  • LocationBerlin, Germany

Posted 11 August 2017 - 11:43 AM

Hi,

 

See also this post for more information about how to write a file.

 

Cheers

Joerg


  • 0

#4 Ms. Haipeng Liu

Ms. Haipeng Liu

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 14 August 2017 - 11:16 AM

Hi Haipeng,

 

you have to write a feature inside the project, which writes a file. This can be the code for the feature:

ffile file(getResultsDir()+"/"+filename)
if (!file.openWrite())
  echo("Failed to open file \"" + file.getAbsolutePath() + "\" for writing")
  break()
endif

// use file.write() or file.writeLine() to write to the file.

file.writeLine(""+p:x+"\t"+p:y+"\t"+p:z)


//close file when done with it
file.close()

To write this code I simply used the feature templates.

 

Then in the fsc script you have to write a line:

exportFile.run()

 

This will update the feature and trigger the export.

 

best regards

 

Carsten

Thanks a lot for your advice. It works well in my project. 


  • 0

#5 Ms. Haipeng Liu

Ms. Haipeng Liu

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 14 August 2017 - 11:18 AM

Hi,

 

See also this post for more information about how to write a file.

 

Cheers

Joerg

Hi Joerg, thanks a lot for your sample. It helps a lot!


  • 0

#6 Ms. Haipeng Liu

Ms. Haipeng Liu

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 14 August 2017 - 01:12 PM

Hi Haipeng,

 

you have to write a feature inside the project, which writes a file. This can be the code for the feature:

ffile file(getResultsDir()+"/"+filename)
if (!file.openWrite())
  echo("Failed to open file \"" + file.getAbsolutePath() + "\" for writing")
  break()
endif

// use file.write() or file.writeLine() to write to the file.

file.writeLine(""+p:x+"\t"+p:y+"\t"+p:z)


//close file when done with it
file.close()

To write this code I simply used the feature templates.

 

Then in the fsc script you have to write a line:

exportFile.run()

 

This will update the feature and trigger the export.

 

best regards

 

Carsten

 

 

Hi,

 

See also this post for more information about how to write a file.

 

Cheers

Joerg

Hi Carsten and Joerg,

 

Is that possible to write the result into an existing excel instead of a new .txt?


  • 0

#7 Jörg

Jörg

    Moderator

  • Moderators
  • 503 posts
  • LocationBerlin, Germany

Posted 05 September 2017 - 08:11 AM

Hi Haipeng,

 

There is the possibility to connect to an Excel sheet through the COM interface. Maybe this helps. However, I am not sure whether the feature in this rather old post still works, maybe you can simply try it out.


  • 0