# Change the export stl file code from Exported from Blender-x.x.x to object name

I want export model into stl format in ASCII, which Blender can do. However when I open the exported stl file by text, the first line is always like this:

solid Exported from Blender-2.91.2

And the last line is:

endsolid Exported from Blender-2.91.2

I want to change the string "Exported from Blender-2.91.2" to my stl file name, so I have to open my stl files again and again to change the name. This bothers me a lot and I don't know how to fixed it once and for all. I tried to open the addon folder io_mesh_stl(path:2.91\scripts\addons) and find in file stl_utils,line 75:

return "Exported from Blender-" + bpy.app.version_string

Is it because this line? How can I fix my problem? Thanks a lot if anyone can help!

Slippery Slope.

Would investigate doing this in a post pro way, Using something like sed or python, to run thru stl files and automate the bothersome edit, rather than updating the addon code.

That said, a quick edit to change the header when writing to ASCII

stl_utils.py

def _ascii_write(filepath, faces):
from mathutils.geometry import normal

with open(filepath, 'w') as data:
fw = data.write
fw('solid %s\n' % header)

for face in faces:
# calculate face normal
fw('facet normal %f %f %f\nouter loop\n' % normal(*face)[:])
for vert in face:
fw('vertex %f %f %f\n' % vert[:])
fw('endloop\nendfacet\n')

fw('endsolid %s\n' % header)


change the code (circa line 205) from

header = _header_version()


to

header = filepath


or to hack it just to use the filepath stem "/path/foo/bar/stem.extension"

from pathlib import Path

or to hack it just to use the filname (with extension) "/path/foo/bar/filename"
from pathlib import Path

• Seems? Added code to add just the stem of a filepath "/path/foo/bar/stem.extension" – batFINGER Feb 24 at 8:01