VRED 2024, Python, Access to core attachments

VRED 2024, Python, Access to core attachments

andreasK3K4G
Enthusiast Enthusiast
671 Views
4 Replies
Message 1 of 5

VRED 2024, Python, Access to core attachments

andreasK3K4G
Enthusiast
Enthusiast

Hi,

i have some special case this time.

When have a (transform) node, Going to Transform->RotationPivot. I can change the Alignment to "Direction Vector". (#1 in my picture)

Having a look to the node attribute editor, this will create a new attachment to the "core Transform3D (xxxxx)"

See picture #2.

 

Is it possible to create this attachment and access the values via python, in order to change the rotation pivot alignment to Direction Vector and add new values?

With field access attachment i can only reach the attachments directly under the node. (like "Name")

 

Best regards

Andreas

0 Likes
Accepted solutions (1)
672 Views
4 Replies
Replies (4)
Message 2 of 5

Eduardt_AlbergEZ998
Participant
Participant

Hi Andreas,

 

long story short:

my_node = findNode("my_node")

# create the attachment and add it to the node
attachment = createAttachment("StringAttributeMap")
vrFieldAccess(attachment ).setBool("internal",False)
vrFieldAccess(attachment ).setMString("keys",["rotationDirection"])
vrFieldAccess(attachment ).setMString("values",["0 0 1 0"])
vrFieldAccess(my_node.fields().getFieldContainer('transform')).addAttachment(attachment)

# set the rotation_pivot direction
vrFieldAccess(vrFieldAccess(my_node.fields().getFieldContainer('transform')).getAttachment("StringAttributeMap")).setMString('values',['0 1 0 0'])

# get the rotation_pivot direction
print(vrFieldAccess(vrFieldAccess(my_node.fields().getFieldContainer('transform')).getAttachment("StringAttributeMap")).getMString('values'))

 

I guess the ui is not updating to the rotation mode, but the data is set, so i think it should work 🙂

 

best regards

VREDuardt

0 Likes
Message 3 of 5

andreasK3K4G
Enthusiast
Enthusiast

Hi Eduardt,

 

this looks promising. Unfortunately I get the error in line 8.
"vrFieldAccess::getField: Couldn't find field 'transform'"

 

I guess the field container name is something different. Tried "core Transform3D" and also "Transform3D" with no luck.

0 Likes
Message 4 of 5

Eduardt_AlbergEZ998
Participant
Participant
Accepted solution

Hi Andreas,

 

i guess you want to modify a group node. The difference is that a group node itself has the transform fieldcontainer as core. In a geometry node the transform field container is a child of the core Geometry field container. You can see structure in the node attribute editor. I modified the script to work on a group node:

my_node = findNode("myGroup")

# create the attachment and add it to the node
attachment = createAttachment("StringAttributeMap")
vrFieldAccess(attachment ).setBool("internal",False)
vrFieldAccess(attachment ).setMString("keys",["rotationDirection"])
vrFieldAccess(attachment ).setMString("values",["0 0 1 0"])
my_node.fields().addAttachment(attachment)

# set the rotation_pivot direction
vrFieldAccess(my_node.fields().getAttachment("StringAttributeMap")).setMString('values',['0 1 0 0'])

# get the rotation_pivot direction
print(vrFieldAccess(my_node.fields().getAttachment("StringAttributeMap")).getMString('values'))
0 Likes
Message 5 of 5

andreasK3K4G
Enthusiast
Enthusiast

Hi Eduardt,

thanks a lot, this is working.

Just to figure out, how to "update" the group, so the new rotation pivot orientation is also visible and working in render window then.

Right now, i need to go to RotationPivot Alignment and hit return on the x value to make the changes active.

0 Likes