cdrTraceLineDrawing FAILS, producing single linear path instead of Centerline bitmap trace?

Hello esteemed CDR &CorelDESIGNER API Members,
                                                                                        and thanks for such excellent programming, scripts and productive support.

1) I hoped you might please advise how to use cdrTraceType cdrTraceLineDrawing which FAILS, only producing a single linear path instead of CENTERLINE trace?

When using cdrTraceLineArt the same macros below WORK, producing vectorized OUTLINE paths from bitmap textures:
(please feel free to forward this to anyone who may instruct remedy. Thanks for any help, Jeff)

(2) Bitmap Trace via With(reference) to ActivePage Shapes:
Sub TraceActivePage()
        Dim s As Shape, sr As ShapeRange, p As Page
        For Each p In ActiveDocument.Pages
               p.Activate
              Set sr = ActivePage.Shapes.FindShapes(, cdrBitmapShape)
              Set s = ActiveShape
              For Each s In sr
                     With s.Bitmap.Trace(cdrTraceLineDrawing, 25, 100, cdrColorBlackAndWhite, cdrUniform, , True, True, True)
                    .Finish
                     End With
              Next s
        Next p
End Sub


(1) Bitmap Trace via Set(parameter) TraceSettings:
Sub TraceSettings()
Dim s As Shape, sr As ShapeRange
Dim t As TraceSettings
For Each s In ActivePage.FindShapes(, cdrBitmapShape)
       Set t = s.Bitmap.Trace(cdrTraceLineDrawing, 25, 100, cdrColorBlackAndWhite, cdrUniform, , True, True, True)
       t.Finish
       Next s
       Set t = Nothing
       Set s = Nothing
End Sub

Parents Reply
  • ..hi Joe, i've also found the following Event Handlers which i'm attempting to hook within\after Bitmap.Trace to merge reduced colors. I'm hoping you may please do the same if event handlers are applicable. As always appreciate any solutions or suggestions.
    Jeff


    community.coreldraw.com/.../8-6---working-with-shapes
    Class         Member                 Description
    AddinHook     ShapeCreated event     Is triggered when a shape is created For more information, see Creating shapes.

    Application     SelectionChange event     Is triggered when a selection is deactivated For more information, see Deselecting shapes.

    Document     SelectionChange event     Is triggered when a selection is deactivated For more information, see Deselecting shapes.

    Document     ShapeChange event     Is triggered when a shape is deselected For more information, see Deselecting shapes.
    Document     ShapeCreate event     Is triggered when a shape is created For more information, see Creating shapes.
    Document     ShapeDelete event         Is triggered when a shape is deleted For more information, see Deleting shapes.
    Document     ShapeDistort event         Is triggered when a shape is distorted For more information, see Applying distortions.
    Document     ShapeMove event         Is triggered when a shape is positioned For more information, see Positioning shapes.
    Document     ShapeTransform event     Is triggered when a shape is transformed For more information, see Transforming shapes.

    GlobalMacroStorage     SelectionChange event     Is triggered when a selection is deactivated For more information, see Deselecting shapes.


    forums.codeguru.com/showthread.php
    April 21st, 2004, 07:43 AM #5
    Aleksan is offline Junior Member
    Join Date    Jan 2004
    Posts    8    

    In Basic its look like this

    Dim Draw As CorelDRAW.Application
    Dim WithEvents MyAddin As CorelDRAW.AddinHook

    Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As                                     AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
                    Set Draw = Application
                    Set MyAddin = Draw.AddIns.Attach(cdrAddinFilterNone, "Get Shape Length")
    End Sub

    Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
                         Set GetLengthAddin = Nothing
                         Set Draw = Nothing
    End Sub

    Private Sub GetLengthAddin_Execute()
    End Sub



    www.oberonplace.com/.../comaddins.htm
    ..11. Add the code to OnConnection and OnDisconnection event handlers. Use the following example on how to do this:

    Dim Draw As CorelDRAW.Application
    Dim WithEvents CropMarksAddin As CorelDRAW.AddinHook

    Private Sub AddinInstance_OnConnection(ByVal Application As Object, _
                 ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
                 ByVal AddInInst As Object, custom() As Variant)
                 Set Draw = Application
                 Set CropMarksAddin = Draw.AddIns.Attach(cdrAddinFilterNone, "Create &CropMarks")
    End Sub

    Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As _
                 AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
                 Set CropMarksAddin = Nothing
                 Set Draw = Nothing
    End Sub

    In the above example, the application object is set to a global variable Draw. Then a new addin hook is added to CorelDRAW by using its Addins collection and calling its Attach method.

    ..13. Add the code to the Execute event handler to provide your addin code:

    Private Sub CropMarksAddin_Execute()
        Dim x As Double, y As Double, sx As Double, sy As Double
        If Draw.Documents.Count > 0 Then
            If Draw.ActiveSelection.Shapes.Count > 0 Then
                Draw.ActiveSelection.GetBoundingBox x, y, sx, sy, True
                With Draw.ActiveLayer
                    .CreateLineSegment x - 0.5, y, x, y
                    .CreateLineSegment x, y - 0.5, x, y
                    .CreateLineSegment x + sx, y, x + sx + 0.5, y
                    .CreateLineSegment x + sx, y - 0.5, x + sx, y
                    .CreateLineSegment x - 0.5, y + sy, x, y + sy
                    .CreateLineSegment x, y + sy, x, y + sy + 0.5
                    .CreateLineSegment x + sx, y + sy, x + sx + 0.5, y + sy
                    .CreateLineSegment x + sx, y + sy, x + sx, y + sy + 0.5
                End With
            End If
        End If
    End Sub

    14. Save your project and compile in a DLL. Go to File>Make CropMarks.dll menu in Visual Basic and specify a folder to save the addin DLL to. When the addin is compiled it is automatically registered with CorelDRAW.

    So now you can just launch CorelDRAW and see how it works. After CorelDRAW is started, create a new document and create a shape. With the shape still selected go to Tools>Visual Basic>Addins and choose "Create CropMarks" item in the pop-up menu. The addin should be executed and crop marks should be created around the selected shape in CorelDRAW document.

Children