OberonPlace.com Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-03-2004, 11:20
pp21
Guest
 
Posts: n/a
Default Convert barcode to curves

Barcode is OLE object, so you can't make a lot of actions, like changing colors, rotating and there are problems across Corel Draw versions.

Convert barcode to curves is good idea. I know only 2 ways how to do it.

1. Export barcode as vector format (EPS, AI, PDF, PS) and import it back.
2. Copy barcode to clipboard and paste special as metafile.

Second way is more comfortable but barcode is pasted to center of page and colors are in RGB.

Idea for macro is:
- Convert selected barcode to curves; keep original position (in all 3 axis - y, x and z (object order))
- If group is selected, look if in the group are barcodes and convert them
- If nothing is selected look whole page for barcodes and convert them
- Look inside Power Clips


I write a macro for this. It is designed for Corel Draw 11 and does not all features listed above.
But it work. If selected barcode is inside group is converted too and curved barcode is back inside group.

Here is the code, but it use CorelScript object so it will not work in Draw 12. This code is attached in GMS file too. Barcode must be selected to run this macro.

Code:
Sub BCtoCurves()
  Dim x As Double, y As Double, bc As Shape
  
  ' No selection
  If ActiveShape Is Nothing Then Exit Sub
  ' More than one object selected
  If ActiveSelection.Shapes.Count <> 1 Then Exit Sub
  ' No OLE (BarCode) object selected
  If ActiveShape.Type <> cdrOLEObjectShape Then Exit Sub
  
  If Not ActiveLayer.Editable Or Not ActiveLayer.Visible Then
    MsgBox "Operation cannot be completed." & vbLf & _
           "The active layer """ & ActiveLayer.Name & _
           """ is locked or invisible.", vbExclamation
    Exit Sub
  End If
  
  ' For one undo operation
  ActiveDocument.BeginCommandGroup "Convert Barcode To Curves"

  Set bc = ActiveShape
  ' Copy BarCode to clipboard
  bc.Copy
  
  ' remeber BarCode position and layer
  bc.GetPosition x, y
  l = bc.Layer.Name
      
  ' Paste as metafile
  CorelScript.PasteSystemClipboardFormat 3
  
  ' Convert to curves (BarcodeDigits are artistic texts)
  ActiveSelection.ConvertToCurves
  
  ' Recolor black and white RGB colors to CMYK
  ActiveSelection.Ungroup
  For Each sh In ActiveSelection.Shapes
    If sh.Fill.UniformColor.Type = cdrColorRGB Then
      c = sh.Fill.UniformColor.RGBRed
      c = sh.Fill.UniformColor.RGBGreen + c
      c = sh.Fill.UniformColor.RGBBlue + c
      If c = 0 Then
        sh.Fill.UniformColor.CMYKAssign 0, 0, 0, 100
      ElseIf c = 765 Then
        sh.Fill.UniformColor.CMYKAssign 0, 0, 0, 0
      End If
    End If
  Next
  ActiveSelection.Group
  
  ' Move curved BarCode to original position
  CorelScript.MoveToLayer l
  ActiveShape.SetPosition x, y
  ActiveShape.OrderFrontOf bc

  ' Delete original BarCode
  bc.Delete
    
  ActiveDocument.EndCommandGroup
End Sub
Attached Files
File Type: gms bc2cur.gms (21.0 KB, 1574 views)
Reply With Quote
  #2  
Old 10-03-2004, 22:56
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: Convert barcode to curves

Hey, nice macro there! Good work!
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
how can convert GMS file unviewable??!!! bb CorelDRAW/Corel DESIGNER VBA 13 14-01-2011 01:40
how can convert GMS file unviewable??!!! bb CorelDRAW/Corel DESIGNER VBA 0 29-03-2005 19:31
[b]Smoothing curves[/b] LOT CorelDRAW/Corel DESIGNER VBA 2 11-02-2004 08:24
convert .gms file unviewable !!! bb CorelDRAW/Corel DESIGNER VBA 1 18-06-2003 17:04
Corel 10 file conversion script doesn't convert files Kevin CorelDRAW CS 0 13-04-2003 20:28


All times are GMT -5. The time now is 04:48.


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