![]() |
#1
|
|||
|
|||
![]()
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 |
#2
|
||||
|
||||
![]()
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 |
#3
|
||||
|
||||
![]()
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 |
#4
|
||||
|
||||
![]()
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 |
#5
|
|||
|
|||
![]() Quote:
![]() 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) |
#6
|
||||
|
||||
![]()
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 |
#7
|
|||
|
|||
![]() Quote:
-Greg |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Variable form controls based on file system | inaph | CorelDRAW/Corel DESIGNER VBA | 3 | 03-02-2009 17:35 |
Resizing graphic based on merge record | RonHill | General | 0 | 16-04-2007 14:39 |
1 document - pages based on different templates? | Leeoniya | General | 1 | 12-06-2006 21:24 |
Target Desktop | ddonnahoe | CorelDRAW/Corel DESIGNER VBA | 1 | 15-11-2005 09:38 |
Is there a need for a vector based drop-shadow macro? | johndankey | New product ideas | 4 | 08-02-2005 18:41 |