OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Oberon Products > New product ideas

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 18-01-2004, 23:43
Hernán
Guest
 
Posts: n/a
Default New Idea !!!

Hi Alex,
I got a new idea for a tool that could save a lot of time.

For those who draw complex technical drawings (like me)
and need to use a lot of guidelines
and need to erase multiple guidelines at the same time,

why no to enhance the Pick Tool
to be able to select ONLY guidelines
(by dragging like as when we select objects)?

Because DRAW have only the possibility to select/delete guidelines
individually, or ALL at the same time.

Thanks
Reply With Quote
  #2  
Old 19-01-2004, 10:31
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: New Idea !!!

Hey, neat idea!

Even though it is not possible to modify the pick tool behavior from VBA, it is still possible to implement something similar.

I just played with it a bit and here is the resulting macro. I varified its operation under CorelDRAW 10, 11, and 12 and it seems to work fine. It allows you to define a rectangular selection area and then it selects all the guidelines that intersect that rectangle. If you hold down the Shift key, it selects/deselects the guidelies, effectively adds/removes them to/from selection.

When you are done with selecting the guidelines, just hit Escape to exit the guideline selection mode and return back to CorelDRAW.

Below is the source code of the macro and attached is the macro packaged as a GMS module. Give it a try and let me know what you think. If everything goes well, I will publish it on this web site in VBA macro section for everybody to download and use...

Code:
'=============================================================
' Select Guides for CorelDRAW 10-12
'
' Selects all the guidelines within a marquee selection
' Shift-select to add/remove individual guidelines to/from
' existing selection
' Hit ESC when done
'
' Copyright (c) 2004 by Alex Vakulenko
' http://www.oberonplace.com
'=============================================================
Option Explicit

Sub SelectGuides()
    Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double
    Dim v As Double
    Dim x As Long, y As Long
    Dim Shift As Long
    Dim srSelection As ShapeRange
    Dim nCursor As Long
    
    If ActiveDocument Is Nothing Then
        MsgBox "No document open", vbCritical
    End If
    
    If VersionMajor < 11 Then
        nCursor = 93
    Else
        nCursor = 530
    End If
    
    Set srSelection = ActiveSelectionRange
    While ActiveDocument.GetUserArea(x1, y1, x2, y2, Shift, 1000, False, nCursor) = 0
        ' If anything but a guideline is selected, clear selection first
        ' because CorelDRAW shouldn't allow selecting guidelines along
        ' with other object types
        If Not ActiveShape Is Nothing Then
            If ActiveShape.Type <> cdrGuidelineShape Then
                ActiveDocument.ClearSelection
            End If
        End If
        
        ' If the Shift key is not pressed, clear the selection
        If (Shift And 1) = 0 And Not ActiveShape Is Nothing Then
            ActiveDocument.ClearSelection
        End If
        
        If x1 > x2 Then
            v = x1
            x1 = x2
            x2 = v
        End If
        
        If y1 > y2 Then
            v = y1
            y1 = y2
            y2 = v
        End If
        
        ' Get the guidelines on the current page
        ProcessGuides ActivePage.Guides(cdrAllGuides), x1, y1, x2, y2
        ' Get the guidelines on the master page
        ProcessGuides ActiveDocument.Pages(0).Guides(cdrAllGuides), x1, y1, x2, y2
        Set srSelection = ActiveSelectionRange
    Wend
    
    ' Restore the last saved selection
    srSelection.CreateSelection
End Sub

Private Sub ProcessGuides(ByVal srGuildes As ShapeRange, ByVal x1 As Double, ByVal y1 As Double, ByVal x2 As Double, ByVal y2 As Double)
    Dim s As Shape
    Dim x As Double, y As Double, w As Double, h As Double
    Dim bInsideSelection As Boolean
    Dim c As Double
    
    For Each s In srGuildes
        If Not s.Guide.Preset Then
            ' Check if the current guideling is inside the marquee
            s.GetBoundingBox x, y, w, h
            Select Case s.Guide.Type
                Case cdrSlantedGuide
                    If s.IsOnShape(x, y) = cdrOutsideShape Then
                        y = y + h
                        h = -h
                    End If
                    c = x * h - y * w
                    x = (w * y1 + c) / h
                    bInsideSelection = (x >= x1 And x <= x2)
                    If Not bInsideSelection Then
                        x = (w * y2 + c) / h
                        bInsideSelection = (x >= x1 And x <= x2)
                    End If
                    If Not bInsideSelection Then
                        y = (h * x1 - c) / w
                        bInsideSelection = (y >= y1 And y <= y2)
                    End If
                    If Not bInsideSelection Then
                        y = (h * x2 - c) / w
                        bInsideSelection = (y >= y1 And y <= y2)
                    End If
                Case cdrVerticalGuide
                    bInsideSelection = (x >= x1 And x <= x2)
                Case cdrHorizontalGuide
                    bInsideSelection = (y >= y1 And y <= y2)
            End Select
            If bInsideSelection Then
                s.Selected = Not s.Selected
            End If
        End If
    Next s
End Sub
Attached Files
File Type: gms GuideSelect.gms (18.0 KB, 663 views)
Reply With Quote
  #3  
Old 19-01-2004, 14:28
Lev
Guest
 
Posts: n/a
Default Re: New Idea !!!

Quote:
Originally Posted by Alex
Give it a try and let me know what you think. If everything goes well, I will publish it on this web site in VBA macro section for everybody to download and use...
I think it will be good to name and store guide sets (they can already be stored with the Selection Manager macro) and to have option to select-deselect and to delete-recreate sets, since I dont know the way to have several Guides layers. I think it can be easily coded an would increase the usefullness of a macro.
Reply With Quote
  #4  
Old 19-01-2004, 14:53
Hernán
Guest
 
Posts: n/a
Default

FANTASTIC !!! You’re a genius Alex! It works absolutely fine !!!

Thanks a lot Alex !!!

Why you don’t put this macro on the VBA macros’s homepage?
Reply With Quote
  #5  
Old 19-01-2004, 15:04
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Quote:
Originally Posted by Guru_Boy_CDR
Why you don’t put this macro on the VBA macros’s homepage?
Read my previous post more carefully

Quote:
Give it a try and let me know what you think. If everything goes well, I will publish it on this web site in VBA macro section for everybody to download and use...
Reply With Quote
  #6  
Old 20-01-2004, 00:27
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Just posted the macro here: http://www.oberonplace.com/vba/drawm...lect/index.htm
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
Panic !!!!!! Paragraph text, frame height Bellekom CorelDRAW/Corel DESIGNER VBA 4 11-05-2004 06:03
An Idea for a handy and easy to make macro vallentin Macros/Add-ons 2 16-03-2004 11:35
Another Good Idea Hernán New product ideas 3 28-01-2004 10:46
Idea? johndankey Web site suggestions 2 21-01-2003 15:06


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


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