Tom van t Hof

Notwar

About Me

EXPERTISE
Freelancer
INDUSTRY
Advertising / Motion Graphics

Connect

LOCATION
Rotterdam, Netherlands

Houdini Skills

Availability

I am available for Freelance Work

Recent Forum Posts

Houdini 20.5 ignore ocio system variable? Sept. 5, 2024, 8:56 a.m.

I've created a small .bat file to switch the OCIO variable on and off depending on your needs without going into the houdini.env all the time.

You can save the code below to a .bat file and double click it to switch between enabled and disabled states. I suppose you can tweak it a bit to do the same for a json package if that's how you've set up your OCIO.

Hope it is of some use


@echo off
setlocal

REM Below you can set the path to the houdini.env file if it's not in the standard location
set "FILE_PATH=C:\Users\%USERNAME%\Documents\houdini19.5\houdini.env"

REM Using PowerShell to find the line starting with "OCIO =" or "#OCIO =", then toggle it on or off
powershell -Command ^
    "$content = Get-Content '%FILE_PATH%';" ^
    "$modified = $false;" ^
    "$commentToggled = 'none';" ^
    "for ($i = 0; $i -lt $content.Length; $i++) {" ^
    "    if ($content[$i] -match '^#?OCIO =') {" ^
    "        if ($content[$i] -match '^#OCIO =') {" ^
    "            $content[$i] = $content[$i] -replace '^#', '';" ^
    "            $commentToggled = 'removed';" ^
    "        } else {" ^
    "            $content[$i] = '#' + $content[$i];" ^
    "            $commentToggled = 'added';" ^
    "        }" ^
    "        $modified = $true;" ^
    "        break;" ^
    "    }" ^
    "};" ^
    "if ($modified) {" ^
    "    $content | Set-Content '%FILE_PATH%';" ^
    "    if ($commentToggled -eq 'added') { Write-Host 'OCIO disabled' }" ^
    "    elseif ($commentToggled -eq 'removed') { Write-Host 'OCIO enabled' }" ^
    "} else {" ^
    "    Write-Host 'Line starting with \"OCIO =\" not found.' }"

echo Done.