OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Corel User Forums > CorelDRAW > Feature requests/wishlist

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-05-2010, 17:36
gorgo2 gorgo2 is offline
Senior Member
 
Join Date: Feb 2010
Posts: 107
Default Equally spacing objects based on a target

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
Attached Images
 
Reply With Quote
  #2  
Old 12-05-2010, 17:49
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default 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
Reply With Quote
  #3  
Old 12-05-2010, 18:30
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Smile

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
Reply With Quote
  #4  
Old 12-05-2010, 20:22
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

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
Reply With Quote
  #5  
Old 12-05-2010, 21:24
gorgo gorgo is offline
Senior Member
 
Join Date: Feb 2010
Posts: 169
Thumbs up

Quote:
Originally Posted by runflacruiser View Post
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)
Reply With Quote
  #6  
Old 12-05-2010, 21:34
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

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
Reply With Quote
  #7  
Old 12-05-2010, 23:01
gorgo gorgo is offline
Senior Member
 
Join Date: Feb 2010
Posts: 169
Default

Quote:
Originally Posted by runflacruiser View Post
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
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable form controls based on file system inaph CorelDRAW/Corel DESIGNER VBA 3 03-02-2009 16:35
Resizing graphic based on merge record RonHill General 0 16-04-2007 13:39
1 document - pages based on different templates? Leeoniya General 1 12-06-2006 20:24
Target Desktop ddonnahoe CorelDRAW/Corel DESIGNER VBA 1 15-11-2005 08:38
Is there a need for a vector based drop-shadow macro? johndankey New product ideas 4 08-02-2005 17:41


All times are GMT -5. The time now is 05:08.


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