Page 1 of 1
Get Object Location
Posted: Sun Mar 14, 2021 8:09 pm
by aronb
Hi,
I need to find the location of an object inside a view, that I place somewhere in that view.
The example here, shows the text (label) location in the view, but how do I get that location point out of the view?
Also... can I get back any objects location?
The end goal for now, is to be able to use the "area AND the location" of the text, to create a clipping area to allow the text to be over another object in the view, and clip / exclude that object, to allow the text to make that area clear (in this example).
I can of course get the width and height, but how do get an objects location in the final view???
Thanks for any help,
Aron
Re: Get Object Location
Posted: Mon Mar 15, 2021 1:17 am
by aronb
P.S.
You can see that information during and while positioning objects... the trick is how do I get at it?
In this example "Label wOptions v1 (5,5) sqr" is shown, and is the upper left corner of the insert point.

- Position
- Text_Position.png (18.06 KiB) Viewed 15377 times
Thanks Again!
Aron
Re: Get Object Location
Posted: Mon Mar 15, 2021 8:16 am
by adamszabo
If you read the user manual, in the text section it says, you can get the area a text is occupying with Ruby, and you can use that to clip your line behind the text. Read the part about "v.measureString" you need to use that
Re: Get Object Location
Posted: Tue Mar 16, 2021 6:05 pm
by aronb
Yes of course,
You can even create (in Ruby) a rectangle to put the text in - I.E. "v.drawString @label,font,sf,rect,(Brush.new @color)", but again you can't seem to get at the LOCATION of that text in the MGUI...?
Again the idea here, is getting to the position data of the object of each item in the MGUI during the unlock, edit placement time. Yes you can get an items size, but seemingly not its location
Of course we / I could just create all of it in Ruby (text and rounded rectangle), but a better way would be able to get the object location coordinates (size is easy), and then be able to use that data for calculating the front panel or GUI.
Programming the whole thing again is great, but just pulling in something from the toolbox as needed makes more sense to me... that way, its not a custom module, it is a generic module made of prims or other modules.
Hope that makes sense

Thanks for the input!!!
Aron
Re: Get Object Location
Posted: Tue Mar 16, 2021 8:06 pm
by tulamide
While you don't get it served on a golden plate (which would be great), it should be possible. You just need to think in reverse, from bottom to top.
The prim "View Area" outputs the area of the current view. The prim "Area to Float" gives you access to its components as float values, namely x, y, width and height. Whenever this view is placed in another view (and the chain of view inputs on the MGUIs is intact), x and y will be local to that other view.
For Ruby, the same thing is available. It is a method called "getViewPos" and contains [x, y] and "getViewSize", which contains [width, height]. I'm not sure though if getViewPos was already implemented in 3.0.6, so you might want to try it with the newest alpha?