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-10-2007, 17:55
m31uk3
Guest
 
Posts: n/a
Default Corel Draw 12 Roland CX-300

Hello

I have a script that formats my graphics on the page for cutting on my Roland cutter. It works great most of the time with the occasional CorelDraw crash. I am guessing I am not managing memory correctly or something similar because other wise Corel would not be crashing.

More troubling is the fact that sometimes when I submit the job to the cutter it gets corrupted by Corel and the cutter goes crazy. The number of jobs this happens to seems to increase after Corel crashes and the longer it runs.

Please any help would be greatly appreciated.

Code:
Sub CutnClean()
    'Unlock and Ungroup all objects
    ActivePage.Shapes.All.Unlock
    ActivePage.Shapes.All.UngroupAll
    'Repeat for sub-nested objects
    ActivePage.Shapes.All.Unlock
    ActivePage.Shapes.All.UngroupAll
    'Find Null Shapes and Delete
    Dim shC As Color, sCount As Long
    sCount = ActivePage.Shapes.count
    If sCount <= 2 Then
        Set shC = CreateCMYKColor(0, 0, 0, 100)
    ElseIf ActivePage.Shapes.Item(2).Fill.Type <> cdrNoFill Then
        Set shC = ActivePage.Shapes.Item(2).Fill.UniformColor
    End If
    'Convert text to curves
    ActivePage.Shapes.All.ConvertToCurves
    'Group to prevent overlap
    ActivePage.Shapes.All.Group
    'Mirror for cutting
    ActivePage.Shapes.All.Flip cdrFlipHorizontal
    'Copy fill color to outline, set width to hairline, remove fill
    ActivePage.Shapes.All.SetOutlineProperties width:=0.003, Color:=shC
    ActivePage.Shapes.All.ApplyNoFill
    'Clear group and selection
    ActivePage.Shapes.All.UngroupAll
    ActiveDocument.ClearSelection
End Sub
Thanks,

-Lucas

Last edited by m31uk3; 12-10-2007 at 06:51.
Reply With Quote
  #2  
Old 12-10-2007, 01:00
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

1. try to use ActivePage.UnlockAllShapes method
2. try to bracket the action sequence in Undo grouping commands, see code
3. convert only text shapes to curves
4. [the most probable cause] there may be times when your if/elseif does not catch and shC color is nothing, that's very bad, see code
Code:
Sub CutnClean()
    on error resume next
    ActiveDocument.BeginCommandGroup "CutnClean"
    ActivePage.UnlockAllShapes
    ActivePage.Shapes.All.UngroupAll
    
    Dim shC As Color, sCount As Long
    sCount = ActivePage.Shapes.count
    Set shC = CreateCMYKColor(0, 0, 0, 100)
    If sCount > 2 Then _
        If ActivePage.Shapes(2).Fill.Type <> cdrNoFill Then _
            Set shC = ActivePage.Shapes(2).Fill.UniformColor

    'Convert text to curves
    with ActivePage.FindShapes(,cdrTextShape)
        if .Count then .ConvertToCurves
    end with
    'Group to prevent overlap
    with ActivePage.Shapes.All.Group
        'Mirror for cutting
        .Flip cdrFlipHorizontal
        'Copy fill color to outline, set width to hairline, remove fill
        .Outline.SetProperties width:=0.003, Color:=shC
        .Fill.ApplyNoFill
        'Clear group and selection
        .UngroupAll
    end with
    ActiveDocument.EndCommandGroup
    ActiveDocument.ClearSelection
End Sub
Reply With Quote
  #3  
Old 12-10-2007, 01:19
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 Convert To Curves

Quote:
Originally Posted by wOxxOm View Post
3. convert only text shapes to curves
Depending how he is sending the file to his cutter, it is wise to convert everything to curves. Some cutters don't like predefines objects like rectangles, circles, polygons etc...

So do everything not just the text.

-Shelby
Reply With Quote
  #4  
Old 12-10-2007, 06:17
m31uk3
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by wOxxOm View Post
1. try to use ActivePage.UnlockAllShapes method
2. try to bracket the action sequence in Undo grouping commands, see code
3. convert only text shapes to curves
4. [the most probable cause] there may be times when your if/elseif does not catch and shC color is nothing, that's very bad, see code
Hey wOxxOm,

Thanks for your reply!

I have tried ActivePage.UnlockAllShapes and it did not work on specific svg files which contained locked data. It would delete about 60% but not all. When I switched to ActivePage.Shapes.All.Unlock it started working. This however is the least import part of the script it can be put into another macro if needed.

The following is the most important:
  • Convert All Objects To Curves
  • Flip All Objects Horizontally
  • Set Outline To Hairline

The following would be nice:
  • Do not ungroup if there are no further subgroups (if this would slow it down to much it would not be worth it)
  • Take outline color from fill color

I would be happy just to get a reliable result from Corel as I typically cut 200 18x20 pages a day and it would be nice to just be able to queue the jobs and not have to constantly watch for jagged prints indicating a corrupted print job.

I like your tips with command grouping I will implement that once I get it working.

If the shC color was nothing I would be able to see this as the outline would not be visible. This has not happened yet so I don't think its that. I process from CMX files so they are already clean. The problem was I tried to have one super macro as there are times we must work directly from SVG. But as I stated before it makes more sense to have this in a separate macro.

Thanks shelbym,

Sorry for the double post just very frustrated and wanted some help fast

I will try your suggestion with reducing the calls to ActivePage and setting it to UngroupAllEx. However could you please explain what UngroupAllEx does exactly?

I searched the manual PDF but could not find it.

Thanks,

-Lucas

Last edited by m31uk3; 12-10-2007 at 06:57.
Reply With Quote
  #5  
Old 12-10-2007, 06:51
m31uk3
Guest
 
Posts: n/a
Default No Go

Here is the revised code:

Code:
Sub CutnCleanNew()
    Dim cColor As Color
    Dim sRange As ShapeRange
    
    Set sRange = ActivePage.Shapes.All.UngroupAllEx
    Set cColor = CreateCMYKColor(0, 0, 0, 100)
    
    'Convert text to curves
    sRange.ConvertToCurves
    'Mirror for cutting
    sRange.Flip cdrFlipHorizontal
    'Copy fill color to outline, set width to hairline, remove fill
    sRange.SetOutlineProperties width:=0.003, Color:=cColor
    sRange.ApplyNoFill
    'Clear selection
    ActiveDocument.ClearSelection
End Sub
This ungroups and converts to curves correctly but then nothing further until ActiveDocument.ClearSelection is called.
Reply With Quote
  #6  
Old 12-10-2007, 09:57
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 Odd...

Seems to work fine here. I am using CorelDRAW X3 SR2. The UngroupAllEx return a ShapeRange so you can work with it.

-Shelby
Reply With Quote
  #7  
Old 12-10-2007, 15:36
m31uk3
Guest
 
Posts: n/a
Default

Do you feel that Corel X3 is a more stable application than Corel 12?

If so I may make the upgrade....
Reply With Quote
  #8  
Old 12-10-2007, 15:41
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

X3sp2 is more stable than 12sp1 positvely. I have experience with both of them for a few years.
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
Attributes in Corel Draw dueless CorelDRAW/Corel DESIGNER VBA 8 09-01-2008 06:56
Corel Trace and editing in Corel draw madhur General 1 26-09-2007 17:04
Corel Draw or Corel Paint? H20diver General 8 24-07-2007 12:06
Corel Draw 12 and Color Management... meandirtyjoe General 7 31-12-2005 16:57
corel draw 11 and Corel Trace 11 BEAMA General 2 04-08-2005 19:39


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


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