Group2D width and height

There is a way to get the width and height of an Group2D?

I have a Group2D where I add different Object2D and I need to draw the Gropu2D into a canvas scaling the Gropu2D to fill the canvas.

I think to het width and height of the canvas and width and height of the Group2D and draw at proper scale but Group2D don’t have width and height property so how I can determine the dimension of the Group2D?

Visto che sei sul forum italiano, ti rispondo in italiano.
una situazione in cui non mi sono mai trovato, forse potresti provare ad usare count e item, ciclarli tutti, vedere x e width per trovare il punto X pi lontano, stesso discroso per y e heigh, purtroppo Object2D non ha width e height e dovresti fare i vari cast

cosi ad occhio…

dim max_w,cur_w as integer
dim max_h,cur_h as integer

max_w = 0
max_h = 0

for i as integer = 0 to my_Group2D.count
dim cur as Object2D
cur = my_Group2D.item(0)
if cur IsA ArcShape Then
dim obj as ArcShape = ArcShape(cur)
ElseIf cur IsA CurveShape Then
dim obj as CurveShape = CurveShape(cur)

End If
cur_w = obj.X + obj.width
cur_h = obj.Y + obj.heigth

if max_w < cur_w then
    max_w = cur_w
end if

if max_h < cur_h then
    max_h = cur_h
end if

next

Alla fine in max_h e max_w dovresti avere il size
Non so se una buona strada da seguire ma altre idee non mi vengono

Si ho pensato anch’io di fare cos solo che se l’oggetto ruotato le coordinate X Y sono quelle del centro ma width e height sono dell’oggetto non ruotato.
Strano che non ci sia implementata questa funzionalit.

Mi serve perch vorrei fare un disegno in un Group2D e quindi poterlo disegnare occupando tutta l’area di un canvas facendolo stare tutto all’interno calcolando la scala che devo utilizzare rapportando le dimensioni massime del Group2D con le dimensioni del Canvas.

Purtroppo non c’. Te le devi calcolare oggetto per oggetto, se sono rettangolari, quadrati, etc sapendo la rotazione con un po’ trigonometria te la dovresti cavare quelli problematici sono i CurveShape dove dovrai calcolare la distanza tra i due punti pi distanti e quindi riapplicare la trigonometria se sono ruotati e il FigureShape che dovrai analizzarlo item per item…
Da quanto ho cercato su google ne parlavano gi nel 2005…
http://www.monkeybreadsoftware.eu/listarchive-realbasic-nug/2005-02-09-26.shtml

Si Michelangelo, lo ho trovato anche io…
Io avevo risolto con delle classi ‘Group2D’ che preparo prima di applicare all’oggetto graphics.
In pratica ho creato un array di classi di tipo Object2D
poi le parso e ne calcolo gli ingombri