Neon Junkyard Posted January 23, 2019 Share Posted January 23, 2019 I'm trying to create network boxes with padding in python However I'm having problems getting the padding to be even and constant on all sides. I can recreate the built in functionality with fitAroundContents(), but I cant figure out how to correctly figure out the bounding rect from that and then expand it evenly on all sides. I think this is partially because I'm not correctly calculating the center point from sel.position Here is my code so far (my python knowledge is very basic). Any help is much appreciated! sel = hou.selectedNodes()[0] all = hou.selectedNodes() pos = sel.position() parent = sel.parent() box = parent.createNetworkBox() box.setPosition(sel.position()) # add selected nodes for node in all: box.addItem(node) # set color box.setColor(hou.Color(0.3, 0.3, 0.3)) # fit box box.fitAroundContents() # fit box size = box.size() center = box.position() pad = hou.Vector2(2, 2) # set bounding box bbox = hou.BoundingRect((center[0]-size[0])-pad[0], (center[1]-size[1])-pad[1], (center[0]+size[0])+pad[0], (center[1]+size[1])+pad[1]) # set to bbox box.setBounds(bbox) Quote Link to comment Share on other sites More sharing options...
Arihant Fx Posted October 12, 2020 Share Posted October 12, 2020 (edited) Edited October 12, 2020 by Arihant Fx Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.