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 29-05-2009, 10:31
cmjmmrp
Guest
 
Posts: n/a
Default Align a objet with guides

hi, Is it possible to align an object with a line guide via code?
i work with a barco Graphics Packedge an this program do it, in corel is possible make it?
Reply With Quote
  #2  
Old 08-06-2009, 07:38
cmjmmrp
Guest
 
Posts: n/a
Default

Hi, Someone can orientate me for this?
Reply With Quote
  #3  
Old 09-06-2009, 00:56
iceage3
Guest
 
Posts: n/a
Default

Is it faster to align a shape to the guideline manually?

You can find the Guideline settings in menu Tool->Options->GuideLine. Then you know what to do. XD
Reply With Quote
  #4  
Old 09-06-2009, 01:17
cmjmmrp
Guest
 
Posts: n/a
Default

hi, i work with a barco Graphics Packedge an this program do it , in corel sometimes obtain align errors if i do manualy, so i think if is possible make it by code the error is null.
Reply With Quote
  #5  
Old 09-06-2009, 01:37
iceage3
Guest
 
Posts: n/a
Default

I cant understand why there is a "align error", I have never seen it. So it will be better if you post an example up here.

I cant put a code here now cos I really dont know what you want to get. Because there're many align methods like left aling, right align, top align, etc...Or you just want to stack the shape on the guideline and make their center align to it?
Reply With Quote
  #6  
Old 09-06-2009, 01:52
cmjmmrp
Guest
 
Posts: n/a
Default

hi, I refer to mistakes when fit the object with the line guide manualy ( i move the object with my mouse "pulse"). i explain:
in the barco graphics Packedge there is two align ways :
the object with two special lines guides and viceversa the two special lines guides with a selected object.
is a way to work so quickly with objects.
do you understand me?
Reply With Quote
  #7  
Old 09-06-2009, 03:00
iceage3
Guest
 
Posts: n/a
Default

OK, I got it. But what's the relationship between guide lines and objects? What's the functionality of the guideline when you are drawing something? XXD. It seems that the Packedge you're using is not CorelDRAW VBA application or a add-in , right?
I didnt use this soft and so ..... if there is a info for this soft?
Reply With Quote
  #8  
Old 09-06-2009, 03:07
cmjmmrp
Guest
 
Posts: n/a
Default

Hi again, i used coreldraw and Esko Packedge, with coreldraw "draw" the design and with Esko Packedge i compound and editing this desing. take a eye at http://esko.com/web/site.aspx?p=199
Reply With Quote
  #9  
Old 09-06-2009, 12:32
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 10
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 Align to Guides

I am still not sure if this is what you want. But here is my attempt. Select your shapes first, then run one of the Macros. The cursor will change and select your guideline. All shapes that were selected will then be aligned to the guideline.

This code will only work in X4 as I haves used CQL calls.

Code:
Sub AlignToGuideLeft()
    If SelectionCheck Then
        boostStart "Align to Guide"
            AlignToGuide "Left"
        boostFinish True, True
    End If
End Sub

Sub AlignToGuideRight()
    If SelectionCheck Then
        boostStart "Align to Guide"
            AlignToGuide "Right"
        boostFinish True, True
    End If
End Sub

Sub AlignToGuideTop()
    If SelectionCheck Then
        boostStart "Align to Guide"
            AlignToGuide "Top"
        boostFinish True, True
    End If
End Sub

Sub AlignToGuideBottom()
    If SelectionCheck Then
        boostStart "Align to Guide"
            AlignToGuide "Bottom"
        boostFinish True, True
    End If
End Sub

Private Function SelectionCheck() As Boolean
    Dim srSelection As ShapeRange
    
    If ActiveDocument Is Nothing Then
        MsgBox "No document open", vbCritical
        SelectionCheck = False
        Exit Function
    End If
    
    Set srSelection = ActiveSelectionRange
    
    If srSelection.Count = 0 Then
        MsgBox "No shape(s) selected", vbCritical
        SelectionCheck = False
        Exit Function
    End If
    
    SelectionCheck = True
