Skip to main content
Known Participant
October 16, 2023
Open for Voting

obtain child comment graph pos

  • October 16, 2023
  • 2 replies
  • 129 views

could you add a method so we can obtain a child comment's graph position?

 

i have this plugin that when placing entities(nodes/objects) in scene, it first checks if an entity is selected, if so, it offsets the new entity from that. however when it comes to offsetting something from a selected comment thats a child of a node, then the newly placed entity is badly offset due to the child comment's pos being based off the nodes coordinate system rather than the graphs.

 

regards,

phil

2 replies

Known Participant
October 17, 2023

ty, hopefully a more robust method would be implemented in future.

 

regards,

phil

Cyril Dellenbach
Community Manager
Community Manager
October 17, 2023

Hi Phil,

 

The idea is to use the position of the node + the comment's offset.

 

import sd
from sd.api.sdbasetypes import float2
app = sd.getContext().getSDApplication()
ui_mgr = app.getQtForPythonUIMgr()
graph = ui_mgr.getCurrentGraph()
node = graph.getNodes()[0]
node_pos = node.getPosition()
obj = graph.getGraphObjects()[0]
obj_pos_relative = obj.getPosition()
obj_pos = float2(
	node_pos.x + obj_pos_relative.x,
	node_pos.y + obj_pos_relative.y
	)
print("Node position - " + str(node_pos))
print("Comment position (relative) - " + str(obj_pos_relative))
print("Comment position (absolute) - " + str(obj_pos))


Note that this will work only with a single node graph, and this node must have a comment.

Best regards,

Cyril Dellenbach (Micro) | QA Support Artist | Adobe