OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-05-2012, 13:36
Joe Joe is offline
Member
 
Join Date: Nov 2008
Location: Latvia
Posts: 92
Send a message via Skype™ to Joe
Default CorelDRAW X6 easy object placement Docker (also quick VBA macro)

Hi all!

Haven't been here for a loooong time, but made this super-simple little macro for a task and thought maybe it could come in handy to someone, it's kinda neat.

What it does is it takes a bunch (or just one) of objects and then as you click it places a copy of a random object at a random angle. Here's an example:



So you want to place those sea-things onto the water. Normally arranging them would be quite a chore, here you just select all the objects on top, start the macro, click like crazy, then press ESC to cancel the placement mode and get this:



You can undo any placement or right click to move them mid-placement and, of course, change the positions after you are done placing. But it's a good start. Here's the code, I hope someone finds it useful:

Code:
Sub ObPlacer()
  If ActiveSelection.Shapes.Count = 0 Then
    MsgBox "Please select at least one object.", vbOKOnly

    Exit Sub
    End If

    Dim X As Double, Y As Double
    Dim b As Boolean
    Dim s As Shape
    Dim Pool As ShapeRange
    Dim Count As Single, WhichOne As Single

    Set Pool = ActiveSelectionRange
    Count = Pool.Shapes.Count

    b = False

    While Not b
    
    b = ActiveDocument.GetUserClick(X, Y, 0, 10, False, cdrCursorSmallcrosshair)
        If Not b Then
          WhichOne = Int(Rnd * Count + 1)
          ActiveDocument.BeginCommandGroup ("Placed Object")
          Set s = Pool.Shapes(WhichOne).Duplicate(X - Pool.Shapes(WhichOne).CenterX, Y - Pool.Shapes(WhichOne).CenterY)
          s.Rotate (Rnd * 360)
          ActiveDocument.EndCommandGroup
        End If
    Wend
  End Sub
If/when I finally get my brain to understand shelby's excellent new X6 docker tutorial I might try to make a proper version with settings and such.

Last edited by Joe; 18-05-2012 at 11:12.
Reply With Quote
  #2  
Old 12-05-2012, 13:27
Sablesword Sablesword is offline
Junior Member
 
Join Date: Aug 2006
Posts: 20
Default

Nifty idea. I'll have to see what I can do with this.
Reply With Quote
  #3  
Old 12-05-2012, 14:15
Joe Joe is offline
Member
 
Join Date: Nov 2008
Location: Latvia
Posts: 92
Send a message via Skype™ to Joe
Default Updates

Thanks, Sablesword

So it seemed like some options were missing and thus I have built a small GUI for the thing:



With the new options you can set the range within which the objects are randomly turned and resized, and there's also an option for random flipping, thus enabling more natural placement of certain objects:



The bottom panel lets you do similar things to objects already placed (nudge and rotate them) while the nodes option nudges the nodes of curve objects.

There are no real error messages yet so be careful what objects you use it on - if it crashes with a non-curveable object it'll be stuck in the accelerated mode and won't redraw the screen (for now).

Place the GMS in the usual directory and call ShowOrHideGUI

Enjoy, feedback and suggestions welcome.
Attached Files
File Type: gms Tools.gms (34.5 KB, 392 views)
Reply With Quote
  #4  
Old 13-05-2012, 04:43
Joe Joe is offline
Member
 
Join Date: Nov 2008
Location: Latvia
Posts: 92
Send a message via Skype™ to Joe
Default Xenobiology!

Never mind me, just adding more features as they come to mind:



Orbit placement mode is the new thing in this revision. Best explained by example. So we have a barren little planet like this:



And would like to place some alien vegetation on it:



Using standard tools (or even the standard placement tools in this macro) it would take a while to position all these objects, but using the Orbit mode you just Select the vegetation objects, Push the button, Click in the middle of the planet and then Click around the perimeter. And get this:



Enjoy, feedback and suggestions as always welcome.
Attached Files
File Type: gms Tools.gms (60.0 KB, 441 views)

Last edited by Joe; 13-05-2012 at 04:47.
Reply With Quote
  #5  
Old 14-05-2012, 08:26
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

This is a great idea. I'll play with it a little and send some feedback.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #6  
Old 14-05-2012, 16:37
Joe Joe is offline
Member
 
Join Date: Nov 2008
Location: Latvia
Posts: 92
Send a message via Skype™ to Joe
Default More updates

It's not too easy, but I'm slowly getting the hang of the new WPF docker possibilities in X6 (thanks, Shelby!) so here is a taste of things to come:



Once it's all working properly I'll try to post the docker as well.
Reply With Quote
Reply

Tags
objects, placement, vba


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
Quick and easy way to removes empty lines of text runflacruiser Code Critique 0 23-11-2010 14:37
Table scale and placement. Corel accuracy in question? Morphevs General 2 18-11-2008 08:19
Dialog placement ddonnahoe CorelDRAW/Corel DESIGNER VBA 2 17-06-2005 16:26
An Idea for a handy and easy to make macro vallentin Macros/Add-ons 2 16-03-2004 12:35
newbie question but hopefully easy to answer. cutter CorelDRAW/Corel DESIGNER VBA 0 05-11-2003 12:30


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


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