Hello
I have absolutelly no experience in scripting, but would like to request a probably easy task that would be helpful to most in our community.
A small script that would automatically refresh all the scatter nodes in a scene. Would this be difficult to achieve through scripting?
Thanks
Best regards
Filipe
Script request to refresh scatter nodes
- stratified
- Posts: 945
- Joined: Wed Aug 15, 2012 6:32 am
- Location: Auckland, New Zealand
hi there,
Sure that's possible. Here's a small code snippet for the users who want to try and tackle this problem (getSelection is new in 1.23). It shouldn't be too hard:
cheers,
Thomas
Sure that's possible. Here's a small code snippet for the users who want to try and tackle this problem (getSelection is new in 1.23). It shouldn't be too hard:
Code: Select all
-- gets the selected scatter node
scatter = octane.project.getSelection()[1]
-- 3x4 matrices (actually, they are standard 4x4 transform matrices in disguise but we ommit the last (0, 0, 0, 1) row)
transforms =
{
-- unit matrix
{
{ 1, 0, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 0, 1, 0 }
},
-- transformed matrix ( 2x scaling + translation)
{
{ 2, 0, 0, 5 },
{ 0, 2, 0, 5 },
{ 0, 0, 2, 5 },
}
}
-- set the array of transformations in the scatter node
scatter:setAttribute(octane.A_TRANSFORMS, transforms)
Thomas
- stratified
- Posts: 945
- Joined: Wed Aug 15, 2012 6:32 am
- Location: Auckland, New Zealand
Hi there,
Here's something more complete. This script will reload the file in each scatter node. For the interested users, there's a generic update function here which will call a predicate function on each node of a specific type in the project. This might come in handy in other scripts.
cheers,
Thomas
Here's something more complete. This script will reload the file in each scatter node. For the interested users, there's a generic update function here which will call a predicate function on each node of a specific type in the project. This might come in handy in other scripts.
Code: Select all
-- Calls the predicate function on each item of the given type.
-- This will recursive in each graph to find nodes of the given type.
--
-- @param graph (Graph)
-- @param nodeType (Type of node we're looking for)
-- @param pred (Predicate function that takes a scatter node)
function updateItem(g, nodeType, pred)
for i, item in ipairs(g:getOwnedItems()) do
if item:getProperties().type == nodeType then
pred(item)
elseif item:getProperties().isGraph then
updateItem(item, nodeType, pred)
end
end
end
-- reloads a scatter node
function reloadScatter(node)
print("reloading ", node)
node:setAttribute(octane.A_RELOAD, true)
end
updateItem(octane.nodegraph.getRootGraph(), octane.NT_GEO_SCATTER, reloadScatter)
Thomas
- stratified
- Posts: 945
- Joined: Wed Aug 15, 2012 6:32 am
- Location: Auckland, New Zealand
getSelection() (and other selection stuff) will be there in the next release candidate (1.23)
What do you mean by other ways? You can run a script from the command line as well (octane.exe --script myscript.lua) if you want to fully integrate Octane in some other tools.
Non-modal windows might be there in Octane 2.x but not for this 1.5 release. We need to think about this a bit more because with non-modal windows you could actually modify a lot of stuff in the standalone while your script is running (and make Octane crash). That's why the GUI is fully blocked while running a script.
not sure what you mean with additional buttons & shortcuts, could you elaborate a bit.
cheers,
Thomas
What do you mean by other ways? You can run a script from the command line as well (octane.exe --script myscript.lua) if you want to fully integrate Octane in some other tools.
Non-modal windows might be there in Octane 2.x but not for this 1.5 release. We need to think about this a bit more because with non-modal windows you could actually modify a lot of stuff in the standalone while your script is running (and make Octane crash). That's why the GUI is fully blocked while running a script.
not sure what you mean with additional buttons & shortcuts, could you elaborate a bit.
cheers,
Thomas
- stratified
- Posts: 945
- Joined: Wed Aug 15, 2012 6:32 am
- Location: Auckland, New Zealand
okay, I understand we'll put something on our TODO list to assign shortcuts to scripts.
cheers,
Thomas
cheers,
Thomas
- stratified
- Posts: 945
- Joined: Wed Aug 15, 2012 6:32 am
- Location: Auckland, New Zealand
We're going to try and come up with a solution that fits more nicely in the workflow in one of the next releases.
cheers,
Thomas
cheers,
Thomas
What is this scripting thing!
Why is it catching fire even with the non-programmers
Why is it making this thing called Octane popular
To find these answers, we will need to scan through these pages to discover the hidden treasures.

Why is it catching fire even with the non-programmers

Why is it making this thing called Octane popular

To find these answers, we will need to scan through these pages to discover the hidden treasures.

Win 11 64GB | NVIDIA RTX3060 12GB