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-2004, 06:12
d-signer
Guest
 
Posts: n/a
Default Select all nodes if the subpath

Sometimes I need to select all nodes in the some subpath (as it's very easy I make in Illustrator) for transforming. I didnt found any built-in command in CorelDraw to do it. More, I didnt any method to doing that by CorelDraw VBA object model. Neither nodes nor segments nor subpaths have 'selection' property.

Or I'm wrong?
Reply With Quote
  #2  
Old 11-05-2004, 09:59
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default Re: Select all nodes if the subpath

You are right. I don't think there is a way to select nodes from VBA so that user can later work with them. However I think there is a workaround. The trick is that each time to move or do something to nodes, they get selected internally. So you can perform a non-destructive operation on the nodes, for example, move them by zero distance. You'll have your selection:

Code:
ActiveShape.Curve.SubPaths(2).Nodes.All.Move 0, 0
Of course, you need to be in Shape edit tool mode to see the selection. If you have the Pick tool selection, you won't notice anything.

You can force the Shape tool to be selected before you perform your operation:

Code:
ActiveTool = cdrToolNodeEdit
Here is a sample macro for you which allows you to select all nodes of one or more subpaths. First, you select some nodes, then run the macro. It will select all the nodes of the subpaths on which the originally selected nodes reside. For example, if you need to select all nodes of a subpath, just select any node on the subpath and run the macro. You can select two nodes from two different subpaths to have all nodes from those subpaths to be selected...

Code:
Sub SelectSubpaths()
    Dim nr As New NodeRange
    Dim n As Node
    
    If ActiveShape Is Nothing Then
        MsgBox "Nothing selected", vbCritical
        Exit Sub
    End If
    
    If ActiveShape.Type <> cdrCurveShape Then
        MsgBox "Please select a curve", vbCritical
        Exit Sub
    End If
    
    If ActiveShape.Curve.Selection.Count = 0 Then
        MsgBox "Please select one or mode nodes and try again", vbCritical
        Exit Sub
    End If
    
    ' Go through each selected node, determine which subpath it is on,
    ' get all the nodes from the subpath and add them to the range.
    ' If a subpath's nodes are already in the range, nr.AddRange will no nothing
    For Each n In ActiveShape.Curve.Selection
        nr.AddRange n.SubPath.Nodes.All
    Next n
    
    ' Now create selection of all selected subpaths
    nr.Move 0, 0
End Sub
As you can see the actual code is quite simple. There are a few sanity checks at the beginning, but there is nothing fancy about that either...

I hope this helps.
Reply With Quote
  #3  
Old 12-05-2004, 23:47
d-signer
Guest
 
Posts: n/a
Default

It's work! Thanks a lot Alex.

I forgot about just what I want - Selection function of Curve object!
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
problems with nodes jmalmsteen CorelDRAW/Corel DESIGNER VBA 1 14-06-2005 12:23
It is a bug? (Reflecting Nodes) Hernán General 0 26-10-2004 01:13
Howcan get a node's offset of the subpah to which nod belong lees CorelDRAW/Corel DESIGNER VBA 2 17-10-2004 21:39
Reducing Nodes Semi Automatic Superfreak New product ideas 2 05-10-2004 02:10
vba question bumblebee CorelDRAW/Corel DESIGNER VBA 4 04-08-2004 15:07


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


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