Solved Distinguish males and femalies according to a scene file

Joined
Nov 22, 2026
Messages
4
Reactions
1
I want to implement package analysis with an external script.
I can read a scene json file from a VAR package, identify persons, used morphs, etc. But I found no robust way to find a person gender.
There is a number attibutes, which may store 'male' or 'female' word. For example, clothes ID, morphs ID, textures URL, etc. But none of them must exist (or contain 'male'/'female' word) for any person. Also, males and females have the same set of storables like 'FemaleEyelashes' and 'penisBaseControl'.
WiKi article says:
Selecting the material skin of the person atom is the only way to change the sex of the Person Atom.
But I'm unsure how it can help with scene json analysis. I guess, it is a 'character' attribute, which may store values like 'Female Custom'. But even this attribute in some scenes may store a proper noun like 'Julian' with no explicit indication of gender.
Is there a way to find gender for a person according to scene json content?
 
Solution
I think that "character"attribute is the only thing you can go by. There are only a few named characters though, basically the options you see on the "Skin Select" tab. You could just create static lists for those female and male names then cross reference them in your script.
I think that "character"attribute is the only thing you can go by. There are only a few named characters though, basically the options you see on the "Skin Select" tab. You could just create static lists for those female and male names then cross reference them in your script.
 
Upvote 0
Solution
I don't think there is a reliable way to do that. Names of texture files, morphs clothes, etc. will vary all over the place. One thing you might do is count how many morphs are exclusive to one gender or the other, then take a majority vote. That will get screwed up by Futas, which may have many of both. There are specific morphs that all Futas have to have, so you can ID those. Altfutas are another story.
 
Upvote 0
Thanks for the answers! With additional investigation, I see that Clownmug's answer is correct: To find a person gender, one needs to read 'character' attribute and compare it against predefined material skins (29 skins for females, 18 skins for males). Very straightforward solution...
Hopefully, I don't need to deal with futas because there are no separate morph groups, clothes, etc. for futas in VaM.
 
Upvote 0
From the spreadsheets, it looks like Skin UV might be simpler. I correct myself!
Agree. But I just checked few random packages. It seems, that 'character' attribute is guaranteed to exist for every person (at least I hope so). And Skin UV is provided if it should be overriden only.
 
Upvote 0
I tested the below on the saves I have, should work.
You can test on what you have to spot check accuracy.

Just keep in mind this is modern .NET, so just make sure you use at least C# 12 and .NET 8.

C#:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;

public static class PersonGender
{
    const string _atomsKey = "atoms";
    const string _idKey = "id";
    const string _atomTypeKey = "type";
    const string _storablesKey = "storables";
    const string _characterKey = "character";

    const string _personType = "Person";
    const string _geometryStorableId = "geometry";

    const string _presetLabel = "(preset)";

    const string _male = "Male";
    const string _female = "Female";
    const string _basisStock = "stock list";
    const string _basisStorables = "storables (weaker)";

    // Storables only a female body has. Add more here if you find reliable ones.
    // Note: They're not on every save, this is just an accuracy step because it depends what is actually stored.
    static readonly string[] _femaleOnlyStorables =
    [
        "BreastPhysicsMesh",
        "BreastInOut"
    ];

    static readonly string[] _femaleBaseStock =
    [
        "Female Dummy",
        "Female Custom",
        "Candy",
        "Evey",
        "Janie",
        "Kayla",
        "Lexi",
        "Maria",
        "Mia",
        "Simone",
        "Tara",
        "Tina"
    ];

    static readonly string[] _maleBaseStock =
    [
        "Male Dummy",
        "Male Custom",
        "Lee",
        "Julian"
    ];

    static readonly string[] _futaBaseStock =
    [
        "Futa Lexi",
        "Futa Maria",
        "Futa Mia",
        "Futa Simone",
        "Futa Kayla"
    ];

    static readonly string[] _femaleNumberedStock = Numbered("Female ", 1, 17);
    static readonly string[] _maleNumberedStock = Numbered("Male ", 1, 9);

    // Display names of VaM's stock characters, taken from the in-game character list.
    // Futa characters live in the male container, so they count as male.
    // Static fields initialise in textual order: keep these sets below the arrays they splat,
    // or they are built from null.
    static readonly HashSet<string> _maleStock =
        new(
            [
                .. _maleBaseStock,
                .. _maleNumberedStock,
                .. _futaBaseStock
            ],
            StringComparer.OrdinalIgnoreCase
        );

    static readonly HashSet<string> _femaleStock =
        new(
            [
                .. _femaleBaseStock,
                .. _femaleNumberedStock
            ],
            StringComparer.OrdinalIgnoreCase
        );

    public static int Main(string[] args)
    {
        if (args.Length != 1)
        {
            Console.Error.WriteLine("Usage: PersonGender <scene.json | preset.vap>");
            return 1;
        }

        using JsonDocument scene = JsonDocument.Parse(File.ReadAllText(args[0]));

        foreach (JsonElement atom in PersonAtoms(scene.RootElement))
        {
            (string gender, string character, string basis) = GenderOf(atom);
            string label = ReadString(atom, _idKey);
            Console.WriteLine($"{(label.Length > 0 ? label : _presetLabel)}: {gender} (character '{character}', by {basis})");
        }

        return 0;
    }

    static IEnumerable<JsonElement> PersonAtoms(JsonElement scene)
    {
        // An appearance preset (.vap) has no atoms: its root is the Person's storables.
        if (scene.TryGetProperty(_storablesKey, out _))
        {
            return [scene];
        }

        return Items(scene, _atomsKey)
            .Where(atom => ReadString(atom, _atomTypeKey) == _personType);
    }

    static (string Gender, string Character, string Basis) GenderOf(JsonElement personAtom)
    {
        List<JsonElement> storables = [.. Items(personAtom, _storablesKey)];

        JsonElement geometry = storables.FirstOrDefault(s => ReadString(s, _idKey) == _geometryStorableId);

        string character = geometry.ValueKind == JsonValueKind.Object
            ? ReadString(geometry, _characterKey)
            : string.Empty;

        if (_maleStock.Contains(character))
        {
            return (_male, character, _basisStock);
        }

        if (_femaleStock.Contains(character))
        {
            return (_female, character, _basisStock);
        }

        HashSet<string> ids = [.. storables.Select(s => ReadString(s, _idKey))];

        bool hasFemaleStorable = _femaleOnlyStorables.Any(ids.Contains);

        string gender = hasFemaleStorable ? _female : _male;

        return (gender, character, _basisStorables);
    }

    static string[] Numbered(string prefix, int first, int count)
    {
        return [.. Enumerable.Range(first, count).Select(i => prefix + i)];
    }

    /// <summary>The elements of an array property, or nothing when it is missing or not an array.</summary>
    static IEnumerable<JsonElement> Items(JsonElement parent, string name)
    {
        if (parent.TryGetProperty(name, out JsonElement array) && array.ValueKind == JsonValueKind.Array)
        {
            return array.EnumerateArray();
        }

        return [];
    }

    /// <summary>A string property, or an empty string when it is missing or not a string.</summary>
    static string ReadString(JsonElement parent, string name)
    {
        if (parent.ValueKind == JsonValueKind.Object
            && parent.TryGetProperty(name, out JsonElement value)
            && value.ValueKind == JsonValueKind.String)
        {
            return value.GetString() ?? string.Empty;
        }

        return string.Empty;
    }
}
 
Upvote 0
Back
Top Bottom