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 04-10-2014, 09:25
nic nic is offline
Member
 
Join Date: May 2009
Posts: 90
Default Working with parts of a curve that has been broken

Hi
the code below adds nodes to a curve and then breaks the curve apart but I dont know how to then work with the new curves (Im intending to recolour them each in a separate colour).

How do you refer to the new objects created when you break a curve apart?
nic

Code:
Dim s as shape, sr as ShapeRange, sp as SubPath, nr as NodeRange 
Set sr = ActivePage.Shapes.FindShapes()

'loop thru shapes
For Each s In sr

   s.Curve.SubPaths.First.AddNodeAt 0.333, cdrRelativeSegmentOffset
   s.Curve.SubPaths.First.AddNodeAt 0.666, cdrRelativeSegmentOffset

    'break nodes and curve
    Set nr = s.Curve.Nodes.All
    nr.BreakApart
    nr.RemoveAll
    s.BreakApart
     
    'bogus code
    's.PART1.Outline.Color.RGBAssign 255, 0, 0
    's.PART2.Outline.Color.RGBAssign 0, 255, 0
    's.PART3.Outline.Color.RGBAssign 0, 0, 255
    
Next s

Last edited by nic; 04-10-2014 at 10:40.
Reply With Quote
  #2  
Old 05-10-2014, 17:46
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,770
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 BreakApartEx

The easiest way to do this is the use BreakApartEx it will return a ShapeRange with all the newly created shapes.

Here is your code modified a bit, it will randomly change the outline color:
Code:
    Dim s As Shape, sr As ShapeRange, sp As SubPath, nr As NodeRange
    Set sr = ActivePage.Shapes.FindShapes()
    Dim srBrokenCurves As New ShapeRange
    Dim n As Long, num As Long
    
    'loop thru shapes
    For Each s In sr
    
       s.Curve.SubPaths.First.AddNodeAt 0.333, cdrRelativeSegmentOffset
       s.Curve.SubPaths.First.AddNodeAt 0.666, cdrRelativeSegmentOffset
    
        'break nodes and curve
        Set nr = s.Curve.Nodes.All
        nr.BreakApart
        nr.RemoveAll
        srBrokenCurves.AddRange s.BreakApartEx
    Next s
    
    num = ActivePalette.ColorCount
    
    For Each s In srBrokenCurves
        n = CLng(Fix(Rnd() * num)) + 1
        s.Outline.Color = ActivePalette.Color(n)
    Next s
Hope that helps,

-Shelby
Reply With Quote
  #3  
Old 06-10-2014, 08:24
nic nic is offline
Member
 
Join Date: May 2009
Posts: 90
Default Thanks

Hi Shelby
thank you, that does exactly what I was after - BreakApartEx - a new tool to add to my toolbox.

Many thanks
nic
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
Custom Docker to generate parts of 3D box for laser/CNC cut Plixo CorelDRAW/Corel DESIGNER VBA 3 19-12-2013 21:07
Splict funtction parts retrieval ddonnahoe CorelDRAW/Corel DESIGNER VBA 2 06-04-2012 07:30
dimensions broken apart HeauxmBru General 3 29-04-2011 10:14
X4:s1.PlaceTextInside itm1 broken ddonnahoe CorelDRAW/Corel DESIGNER VBA 3 29-01-2008 07:31
ActiveView.OriginX is broken???? jemmyell CorelDRAW/Corel DESIGNER VBA 2 24-01-2005 19:09


All times are GMT -5. The time now is 09:35.


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