Cloaks Posted April 29, 2016 Share Posted April 29, 2016 Hi there Odforce! I had a small question which I hope someone will know the answer to! When i'm in the COP context, and I create a text node, how can I then get the actual width of the text? As you can see in the top part of the image, there is quite a lot of black padding around the word "Layer". When I drag the text outside of the actual canvas, you can see the blue rectangle that represents the actual size of the word. Is there any way I can query the size of that blue rectangle? Some more background on what I'm trying to achieve: I would like to move and resize the text to a specific location within a canvas. The text however, isn't predefined, so I would need to know the actual size and position of the text without manually having to override the size to minimize the background behind the letters. Thank you all for your time! Quote Link to comment Share on other sites More sharing options...
Atom Posted April 29, 2016 Share Posted April 29, 2016 I noticed that when I create a Font node in COPs it is populated with $I variable for the integer frame value. On a whim I typed $W and it gave me the comp width. $H gives the comp height. You can also fetch the values of the font scaling using `ch("scale1")`. This is the number you would multiply by the $W to get the width. `$W * ch("scale1")` Quote Link to comment Share on other sites More sharing options...
Cloaks Posted April 30, 2016 Author Share Posted April 30, 2016 Hello Atom, thank you for your reply. The width and height of the entire font node area isn't exactly what I'm trying to get here though. I've added a few images to hopefully better explain the exact details of what I'm trying to get. Image 01: Roughly measuring the width I get from $W * ch("scale1") Image 02: Roughly measuring the width I would like to get Image 03: The blue rectangle in Houdini indicates that it knows those values. Now the big question is, how to get those values Quote Link to comment Share on other sites More sharing options...
yesyes Posted May 1, 2016 Share Posted May 1, 2016 bounding box? Quote Link to comment Share on other sites More sharing options...
Cloaks Posted May 1, 2016 Author Share Posted May 1, 2016 Entering the following into the text field of the font node yields 0 (zero). `bbox("../font4", D_XSIZE)` But that might have been expected due to the documentation for bbox reading as follows; Returns bounding box information for a surface node. I also looked into the python documentation for boundingbox stuff. That gave me hou.BoundingBox() , which instantiates a bounding box. The docs here also mention that it's for geometry. I guess that doesn't include the nodes in a COP2NET Quote Link to comment Share on other sites More sharing options...
malexander Posted May 1, 2016 Share Posted May 1, 2016 It's: imgbounds( <coppath>, <planename>, <dimension>, <frame>) So you'd do something like imgbounds("/img/cop2net1/font1", "C", "w", $I) Other dimension names are: x, x1: leftmost bounds y, y1: bottommost bounds x2: rightmost bounds, inclusive y2: topmost bounds, inclusive w, width: bounds width h, height: bounds height Return value is in pixels. 2 Quote Link to comment Share on other sites More sharing options...
Cloaks Posted May 1, 2016 Author Share Posted May 1, 2016 Hello Mark, thank you so much for this! This is exactly what I was looking for! Thanks for chiming in everybody! 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.