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
  • 6) you suggested 'playing with threshold, is that same as Detail level, or is there an actual "Threshold" setting to edit?,

    That is the exact name of the setting of that two color Bitmap conversion. But probably isn't important anymore, given the different approach below.

    7) in your Detail level .gif, centerlines were rendered starting at value:104, but then with No variation in detail at any further increased level. So macro settings edits seem again to have only partial effect\control over tracing renders compared to full control manually tracing?

    It is that function working incorrectly when used in a macro, yes. At least as far as I can tell. Nothing changes when changing the same settings that do something when using it through the user interface. So sounds like a bug to me.

    8) was ShapeToTrace.Bitmap.ConvertToBW cdrRenderLineArt, 100, 24 the b/w bitmap method you used to find the best settings?, if not please show which?

    Yes, that is exactly it. If you want to see how things work inside a macro you can run it step by step instead of the usual run command. Just place the cursor inside the macro text and press F8 on the keyboard to start. Then keep on pressing F8 to go through each line and see what it does. You can also just stop the macro to leave the results at that stage.

    ..Corel owe's you big illuminating\resolving These issues alone, and since indispensable to scripting they don't support, you should obvously be on payroll.

    I wouldn't say so. There are some REALLY talented macro wizards here. Now they deserve some real praise. But it's been a little quiet here lately so I came to help to the best of my ability 

    Hopefully you've still a bit of time to script this additional algorithm into 'lines of needed functions achieved using a macro?,

    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
                'Bitmaps > Outline Trace > Line Art \ Colors(tab): Number of Colors=8,
                With S.Bitmap.Trace(cdrTraceClipart, 10 * 2.55, 45 * 2.55, cdrColorRGB, , 8, False, , False)
                    .Finish
                End With
                
                'The 25 at the end here makes sense if your canvas size is about 2000mm wide.
                'If not you will have to adjust it so the bitmap isn't huge, but still has
                'enough detail. I would just adjust the document and image to, say 1920x1080 mm.
                Set S = ActiveSelection.ConvertToBitmap(, , , , 25)
            
                'Bitmaps > Centerline Trace > Line Drawing
                With S.Bitmap.Trace(cdrTraceLineDrawing, 80 * 2.55, 45 * 2.55, , , 2, False, , True)
                    .Finish
                End With
                
                'Remove the middle temporary image object
                S.Delete
            Next S
        Next p
    End Sub
    

    I think that should do the things you mentioned in that list. The results are a little different from the example, but you can try changing the settings around to change the results a little.

    Good luck, let me know how it goes.

Children