OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   Feature requests/wishlist (http://forum.oberonplace.com/forumdisplay.php?f=33)
-   -   Equally spacing objects based on a target (http://forum.oberonplace.com/showthread.php?t=6970)

gorgo2 12-05-2010 18:36

Equally spacing objects based on a target
 
1 Attachment(s)
Hi all. Is there a way to equally space objects based on a target object like several small rectangles placed in a big rectangle (container)?

Thanks in advance!

-Greg

shelbym 12-05-2010 18:49

Distrubute
 
I would normally draw a rectangle at the top and bottom of your box then use Align and Distribute to distribute the space equally, then center everything to your box. Sure it is a couple steps, but it goes very quick when you get the hang of it.

-Shelby

runflacruiser 12-05-2010 19:30

Hi.
This will be useful for me too. I have had this in my mind for sometime as an addon for one of my macros.

Code:

Option Explicit

Sub fitEmIn()

Dim s As Shape
Dim sr As ShapeRange
Dim i As Integer
Dim x#, y#, w#, h#
Dim x1#, y1#, w1#, h1#
Dim addup As Double
Dim space As Double
Dim itemsCount As Long
Dim boxLen As Double
Dim shapesLen As Double
Dim entry As Variant

entry = InputBox("Enter box width", "Fit em in!", 35)
If entry = "" Then Exit Sub
boxLen = entry

Set sr = ActiveSelectionRange
sr(1).GetBoundingBox x, y, w, h

For Each s In sr
    shapesLen = shapesLen + s.SizeWidth
Next s

space = (boxLen - shapesLen) / sr.Count
space = space + (space / sr.Count)

ActiveDocument.ReferencePoint = cdrBottomRight

addup = w
For i = 1 To sr.Count
    If i > 1 Then
        sr(i).GetBoundingBox x1, y1, w1, h1
        sr(i).SetPosition x + w1 + addup, y
        addup = addup + w1 + space
    Else
        sr(i).Move -space, 0
    End If
   
Next i

End Sub


-John

runflacruiser 12-05-2010 21:22

oh.
Here's some spacing options too.

Code:

'space = space + (space / sr.Count) 'end to end, comment this for half space on each side
space = space - (space / sr.Count) 'full space on each side

-John

gorgo 12-05-2010 22:24

Quote:

Originally Posted by runflacruiser (Post 16479)
Hi.
This will be useful for me too. I have had this in my mind for sometime as an addon for one of my macros.

Code:

Option Explicit

Sub fitEmIn()

Dim s As Shape
Dim sr As ShapeRange
Dim i As Integer
Dim x#, y#, w#, h#
Dim x1#, y1#, w1#, h1#
Dim addup As Double
Dim space As Double
Dim itemsCount As Long
Dim boxLen As Double
Dim shapesLen As Double
Dim entry As Variant

entry = InputBox("Enter box width", "Fit em in!", 35)
If entry = "" Then Exit Sub
boxLen = entry

Set sr = ActiveSelectionRange
sr(1).GetBoundingBox x, y, w, h

For Each s In sr
    shapesLen = shapesLen + s.SizeWidth
Next s

space = (boxLen - shapesLen) / sr.Count
space = space + (space / sr.Count)

ActiveDocument.ReferencePoint = cdrBottomRight

addup = w
For i = 1 To sr.Count
    If i > 1 Then
        sr(i).GetBoundingBox x1, y1, w1, h1
        sr(i).SetPosition x + w1 + addup, y
        addup = addup + w1 + space
    Else
        sr(i).Move -space, 0
    End If
   
Next i

End Sub


-John

I feel silly again because I should have known how to properly use the align and dist tool which has been a feature in Draw for ages.:(
I was wrestling with it and just didn't use it correctly and so that's why I posted my question.
Now, Mr. John has some code to try and I did but I don't get how to apply this macro to my situation. I drew four rectangles and one large squarish rectangle which will be the container for these rectangles and ran your code and come up with weird results. There is a text box to enter a value but I'm not sure on the units it is using or even if it respects the current worldscale my document is set to. So, check this out when you can John and thanks again y'all.

-Greg (may just use the normal tool that Draw offers....until then)

runflacruiser 12-05-2010 22:34

Hi Greg.

It's usually never right on for what you need. You should be able to customize this for your needs.
If it's something you'll be doing alot then it would be worth it. If your only going to use is once and a while then draw's built in method should be fine.

Currently this spaced shapes apart horizontally within the distance you enter. So if your box is 35 inches then enter 35. All selected shapes will be spaced evenly to fit in the 35 inches.

You can substitute the commented lines and uncomment as needed for slight tweaks. By default it puts shapes end to end. If you use the other one you can get a half space or full space spacing on ends, before spacing in desired area. This is actually a mod of the spacing script I made on in a much earlier post.

You could even set the macro to automatically group the shapes, or prompt for a click for the container shape at the end. Skies the limit..!

Hope this helps.
-John

gorgo 13-05-2010 00:01

Quote:

Originally Posted by runflacruiser (Post 16483)
Hi Greg.

It's usually never right on for what you need. You should be able to customize this for your needs.
If it's something you'll be doing alot then it would be worth it. If your only going to use is once and a while then draw's built in method should be fine.

Currently this spaced shapes apart horizontally within the distance you enter. So if your box is 35 inches then enter 35. All selected shapes will be spaced evenly to fit in the 35 inches.

You can substitute the commented lines and uncomment as needed for slight tweaks. By default it puts shapes end to end. If you use the other one you can get a half space or full space spacing on ends, before spacing in desired area. This is actually a mod of the spacing script I made on in a much earlier post.

You could even set the macro to automatically group the shapes, or prompt for a click for the container shape at the end. Skies the limit..!

Hope this helps.
-John

I left value at 35 but it spaced my shapes at 28.385. Did I miss something?

-Greg


All times are GMT -5. The time now is 15:17.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com