PyVMF¶
-
class
AllowedVerts
(matrix, dic: Optional[dict] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'allowed_verts'¶
-
-
class
Alphas
(matrix, dic: Optional[dict] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'alphas'¶
-
export
()¶ Gets all the variables than need to be exported into the .VMF file
Returns: All predefined (in export_list) variable names and their associated values Return type: dict
,dict
-
-
class
Box
(dic: Optional[dict] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'box'¶
-
-
class
Camera
(dic: Optional[dict] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'camera'¶
-
-
class
Cameras
(dic: Optional[dict] = None, children: Optional[list] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'cameras'¶
-
-
class
Color
(r: int = 255, g: int = 255, b: int = 255)¶ Bases:
object
Simple RGB color class
Parameters: - r (
int
) – Value for RED between 0 and 255 - g (
int
) – Value for GREEN between 0 and 255 - b (
int
) – Value for BLUE between 0 and 255
-
export
() → Tuple[int, int, int]¶
-
random
()¶ Sets a random color
-
set
(r: int = -1, g: int = -1, b: int = -1)¶ Sets the color
Parameters: - r (
int
) – Value for RED between 0 and 255, if equals to -1 keeps previous value - g (
int
) – Value for GREEN between 0 and 255, if equals to -1 keeps previous value - b (
int
) – Value for BLUE between 0 and 255, if equals to -1 keeps previous value
- r (
- r (
-
class
ColorLight
(r: int = 255, g: int = 255, b: int = 255, brightness: int = 200)¶ Bases:
PyVMF.Color
Simple RGB color class with brightness (used for lights)
Parameters: - r (
int
) – Value for RED between 0 and 255 - g (
int
) – Value for GREEN between 0 and 255 - b (
int
) – Value for BLUE between 0 and 255 - brightness (
int
) – Value for brightness, above 0
-
export
() → Tuple[int, int, int, int]¶
-
set_brightness
(brightness: int)¶ Parameters: brightness ( int
) – New brightness value
- r (
-
class
Common
¶ Bases:
object
The parent class to all VMF classes that need to be exported to the .VMF file.
-
ID
= 0¶
-
export
()¶ Gets all the variables than need to be exported into the .VMF file
Returns: All predefined (in export_list) variable names and their associated values Return type: dict
,dict
-
export_children
()¶ Gets all the children classes
Returns: All predefined children classes Return type: list
ofCommon
instances
-
ids
()¶
-
-
class
Connections
(dic: Optional[dict] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'connections'¶
-
-
class
Convert
¶ Bases:
object
Converts strings to usable instances
-
static
string_to_3x_vertex
(string: str) → List[Vertex, Vertex, Vertex]¶
-
static
string_to_color
(string: str) → PyVMF.Color¶
-
static
string_to_color_light
(string: str) → PyVMF.ColorLight¶
-
static
string_to_uvaxis
(string: str) → PyVMF.UVaxis¶
-
static
string_to_vertex
(string: str) → PyVMF.Vertex¶
-
static
-
class
Cordon
(dic: Optional[dict] = None, children: Optional[list] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'cordon'¶
-
-
class
Cordons
(dic: Optional[dict] = None, children: Optional[list] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'cordons'¶
-
-
class
DispInfo
(dic: Optional[dict] = None, children: Optional[list] = None, parent_side: Optional[PyVMF.Side] = None)¶ Bases:
PyVMF.Common
Keeps track of all the different displacement settings and values
-
NAME
= 'dispinfo'¶
-
export_children
()¶ Gets all the children classes
Returns: All predefined children classes Return type: list
ofCommon
instances
-
is_flipped
() → bool¶ Finds out if the displacement has been flipped, might not work if the face is non rectangular
Returns: If the displacement has been flipped Return type: bool
-
power
= None¶ The displacement power, can only be 2, 3 or 4
-
startposition
¶
-
-
class
DispVert
¶ Bases:
PyVMF.Common
Keeps track of each individual displacement vertex
-
set
(normal: PyVMF.Vertex, distance: int)¶ Sets the normal direction and distance
Parameters: - normal (
Vertex
) – The normal direction (x, y and z) - distance (
int
) – How far to go in the normal direction
- normal (
-
set_alpha
(amount: int)¶ Sets the alpha, used by blend textures, 0 is the first texture, 255 is the second texture, 127 is both
Parameters: amount ( int
) – The alpha amount, between 0 and 255
-
-
class
Distances
(matrix, dic: Optional[dict] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'distances'¶
-
export
()¶ Gets all the variables than need to be exported into the .VMF file
Returns: All predefined (in export_list) variable names and their associated values Return type: dict
,dict
-
-
class
Editor
(dic: Optional[dict] = None, parent_type=None)¶ Bases:
PyVMF.Common
-
NAME
= 'editor'¶
-
export
()¶ Gets all the variables than need to be exported into the .VMF file
Returns: All predefined (in export_list) variable names and their associated values Return type: dict
,dict
-
has_visgroup
() → bool¶
-
-
class
Entity
(dic: Optional[dict] = None, children: Optional[list] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'entity'¶
-
-
class
EntityGenerator
¶ Bases:
object
Generates entities from scratch, remember you still need to add them to
VMF
usingadd_entities()
-
static
info_decal
(origin: PyVMF.Vertex, texture: str) → PyVMF.InfoDecal¶ Generates a basic decal
Parameters: - origin (
Vertex
) – The position of the decal in the world - texture (
str
) – The name of the texture (ex: “tools/toolsnodraw”)
Returns: A generated decal
Return type: - origin (
-
static
info_overlay
(origin: PyVMF.Vertex, texture: str, angle: PyVMF.Vertex = <PyVMF.Vertex object>, *sides) → PyVMF.InfoOverlay¶ Generates a basic overlay
Parameters: Returns: A generated overlay
Return type:
-
static
light
(origin: PyVMF.Vertex, color: PyVMF.Color, brightness: int = 200) → PyVMF.Light¶ Generates a basic light
Parameters: Returns: A generated light
Return type:
-
static
prop_static
(origin: PyVMF.Vertex, model: str, angle: PyVMF.Vertex = <PyVMF.Vertex object>, color: PyVMF.Color = <PyVMF.Color object>, scale: int = 1) → PyVMF.PropStatic¶ Generates a basic prop static
Parameters: Returns: A generated prop static
Return type:
-
static
-
class
Group
(dic: Optional[dict] = None, children: Optional[list] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'group'¶
-
-
class
Hidden
(dic: Optional[dict] = None, children: Optional[list] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'hidden'¶
-
-
class
InfoDecal
(dic: Optional[dict] = None, children: Optional[list] = None)¶ Bases:
PyVMF.Entity
-
SUBNAME
= 'infodecal'¶
-
-
class
InfoOverlay
(dic: Optional[dict] = None, children: Optional[list] = None)¶ Bases:
PyVMF.Entity
-
SUBNAME
= 'info_overlay'¶
-
add_sides
(*sides)¶
-
-
class
Light
(dic: Optional[dict] = None, children: Optional[list] = None)¶ Bases:
PyVMF.Entity
-
SUBNAME
= 'light'¶
-
-
class
Matrix
(size: int)¶ Bases:
PyVMF.Common
A grid for keeping track of the displacement values.
Parameters: size ( int
) – The size of the 2 dimensional grid-
column
(x: int) → List[DispVert, ...]¶ Parameters: x ( int
) – The column to getReturns: All the disp verts on the given column Return type: list
ofDispVert
-
export_attr
(attribute)¶ Exports the data in .VMF file ready format, used when exporting the PyVMF, you shouldn’t need to use this
Parameters: attribute ( str
) – Which of the attributes to export (normals, distances, …)Returns: Row to values association Return type: dict
ofstr
:str
-
extract_dic
(dic, a_var=1, triangle=False)¶ Extracts the data from the .VMF file string, you shouldn’t need to use this
Parameters: - dic (
dict
ofstr
:str
) – Holds all the rows - a_var (
int
) – How many variables to group, use 3 to group the ‘x y z’ format, if single int use 1 - triangle (
bool
) –TriangleTags
holds 1 less value than all other displacement variables
Returns: The x and y position in the matrix and the values
Return type: int
,int
,list
ofstr
- dic (
-
get
(x: int, y: int) → PyVMF.DispVert¶ Parameters: - x (
int
) – Position x in the matrix - y (
int
) – Position y in the matrix
Returns: Displacement information at the given position
Return type: - x (
-
inv_rect
(x, y, w, h, step)¶
-
-
class
Normals
(matrix, dic: Optional[dict] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'normals'¶
-
export
()¶ Gets all the variables than need to be exported into the .VMF file
Returns: All predefined (in export_list) variable names and their associated values Return type: dict
,dict
-
-
class
OffsetNormals
(matrix, dic: Optional[dict] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'offset_normals'¶
-
export
()¶ Gets all the variables than need to be exported into the .VMF file
Returns: All predefined (in export_list) variable names and their associated values Return type: dict
,dict
-
-
class
Offsets
(matrix, dic: Optional[dict] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'offsets'¶
-
export
()¶ Gets all the variables than need to be exported into the .VMF file
Returns: All predefined (in export_list) variable names and their associated values Return type: dict
,dict
-
-
class
PropStatic
(dic: Optional[dict] = None, children: Optional[list] = None)¶ Bases:
PyVMF.Entity
-
SUBNAME
= 'prop_static'¶
-
-
class
Side
(dic: Optional[dict] = None, children: Optional[list] = None)¶ Bases:
PyVMF.Common
Corresponds to a face/side of a solid. Sides are defined by 3 vertices, the combination of which define an infinitely large plane, source calculates the intersection between these planes to determine where the edges are. This is not currently calculated in PyVMF, so some methods may behave unpredictably.
Parameters: - dic (
dict
) – All the values to be initialized, if empty default values are used. - children (
list
) – Holds a potential displacementDispInfo
to be initialized
-
NAME
= 'side'¶
-
export
()¶ Gets all the variables than need to be exported into the .VMF file
Returns: All predefined (in export_list) variable names and their associated values Return type: dict
,dict
-
export_children
()¶ Gets all the children classes
Returns: All predefined children classes Return type: list
ofCommon
instances
-
flip
(x=None, y=None, z=None)¶
-
get_displacement
() → PyVMF.DispInfo¶ Returns: The current displacement, only 1 per side Return type: DispInfo
orNone
-
get_naive_rotation
() → int¶ Gets the rotation if and only if it’s a multiple of 90, please don’t use this if it’s not necessary
Returns: Rotation of the face either 0, 90, 180 or 270 Return type: int
-
get_vector
()¶
-
get_vertices
() → List[Vertex, Vertex, Vertex]¶ Returns: All 3 vertices that define the plane Return type: list
ofVertex
-
move
(x, y, z)¶ Moves the side by the given amount
Parameters: - x (
int
orfloat
) – Amount to move the x axis by - y (
int
orfloat
) – Amount to move the y axis by - z (
int
orfloat
) – Amount to move the z axis by
- x (
-
remove_displacement
()¶ Removes the diplacement from the side
-
rotate_x
(center: PyVMF.Vertex, angle)¶ Rotates the side around the x axis
Parameters: - center (
Vertex
) – The point to rotate around - angle (
int
orfloat
) – How much to rotate in degrees
- center (
-
rotate_y
(center: PyVMF.Vertex, angle)¶ Rotates the vertex around the y axis
Parameters: - center (
Vertex
) – The point to rotate around - angle (
int
orfloat
) – How much to rotate in degrees
- center (
-
rotate_z
(center: PyVMF.Vertex, angle)¶ Rotates the vertex around the z axis
Parameters: - center (
Vertex
) – The point to rotate around - angle (
int
orfloat
) – How much to rotate in degrees
- center (
-
set_texture
(new_material: str)¶ Sets the given texture on all sides
Parameters: new_material ( str
) – The texture to use
- dic (
-
class
Solid
(dic: Optional[dict] = None, children: Optional[list] = None)¶ Bases:
PyVMF.Common
Corresponds to an individual solid just like in Hammer
Parameters: -
NAME
= 'solid'¶
-
add_sides
(*args)¶ Adds sides to the solid, note that no checks are made for validity
Parameters: args ( list
ofSide
) – List of sides to be added
-
center
¶ Finds the center of the solid based on the average of all vertices. Can behave unpredictably as faces only consists of 3 verticies so the center might be off by a tiny amount For a more reliable option see
center_geo()
Returns: The average center of the solid Return type: Vertex
-
center_geo
¶ Finds the center of the solid based on the extremities of all 3 axes. More reliable than
center()
Returns: The geometric center of the solid Return type: Vertex
-
export_children
()¶ Gets all the children classes
Returns: All predefined children classes Return type: list
ofCommon
instances
-
flip
(x=None, y=None, z=None)¶
-
get_3d_extremity
(x: bool = None, y: bool = None, z: bool = None) → Tuple[Vertex, List[Vertex, ...]]¶ Finds the vertices that are the furthest on the given axes, as well as ties
Parameters: - x (
bool
) – False for negative side of the axis, True for positive side - y (
bool
) – False for negative side of the axis, True for positive side - z (
bool
) – False for negative side of the axis, True for positive side
Returns: The vertex furthest most on the given axes, and the ties, the champion vertex is included
Return type: - x (
-
get_all_vertices
() → List[Vertex, ...]¶ Finds all vertices on the solid, including overlapping ones from the different sides, for only unique vertices use
get_only_unique_vertices()
Returns: All the vertices on the solid Return type: list
ofVertex
-
get_axis_extremity
(x: Optional[bool] = None, y: Optional[bool] = None, z: Optional[bool] = None) → PyVMF.Vertex¶ Finds the vertex that is the furthest on the given axis, only 1 axis per method call, see
get_3d_extremity()
Parameters: - x (
bool
) – False for negative side of the axis, True for positive side - y (
bool
) – False for negative side of the axis, True for positive side - z (
bool
) – False for negative side of the axis, True for positive side
Returns: The vertex the furthest most on the given axis
Return type: - x (
-
get_displacement_matrix_sides
() → List[Matrix, ...]¶ Gets the matrices from all the sides that have displacements, use
get_displacement_sides()
to get the sides insteadReturns: The matrices from the sides with displacements on them Type: list
ofMatrix
-
get_displacement_sides
() → List[PyVMF.Side]¶ Gets the sides that have displacements, use
get_displacement_matrix_sides()
to get the matrices directly insteadReturns: The sides with displacements on them Return type: list
ofSide
-
get_linked_vertices
(vertex: Vertex, similar=0.0) → List[Vertex, ...]¶ Parameters: - vertex (
Vertex
) – The vertex to check against - similar (
float
) – Distance between vertices to be considered similar (in Hammer units)
Returns: All vertices that are in close proximity to the given vertex itself included
Return type: list
ofVertex
- vertex (
-
get_only_unique_vertices
() → List[Vertex, ...]¶ Finds all unique vertices on the solid, you should not use this for vertex manipulation as changing one doesn’t change all of them. See
get_all_vertices()
Returns: all unique vertices Return type: list
ofVertex
-
get_texture_sides
(name: str, exact=False) → List[Side, ...]¶ Parameters: - name (
string
) – The name of the texture including path (ex: tools/toolsnodraw) - exact (
bool
) – Determines if the material has to be letter for letter the same or just contain the string
Returns: The sides using the given texture
Return type: list
ofSide
- name (
-
has_texture
(name: str, exact=False) → bool¶ Parameters: - name (
string
) – The name of the texture including path (ex: tools/toolsnodraw) - exact (
bool
) – Determines if the material has to be letter for letter the same or just contain the string
Returns: if any sides of the solid contain the given texture
Return type: bool
- name (
-
is_simple_solid
() → bool¶ Returns: A solid is considered simple if it has 6 or less sides Return type: bool
-
link_vertices
(similar=0.0)¶ Tries to link all the vertices that are similiar
Parameters: similar –
-
move
(x, y, z)¶ Moves all sides of the solid by the given amount in Hammer units
Parameters: - x (
int
orfloat
) – - y (
int
orfloat
) – - z (
int
orfloat
) –
- x (
-
naive_subdivide
(x=1, y=1, z=1) → List[Solid, ...]¶ Naively subdivides a copy of the solid, works best for rectangular shapes. It’s naive because it scales down the solid then creates an array from that
Parameters: - x (
int
) – Amount of cuts on the x axis - y (
int
) – Amount of cuts on the y axis - z (
int
) – Amount of cuts on the z axis
Returns: Solids from a subdivided solid
Return type: list
ofSolid
- x (
-
remove_all_displacements
()¶ Removes all displacements from the solid
-
replace_texture
(old_material: str, new_material: str)¶ Checks all the sides if they have the given texture, if so replace it
Parameters: - old_material (
String
) – The texture to check - new_material (
String
) – The texture to replace the old one with
- old_material (
-
rotate_x
(center: PyVMF.Vertex, angle)¶ Rotates the solid around the x axis
Parameters: - center (
Vertex
) – The point to rotate around - angle (
int
orfloat
) – How much to rotate in degrees
- center (
-
rotate_y
(center: PyVMF.Vertex, angle)¶ Rotates the solid around the y axis
Parameters: - center (
Vertex
) – The point to rotate around - angle (
int
orfloat
) – How much to rotate in degrees
- center (
-
rotate_z
(center: PyVMF.Vertex, angle)¶ Rotates the solid around the z axis
Parameters: - center (
Vertex
) – The point to rotate around - angle (
int
orfloat
) – How much to rotate in degrees
- center (
-
scale
(center: PyVMF.Vertex, x=1.0, y=1.0, z=1.0)¶ Scales the solid using ratios. For example using the center of the solid and values of 2 makes it twice as big
Parameters: - center (
Vertex
) – The point from which the scaling is based, use the center of the solid for traditional scaling - x (
int
orfloat
) – Scale ratio on the x axis - y (
int
orfloat
) – Scale ratio on the y axis - z (
int
orfloat
) – Scale ratio on the z axis
- center (
-
set_texture
(new_material: str)¶ Sets the given texture on all sides
Parameters: new_material ( str
) – The texture to replace them all
-
window
(direction: Vertex = None) → List[Solid, Solid, Solid, Solid]¶ Creates a hole in the wall, only works on 90 degree blocks
Parameters: direction ( Vertex
) – If set defines the direction the hole will be made, requires exactly 2 non-zero valuesReturns: The 4 blocks surrounding the hole Return type: list
ofSolid
-
-
class
SolidGenerator
¶ Bases:
object
Generates solids from scratch, remember you still need to add them to
VMF
usingadd_solids()
-
static
cube
(vertex: PyVMF.Vertex, w, h, l, center=False, dev=0) → PyVMF.Solid¶ Generates a solid cube
Parameters: - vertex (
Vertex
) – Start position from which to build the cube - w (
int
) – Width of the cube - h (
int
) – Height of the cube - l (
int
) – Length of the cube - center (
bool
) – If set to True centers the solid on the vertex - dev (
int
) – If set, changes the cube texture, seedev_material()
Returns: A generated solid
Return type: - vertex (
-
static
dev_material
(solid: PyVMF.Solid, dev: int)¶ Changes the material of the solid to single color dev textures, quick and useful when testing
Parameters: - solid (
Solid
) – The target solid - dev (
int
) – The target texture between 1 and 5
- solid (
-
static
displacement_triangle
(vertex: PyVMF.Vertex, w, h, l, dev=0) → PyVMF.Solid¶ Generates a displacement triangle (L shaped viewed from above)
Parameters: - vertex (
Vertex
) – Start position from which to build the triangle - w (
int
) – Width of the triangle - h (
int
) – Height of the triangle - l (
int
) – Length of the triangle - dev (
int
) – If set, changes the triangle texture, seedev_material()
Returns: A generated triangle
Return type: - vertex (
-
static
room
(vertex: Vertex, w, h, l, thick: int = 64, dev=0) → List[Solid, Solid, Solid, Solid, Solid, Solid]¶ Generates a sealed cubed room
Parameters: - vertex (
Vertex
) – Center position of the room - w (
int
) – Width of the room - h (
int
) – Height of the room - l (
int
) – Length of the room - thick (
int
) – The thickness of the walls - dev (
int
) – If set, changes the room texture, seedev_material()
Returns: A generated room
Return type: list
ofSolid
- vertex (
-
static
surf_ramp
(vertex: PyVMF.Vertex, w, h, l, top_cut=32, side_cut=32, center=False, ramp_texture='cs_italy/cobble02', top_texture='cs_italy/plasterwall02a', side_texture='cs_italy/plasterwall02a') → PyVMF.Solid¶ Generates a ramp (triangle viewed from above: △)
Parameters: - vertex (
Vertex
) – Start position from which to build the ramp (bottom middle of the ramp) - w (
int
) – Width of the ramp - h (
int
) – Height of the ramp - l (
int
) – Length of the ramp - top_cut (
int
) – Width of the cut at the top - side_cut (
int
) – Height of the cut on the side - center (
bool
) – If set to True centers the ramp on the vertex - ramp_texture (
str
) – - top_texture (
str
) – - side_texture (
str
) –
Returns: A generated ramp
Return type: - vertex (
-
static
-
class
TriangleTag
(x, y)¶ Bases:
PyVMF.Common
-
class
TriangleTags
(matrix, dic: Optional[dict] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'triangle_tags'¶
-
export
()¶ Gets all the variables than need to be exported into the .VMF file
Returns: All predefined (in export_list) variable names and their associated values Return type: dict
,dict
-
-
class
UVaxis
(x, y, z, offset, scale)¶ Bases:
PyVMF.Common
-
export
()¶ Gets all the variables than need to be exported into the .VMF file
Returns: All predefined (in export_list) variable names and their associated values Return type: dict
,dict
-
localize
(side)¶
-
-
class
VMF
¶ Bases:
object
Equivalent to a single .VMF file, holds all categories and all sub-categories
-
add_entities
(*args)¶ Adds entities to the entity list
Parameters: args – Entities to add
-
add_section
(section: importer.TempCategory)¶ Adds temporary categories to the VMF, used when reading .VMF files, you shouldn’t need to use this
Parameters: section ( importer.TempCategory
) – The temporary category to add
-
add_solids
(*args)¶ Adds solids to the world
Parameters: args – Solids to add
-
add_to_visgroup
(name: str, *args)¶ Adds the given elements to a visgroup, if it doesn’t exist one is created
Parameters: - name (
str
) – Name of the visgroup - args – Elements to add to the visgroup
- name (
-
blank_vmf
()¶ Generates necessary categories (overwriting existing), use
new_vmf()
to generate the VMF itself
-
export
(filename: str)¶ Exports the VMF to a .VMF file
Parameters: filename ( str
) – Exported file name, use a different filename or it will overwrite the existing file
-
get_all_from_visgroup
(name: str)¶ Gets everything from the visgroup
Parameters: name ( str
) – Name of the visgroupReturns: Solids and entities in the visgroup Return type: list
of (Entity
orSolid
)
-
get_entities
(include_hidden=False, include_solid_entities=False) → List[Entity, ...]¶ Gets all the entities
Parameters: - include_hidden (
bool
) – Whether to include quick hidden solids (Hammer “h” hotkey) or not - include_solid_entities (
bool
) – Whether to include solid entities (ex: trigger_teleport) or not
Returns: Entities in the VMF
Return type: list
ofEntity
- include_hidden (
-
get_group_center
(group: list, geo=False) → PyVMF.Vertex¶ Gets a vertex based on the average center of all the solids
Parameters: - group (
list
ofSolid
) – All the solids to include - geo – Whether to use the geometric center or not, see
center()
andcenter_geo()
Returns: The average center position of all the solids
Return type: - group (
-
get_solids
(include_hidden=False, include_solid_entities=True) → List[Solid, ...]¶ Gets all the solids
Parameters: - include_hidden (
bool
) – Whether to include quick hidden solids (Hammer “h” hotkey) or not - include_solid_entities (
bool
) – Whether to include solid entities (ex: trigger_teleport) or not
Returns: Solids in the VMF
Return type: list
ofSolid
- include_hidden (
-
get_solids_and_entities
(include_hidden=False)¶ Gets all the solids and entities
Parameters: include_hidden ( bool
) – Whether to include quick hidden solids (Hammer “h” hotkey) or notReturns: Solids and entities in the VMF Return type: list
of (Entity
orSolid
)
-
info_in_console
= False¶
-
mark_vertex
(vertex: PyVMF.Vertex, size: int = 32, dev: int = 1, visgroup: Optional[str] = None)¶ Quickly adds a solid cube at the given vertex, useful for debugging
Parameters: - vertex (
Vertex
) – The position on which the cube is centered on - size (
int
) – The size of the cube - dev (
int
) – The texture given to the cube, seedev_material()
- visgroup (
None
orstr
) – Optionally adding the cube to an existing visgroup
- vertex (
-
-
class
Vector
(x, y, z)¶ Bases:
PyVMF.Common
-
angle
(other)¶
-
angle_to_origin
()¶
-
cross
(other)¶
-
dot
(other)¶
-
mag
()¶
-
normalize
()¶
-
to_vertex
()¶
-
classmethod
vector_from_2_vertices
(v1: PyVMF.Vertex, v2: PyVMF.Vertex)¶
-
classmethod
vectors_from_side
(side: PyVMF.Side) → Tuple[PyVMF.Vector, PyVMF.Vector]¶
-
-
class
VersionInfo
(dic: Optional[dict] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'versioninfo'¶
-
-
class
Vertex
(x=0, y=0, z=0)¶ Bases:
PyVMF.Common
Corresponds to a single position on the Hammer grid
Parameters: - x (
int
orfloat
) – x position - y (
int
orfloat
) – y position - z (
int
orfloat
) – z position
-
align_to_grid
()¶ Turns x, y and z into integers
-
diff
(other) → PyVMF.Vertex¶ Parameters: other – The vertex to differentiate with Returns: The difference in distance between 2 vertices Return type: Vertex
-
divide
(amount)¶ Divides all the axes uniformly by the given amount (for separate division see
divide_separate()
)Parameters: amount ( int
orfloat
) – How much to divide each axis by
-
divide_separate
(x, y, z)¶ Divides all the axes separatedly by the given amounts (for uniform division see
divide()
)Parameters: - x (
int
orfloat
) – Amount to divide x axis by - y (
int
orfloat
) – Amount to divide y axis by - z (
int
orfloat
) – Amount to divide z axis by
- x (
-
export
() → Tuple[int, int, int]¶ Gets all the variables than need to be exported into the .VMF file
Returns: All predefined (in export_list) variable names and their associated values Return type: dict
,dict
-
flip
(x=None, y=None, z=None)¶
-
move
(x, y, z)¶ Moves the vertex by the given amount
Parameters: - x (
int
orfloat
) – Amount to move the x axis by - y (
int
orfloat
) – Amount to move the y axis by - z (
int
orfloat
) – Amount to move the z axis by
- x (
-
multiply
(amount)¶ Multiplies all the axes uniformly by the given amount
Parameters: amount ( int
orfloat
) – How much to multiply each axis by
-
rotate_x
(center: PyVMF.Vertex, angle)¶ Rotates the vertex around the x axis
Parameters: - center (
Vertex
) – The point to rotate around - angle (
int
orfloat
) – How much to rotate in degrees
- center (
-
rotate_y
(center: PyVMF.Vertex, angle)¶ Rotates the vertex around the y axis
Parameters: - center (
Vertex
) – The point to rotate around - angle (
int
orfloat
) – How much to rotate in degrees
- center (
-
rotate_z
(center: PyVMF.Vertex, angle)¶ Rotates the vertex around the z axis
Parameters: - center (
Vertex
) – The point to rotate around - angle (
int
orfloat
) – How much to rotate in degrees
- center (
-
set
(x, y, z)¶ Sets the vertex position to the given position
Parameters: - x (
int
orfloat
) – New x position - y (
int
orfloat
) – New y position - z (
int
orfloat
) – New z position
- x (
-
similar
(other, accuracy=0.001) → bool¶ Compares the current vertex with the given one to see if they are similar
Parameters: - other (
Vertex
) – - accuracy (
float
) – Distance from the current vertex to be considered similar (in Hammer units)
Returns: If the given vertex is within the proximity of the current vertex
Return type: bool
- other (
- x (
-
class
ViewSettings
(dic: Optional[dict] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'viewsettings'¶
-
-
class
VisGroup
(dic: Optional[dict] = None, children: Optional[list] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'visgroup'¶
-
-
class
VisGroups
(dic: Optional[dict] = None, children: Optional[list] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'visgroups'¶
-
export_children
() → Tuple[PyVMF.VisGroup, ...]¶ Gets all the children classes
Returns: All predefined children classes Return type: list
ofCommon
instances
-
get_visgroups
() → List[PyVMF.VisGroup]¶
-
new_visgroup
(name: str) → PyVMF.VisGroup¶
-
-
class
World
(dic: Optional[dict] = None, children: Optional[list] = None)¶ Bases:
PyVMF.Common
-
NAME
= 'world'¶
-
-
load_vmf
(name: str, merge_vertices=0.0001) → PyVMF.VMF¶ Loads a .VMF file
Parameters: - name (
str
) – The OS file to open, path needs to be included - merge_vertices (
int
orfloat
) – Vertices on a solid within this distance are merged into a single vertex class, set to 0 for no merging
Returns: A loaded VMF
Return type: - name (
-
new_vmf
() → PyVMF.VMF¶ Generates a VMF with the necessary classes
Returns: A blank VMF Return type: VMF
VMF () |
Equivalent to a single .VMF file, holds all categories and all sub-categories |
Solid (dic, children) |
Corresponds to an individual solid just like in Hammer |
SolidGenerator |
Generates solids from scratch, remember you still need to add them to VMF using add_solids() |
Entity (dic, children) |
|
EntityGenerator |
Generates entities from scratch, remember you still need to add them to VMF using add_entities() |
Side (dic, children) |
Corresponds to a face/side of a solid. |
Vertex ([x, y, z]) |
Corresponds to a single position on the Hammer grid |
DispInfo (dic, children, parent_side) |
Keeps track of all the different displacement settings and values |
DispVert () |
Keeps track of each individual displacement vertex |
Matrix (size) |
A grid for keeping track of the displacement values. |