Skip to content

Instantly share code, notes, and snippets.

<html><head><title>  ​​</title><style>
div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td { margin: 0; padding: 0; }
ul { list-style-type: none; }
body {
background-color: #252525;
color: #a0a0a0;
font-family: 'Segoe UI', sans-serif;
font-weight: 400;
font-size: 0.85vw;
line-height: 0.97vw;
<html><head><title>  ​​</title><style>
div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td { margin: 0; padding: 0; }
ul { list-style-type: none; }
body {
background-color: #252525;
color: #a0a0a0;
font-family: 'Segoe UI', sans-serif;
font-weight: 400;
font-size: 0.85vw;
line-height: 0.97vw;

Maya Scripts

About

These are some MEL scripts I've assigned to hotkeys. They are written or pieced together by me based on stuff I found in maya documentation, stackoverflow, forums, etc., or my own guesswork or trial and error. I'm sure there are plenty of weird edge cases where some scripts don't work or break somehow, I fix them as I discover them. The list looks longer than it really is, because many scripts have copies for each axis, some for +/- on each axis as well. Also some scripts depend on the presence of others, it should be mentioned in the description of each script if so.

My current hotkey sheet can be seen here (source is here) and you can make your own using my templates which are explained in this video.

I recommend [Auto

@ronyx69
ronyx69 / replace_net_with_net.cs
Last active May 18, 2022 17:57
Replace target networks with replacement networks. Could break everything idk.
// replace all target nets with replacement net
var target = PrefabCollection<NetInfo>.FindLoaded("Pedestrian Connection Surface");
var replacement = PrefabCollection<NetInfo>.FindLoaded("Pedestrian Connection");
var b = NetManager.instance.m_segments.m_buffer;
for(var i=0;i<b.Length;i++) if(b[i].m_flags!=0) if(b[i].Info==target) b[i].Info=replacement;
var b2 = NetManager.instance.m_nodes.m_buffer;
for(var i=0;i<b2.Length;i++) if(b2[i].m_flags!=0) if(b2[i].Info==target) b2[i].Info=replacement;
for(var i=0;i<b.Length;i++) if(b[i].m_flags!=0) NetManager.instance.UpdateSegment((ushort)i);
@ronyx69
ronyx69 / PropBufferReadSet.cs
Last active July 18, 2021 09:57
Reads the prop buffer and generates a script to set it. Intended for reading/setting props for buildings in the asset editor. Generated example below the actual script.
// You must place the exact amount of props (any kind of props anywhere) before running the prop set script, otherwise it will not work properly.
// Generate a script to place props, located in local addons folder.
var s = "PropInstance[] nb = new PropInstance[65536];\n\n";
var buffer = PropManager.instance.m_props.m_buffer;
for(var i = 0; i < buffer.Length; i++) if (buffer[i].m_flags!=0) {
s = s + "nb[" + i + "].Angle = " + buffer[i].Angle + "f;\n";
s = s + "nb[" + i + "].Blocked = " + buffer[i].Blocked.ToString().ToLower() + ";\n";
@ronyx69
ronyx69 / SetLaneProps.cs
Last active January 31, 2021 12:10
Script to set lane props for a network currently loaded in the asset editor. (for any elevation and lane) And another script which generates a script to set/edit lane props.
// Script to set lane props. Replaces all lane props!
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as NetInfo; var ai = asset.m_netAI as RoadAI;
List<NetLaneProps.Prop>[] basic = new List<NetLaneProps.Prop>[asset.m_lanes.Length];
for (int i = 0; i < basic.Length; i++) basic[i] = new List<NetLaneProps.Prop>();
var elevatedLanes = 0;
if(ai.m_elevatedInfo != null) if(ai.m_elevatedInfo.m_lanes != null) if(ai.m_elevatedInfo.m_lanes.Length != 0) elevatedLanes = ai.m_elevatedInfo.m_lanes.Length;
List<NetLaneProps.Prop>[] elevated = new List<NetLaneProps.Prop>[elevatedLanes];
for (int i = 0; i < elevated.Length; i++) elevated[i] = new List<NetLaneProps.Prop>();
var bridgeLanes = 0;
if(ai.m_bridgeInfo != null) if(ai.m_bridgeInfo.m_lanes != null) if(ai.m_bridgeInfo.m_lanes.Length != 0) bridgeLanes = ai.m_bridgeInfo.m_lanes.Length;
@ronyx69
ronyx69 / ReplaceLaneProps.cs
Created January 10, 2020 21:12
Replace lane props on networks in the asset editor.
Action<string, string> ReplaceProp = (search, replace) =>
{
var replacementProp = PrefabCollection<PropInfo>.FindLoaded(replace);
for (uint i = 0; i < PrefabCollection<NetInfo>.LoadedCount(); i++)
{
var prefab = PrefabCollection<NetInfo>.GetLoaded(i);
if (prefab == null) continue;
if(prefab.m_lanes != null) foreach (var Lane in prefab.m_lanes)
{
@ronyx69
ronyx69 / NetworkElevationRenamer.cs
Created December 27, 2019 05:40
Renames elevations based on the name of the loaded asset.
// Renames elevations, to fix the game adding 0 or 1 to the elevation names, so that they can be kept consistent when updating a network multiple times.
// Do not run on a newly created network, it must be saved with the final name it should have, loaded again, and only then run this script.
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as NetInfo;
var ai = (asset.m_netAI as TrainTrackAI); // change this to RoadAI or something else if necessary.
if(ai.m_elevatedInfo != null) ai.m_elevatedInfo.name = ai.m_info.name.Substring(0, ai.m_info.name.Length-6) + " E";
if(ai.m_bridgeInfo != null) ai.m_bridgeInfo.name = ai.m_info.name.Substring(0, ai.m_info.name.Length-6) + " B";
if(ai.m_slopeInfo != null) ai.m_slopeInfo.name = ai.m_info.name.Substring(0, ai.m_info.name.Length-6) + " S";
if(ai.m_tunnelInfo != null) ai.m_tunnelInfo.name = ai.m_info.name.Substring(0, ai.m_info.name.Length-6) + " T";
@ronyx69
ronyx69 / Vehicle_PropMesh_Copy.cs
Last active May 19, 2019 16:21
Copies mesh from a prop to a vehicle, don't use for vehicles with tyres.
// Copies mesh from a prop to a vehicle, don't use for vehicles with tyres.
var propname = "filename.Asset Name"; // filename.Asset Name
var prop = PrefabCollection<PropInfo>.FindLoaded(propname + "_Data");
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as VehicleInfo;
asset.m_mesh.vertices = prop.m_mesh.vertices; asset.m_mesh.triangles = prop.m_mesh.triangles;
asset.m_mesh.tangents = prop.m_mesh.tangents; asset.m_mesh.normals = prop.m_mesh.normals;
asset.m_mesh.uv = prop.m_mesh.uv; asset.m_mesh.bounds = prop.m_mesh.bounds;
@ronyx69
ronyx69 / BuildingBaseMeshDelete.cs
Last active June 18, 2019 00:27
Script for deleting the automatically generated base mesh for buildings or building sub meshes.
// Deletes automatically generated base mesh based on vertex colors.
// Changes shader to NoBase, enables noBase boolean, raises or lowers vertices too close to 0.
var subMesh = -1; // sub mesh id, order as in ui, starting from 0 (-1 means main building mesh)
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as BuildingInfo;
var m = asset.m_mesh; var shader = Shader.Find("Custom/Buildings/Building/NoBase"); var newVertCount = 0;
if(subMesh >= 0) { m = asset.m_subMeshes[subMesh].m_subInfo.m_mesh;
if(asset.m_subMeshes[subMesh].m_subInfo.m_material != null) asset.m_subMeshes[subMesh].m_subInfo.m_material.shader = shader;
if(asset.m_subMeshes[subMesh].m_subInfo.m_lodMaterial != null) asset.m_subMeshes[subMesh].m_subInfo.m_lodMaterial.shader = shader;