PySourceSDK - Source engine resources for Python developers

  • If you're asking a question make sure to set the thread type to be a question!

fubarFX

The "raw" in "nodraw"
aa
Jun 1, 2009
1,720
1,978
This post is a refresh of this previous thread https://tf2maps.net/threads/new-python-libraries-vmf-tools-and-fgd-tools.39030/
The project has now grown beyond the scope of the original thread
Introducing PySourceSDK!
https://pysourcesdk.github.io/hub/

What the hell is it? ...well currently, nothing substantial. PySourceSDK is just a collection of tools to help python developers build their own tools. The goal is to create reusable libraries that will make it easy for programmers to interact with various source engine file formats. What tools will be made out of that is up to their imagination.

Official source engine tools, while limited, are usually good and extensible.
Community made tools, on the other hand, are often poorly put together, are not seeing active development, aren't open-sourced to assure posterity.

This is where PySourceSDK comes in, the goal is to lay a solid foundation for developers to build better tools and eventually push beyond what is currently possible. Source 1 is dead and will not see future developments, I feel strongly that there's is no time like the present to make definitive tools and solve source once and for all. PySourceSDK is a push in that direction.

Finished projects:
These are fully functional project that are ready for use. They all include documentation to ensure ease of use.

ValveBSP: A Python library for parsing .bsp files. It provides access to lump data and enables modifying and adding to existing files.
https://pysourcesdk.github.io/ValveBSP

ValveEXE: A python library to issue console commands to Source Engine game clients.
https://pysourcesdk.github.io/ValveEXE

ValvePCF: A Python library for parsing .pcf files. It provides ways to read, modify and write pcf files.
https://pysourcesdk.github.io/ValvePCF

ValveFGD: A Python library that can parse .fgd files to provide schemas for entities found in vmfs. ValveFGD will eventually assist ValveVMF when it comes to manipulating entities. They are separate projects to keep things clean and self contained.
https://pysourcesdk.github.io/ValveFGD

ValveSMD: A Python library for parsing .smd files. It provides ways to read, modify and write pcf files. A few utility functions allow to perform basic transformations.
https://pysourcesdk.github.io/ValveSMD

Upcoming projects:
  • ValveVMF
  • ValveMDL
  • ValveVTF

I'm putting this thread out here to publicise resources that have been made available as well as to find people who would be interested in contributing with future projects in that vein. If you have a project of your own that you want to talk about, I'd love to hear about it.

In the Meantime, I'll still be trucking along.
 
Last edited:

fubarFX

The "raw" in "nodraw"
aa
Jun 1, 2009
1,720
1,978
NEW! ValveSMD has been added to the list of finished projects. With it, it becomes very trivial to read, write and modify smd files from python code.

Here's a quick example of what can be achieved with ValveSMD:
Code:
from valvesmd import *

smd = Smd("./rock005.smd")

SmdScale(smd, 2) # scale by a factor of 2
SmdMirror(smd, 'x') # Mirroring on 'x', 'y' or 'z' axis
SmdMatReplace(smd, 'wood', 'metal') # replace a material name

smd.save()

Want to make a gui for smd editing? Want to make an import plugin for your favourite 3D package? You're already halfway there!
Check out the documentation here https://pysourcesdk.github.io/ValveSMD
 

fubarFX

The "raw" in "nodraw"
aa
Jun 1, 2009
1,720
1,978
NEW! ValveEXE has been added to the list of finished projects. With it, you can issue commands to your game client and read the console output.

Here's a quick example of what you'd be able to do with ValveEXE:
Code:
from valveexe import ValveExe

tf2 = ValveExe('C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\hl2.exe',
                          'C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf')

tf2.launch('-windowed', '-novid', '+map', 'ctf_2fort')
tf2.run('buildcubemaps')

Want to make some automation involving in-game console commands? Well you're in luck because we've got most of those interactions already figured out https://pysourcesdk.github.io/ValveEXE/