Isotropix Forums

How to use "SetItemsPositions"

Clarisse Scripting related topics

How to use "SetItemsPositions"

Unread postby gerdhofer » Mon Mar 02, 2020 7:44 pm

Hi again,

I have scripts to create materials automatically. Unfortunately, all material nodes and icons are stacked in the material editor. When I shift a node manually the console prints out a command like that one:

Code: Select all
ix.cmds.SetItemsPositions(["project://scene/standard"], [(561, 70)], "mat_1")


The first two arguments are clear, but what is the third one ("mat_1"), please? Is this perhaps the material editor itself? When I try to use this command inside a simple script I get an error:

Unknown command type: TYPE_NONE
No matching signature found for command 'SetItemsPositions' with '3' arguments.
Found signatures:
(TYPE_ARRAY_STRING, TYPE_ARRAY_VEC2I, TYPE_STRING)
Given arguments:
TYPE_ARRAY_STRING, TYPE_NONE
AttributeError: Unknown command type: TYPE_NONE

Help is - as always - much appreciated :)
Gerd
gerdhofer
 
Posts: 53
Joined: Thu Aug 30, 2018 11:05 am

Re: How to use "SetItemsPositions"

Unread postby anemoff » Tue Mar 03, 2020 11:45 am

Hi,

The error is telling you that the 2nd command parameter type is incorrect.
As the message says, the command is expecting:
- an array of strings: list of nodes to edit
- an array of GMathVec2i: list of node positions to set (list size must match with the node list)
- a string for the position slot name: this parameter should always be "mat_1" when you want to edit positions in the Material Editor. You guessed correctly.

But there is a small bug in the output of the command, misleading the users when wanting to re-use the command output.
This bug will be fixed in a future version.

This:
Code: Select all
ix.cmds.SetItemsPositions(["project://scene/standard"], [(561, 70)], "mat_1")

Should be this:
Code: Select all
ix.cmds.SetItemsPositions(["project://scene/standard"], [ix.api.GMathVec2i(561, 70)], "mat_1")


If you want to edit multiple positions in a single command, use it like this:
Code: Select all
nodes = ["project://scene/node1", "project://scene/node1"] # ...
positions = [ix.api.GMathVec2i(100, 200), ix.api.GMathVec2i(300, 400)] # ...
ix.cmds.SetItemsPositions(nodes, positions, "mat_1")


What do you want to do exactly? Do you want to organize programmatically the nodes?
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 282
Joined: Wed Jan 13, 2016 10:10 am

Re: How to use "SetItemsPositions"

Unread postby gerdhofer » Tue Mar 03, 2020 11:53 am

Many thanks again anemoff!

Yes, you're right: I want to reorganize my material nodes automatically and your idea with the node and position lists is super helpful. I got most my things running, but sometimes I'm struggling with details like the one here. Fortunately your support is outstanding.

Cheers,
Gerd
gerdhofer
 
Posts: 53
Joined: Thu Aug 30, 2018 11:05 am

Re: How to use "SetItemsPositions"

Unread postby anemoff » Tue Mar 03, 2020 11:56 am

You're welcome!
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 282
Joined: Wed Jan 13, 2016 10:10 am


Return to Scripting