End Function

Private Sub AlignToGuide(strAlign As String)
    Dim x As Double, y As Double
    Dim Shift As Long, s As Shape
    Dim srSelection As ShapeRange
    Dim b As Boolean, sGuide As Shape
    
    b = False
    
    Set srSelection = ActiveSelectionRange
    While Not b
        b = ActiveDocument.GetUserClick(x, y, Shift, 1000, False, 530)
        Set sGuide = FindGuide(ActivePage.Shapes.FindShapes(query:="@type='guideline'"), x, y, strAlign)
        If Not sGuide Is Nothing Then
            For Each s In srSelection
                Select Case strAlign
                    Case "Left"
                        s.PositionX = sGuide.PositionX
                    Case "Right"
                        s.PositionX = sGuide.PositionX - s.SizeWidth
                    Case "Top"
                        s.PositionY = sGuide.PositionY
                    Case "Bottom"
                        s.PositionY = sGuide.PositionY + s.SizeHeight
                End Select
            Next s
        b = True
        End If
    Wend
    sGuide.Selected = False
    srSelection.CreateSelection
End Sub

Private Function FindGuide(AllGuides As ShapeRange, x1 As Double, y1 As Double, strAlign As String) As Shape
    Dim s As Shape
    Dim x As Double, y As Double
    
    For Each s In AllGuides
        s.GetPosition x, y
        Select Case s.Guide.Type
            Case cdrVerticalGuide
                If (x < x1 + 0.1 And x > x1 - 0.1) Then
                    If (strAlign = "Left") Or (strAlign = "Right") Then
                        If s.Guide.Type = cdrVerticalGuide Then
                            s.Selected = True
                            Set FindGuide = s
                            Exit Function
                        End If
                    End If
                End If
            Case cdrHorizontalGuide
                If (y < y1 + 0.1 And y > y1 - 0.1) Then
                    If (strAlign = "Top") Or (strAlign = "Bottom") Then
                        If s.Guide.Type = cdrHorizontalGuide Then
                            s.Selected = True
                            Set FindGuide = s
                            Exit Function
                        End If
                    End If
                End If
            End Select
    Next s
End Function

Private Sub boostStart(Optional unDo$)
   On Error Resume Next
   If Len(unDo) Then ActiveDocument.BeginCommandGroup unDo
   Optimization = True
   EventsEnabled = False
   ActiveDocument.SaveSettings
   ActiveDocument.PreserveSelection = False
End Sub

Private Sub boostFinish(Optional ByVal endUndoGroup As Boolean = False, Optional ByVal doRedraw As Boolean = True)
   On Error Resume Next
   ActiveDocument.PreserveSelection = True
   ActiveDocument.RestoreSettings
   EventsEnabled = True
   Optimization = False
   If endUndoGroup Then ActiveDocument.EndCommandGroup
   
   If doRedraw Then
      CorelScript.RedrawScreen
      ActiveWindow.Refresh
      Application.Refresh
   End If
End Sub
Best of luck,

-Shelby
Reply With Quote
  #10  
Old 10-06-2009, 00:21
cmjmmrp
Guest
 
Posts: n/a
Default

hi to all!
I tried your code and ¡¡¡yes¡¡¡ run good and make that i want: alling to lines guide so good
very very thanks from Spain. i post that packedge make with the two special line guides and object in the next corel file:
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
better align object cmjmmrp CorelDRAW/Corel DESIGNER VBA 5 29-05-2009 02:18
Align to Specific Layer ProofingGuy CorelDRAW/Corel DESIGNER VBA 6 11-06-2008 17:11
Align stroke on a path jod General 3 10-05-2007 21:07
Multiple Groups & Align Under kuty CorelDRAW/Corel DESIGNER VBA 2 17-08-2004 13:21
CorelDraw 12's Align Mark CorelDRAW/Corel DESIGNER VBA 8 16-07-2004 17:24


All times are GMT -5. The time now is 03:57.


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