OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   New product ideas (http://forum.oberonplace.com/forumdisplay.php?f=15)
-   -   Convert barcode to curves (http://forum.oberonplace.com/showthread.php?t=418)

pp21 04-03-2004 12:20

Convert barcode to curves
 
3 Attachment(s)
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


Alex 10-03-2004 23:56

Re: Convert barcode to curves
 
Hey, nice macro there! Good work!


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

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