OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Corel User Forums > CorelDRAW > Macros/Add-ons

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 28-02-2006, 20:07
billjones
Guest
 
Posts: n/a
Default Need Macro for "Convert Outline to Object"

Hi. I frequently need to perform the "Convert Outline to Object" function on all objects in my drawing, in order to be able to scale it down without the lines getting thicker. To do this manually, I go to the Object Manager and select the first object, do a CTRL+SHFT+Q and hit the down arrow two times and repeat. This isn't bad if the drawing is simple, but I would like to have a macro to automate this process.

I am using CorelDRAW 12 and am new to using Visual Basic. Can someone show me how to write the code for this, and how to run it from within CorelDRAW? Thanks!
Reply With Quote
  #2  
Old 28-02-2006, 20:20
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Well, this can be done, but have you tried to set "Scale outline with object" setting instead? Go to outline dialog and check that button at the bottom. Then you can scale your objects all you want and your outlines will scale along with your objects.
Reply With Quote
  #3  
Old 28-02-2006, 21:01
billjones
Guest
 
Posts: n/a
Default

Hi Alex. I never noticed that! I'll give it a try.

I still have to get rid of hairlines or thin lines, as these drawings go to a laser machine which will cut through the material on a hairline width or less. The drawings I make start out relatively big and are scaled down to about 20mm in size. The only hairline in the drawings must be around the border, and the rest of the lines are converted to outlines with black fill (so I can see the lines!) and no outline.

Can you show me how to write the macro to do this?
Reply With Quote
  #4  
Old 01-03-2006, 08:06
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,782
Blog Entries: 11
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 Outline

I happen to do this all the time for sandblasting. Here is some quick code to get you started:

Code:
Sub ConvertOutlineToObject()

Dim sr As ShapeRange

If Basics.ExpireCode = True Then Exit Sub
Optimization = True
ActiveDocument.BeginCommandGroup "Convert Outline to Object"
On Error GoTo ErrHandler

If ActiveSelection.Shapes.Count = 0 Then
    Response = MsgBox("Nothing was Selected, Would you like to convert all objects?", vbYesNo, "Convert Outline to Object")
        If Response = vbYes Then
            ConvertOutlinetoObjectSub ActivePage.Shapes
        Else
            Exit Sub
        End If
Else
    Set sr = ActiveDocument.SelectionRange
    ConvertOutlinetoObjectSub ActiveSelection.Shapes
End If

ExitSub:
    ActiveDocument.EndCommandGroup
    Optimization = False
    ActiveWindow.Refresh
    Exit Sub

ErrHandler:
    MsgBox "Error occured: " & Err.Description
    Resume ExitSub

End Sub

Private Sub ConvertOutlinetoObjectSub(ss As Shapes)

Dim s As Shape

For Each s In ss
    If s.Type = cdrGroupShape Then
        ConvertOutlinetoObjectSub s.Shapes
    Else
        s.Outline.ConvertToObject
        s.Delete
    End If
Next s

End Sub
The best thing about this macro is is supports multiple object and even will convert groups. Hope it helps and if you can think on any improvements let me know.

Shelby
Reply With Quote
  #5  
Old 01-03-2006, 08:09
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Ok, here you are...

Code:
Sub ConvertOutlines()
    Dim s As Shape
    Dim sNew As Shape
    For Each s In ActivePage.FindShapes()
        If s.CanHaveOutline Then
            If s.Outline.Type <> cdrNoOutline Then
                Set sNew = s.Outline.ConvertToObject
                If s.CanHaveFill Then
                    ' If the original object had no fill, it now has no outline as well
                    ' That is, it's invisible. Let's just delete that object...
                    If s.Fill.Type = cdrNoFill Then
                        s.Delete
                    End If
                End If
            End If
        End If
    Next s
End Sub
This macro is for CorelDRAW X3...
Reply With Quote
  #6  
Old 01-03-2006, 13:06
billjones
Guest
 
Posts: n/a
Default

Thanks! These macros are exactly what I'm looking for.

Now I would like to ask if it is possible to do the opposite, where a "center line" hairline is generated in the middle of a line that is a filled outline. One application of this I would use is to convert a simple font into a "single line" font for rotary engaving.

I have been looking at the demo of CorelDRAW X3 and like the "Smart Fill" and "Create Boundary" functions. The Create Boundary is close to what I'm looking for, except the hairline is outside (of course) of the filled line instead of being in the middle.

I'm not sure if this is the right place to ask, but on the Smart Fill function I notice that sometimes the fill "leaks out" of an apparently "closed" area. When I look closer at the area to be closed I notice that the nodes aren't exactly connected (endpoint of line is not touching the centerline of another line, and is slightly off but still appears connected due to the line widths overlapping). I know this is caused by sloppy drawing (maybe snap to object was off?). What is the best way to fix this (have all the nodes connect)? Should I select all the curves and do a "Combine" (CTRL+L) and "Break Apart" (CTRL+K), or can I select the whole drawing and do some other function?

Thanks again for your help. Your support is great!
Reply With Quote
  #7  
Old 01-03-2006, 14:15
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

Quote:
Now I would like to ask if it is possible to do the opposite, where a "center line" hairline is generated in the middle of a line that is a filled outline. One application of this I would use is to convert a simple font into a "single line" font for rotary engaving.
Have you tried Trace 12's centerline trace? What you would do is convert the text to a 300 dpi Black and white 1 bit bitmap, then use Trace/Centerline to convert it. I haven't tried it myself, but it was the first thing that came to mind.

I did try it just before posting and it works. Change the node reduction to 0 and the iterations to 100 for best results.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #8  
Old 01-03-2006, 14:31
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,782
Blog Entries: 11
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 CorelTrace 12

Sean's suggestion for CorelTrace 12 is the best solution I know of. Although I have never had the best of luck with it. I seem to recall another thread around here somewere discussing this...you may want to dig around and see if you can find it.

Shelby
Reply With Quote
  #9  
Old 01-03-2006, 22:58
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Quote:
Originally Posted by shelbym
I seem to recall another thread around here somewere discussing this...you may want to dig around and see if you can find it.
The thread Shelby is referring to is this: http://forum.oberonplace.com/showthread.php?t=1218

However it doesn't give any concrete answers as to what the solution might be. Just some discussion about it...
Reply With Quote
  #10  
Old 02-03-2006, 07:36
gingem
Guest
 
Posts: n/a
Default

Hi Alex
The only problem I have found with the scale lines with size is that it always makes the outlines to hairlines if you are working on small details. Since most of my work is for glass and crystal sandblasting I just put the convert to outline on my toolbar and use it as I go. Normally I try to keep the outlines no less that .005 for blasting. Sure would be nice if I could add custom line widths to Corel though.
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
Cannot use Curveworks macros in a user witten macro??? jon46089 CurveWorks 2 02-03-2006 14:18
CD 10, VBA not returning true outline width Webster CorelDRAW/Corel DESIGNER VBA 1 24-11-2004 17:09
Apply Outline - Scale with Image geopig CorelDRAW/Corel DESIGNER VBA 4 06-05-2004 07:23
New macro to clip curves w.r.t. a border Gerard Hermans Macros/Add-ons 0 09-06-2003 07:50
Speeding up a macro Rick Randall CorelDRAW/Corel DESIGNER VBA 2 12-12-2002 10:51


All times are GMT -5. The time now is 07:16.


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