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 pEnd Sub(1) Bitmap Trace via Set(parameter) TraceSettings:Sub TraceSettings()Dim s As Shape, sr As ShapeRangeDim t As TraceSettingsFor 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 = NothingEnd Sub
Hello, already in the New Year.
Could you make a visual example of what is not working/what you would like to achieve? Because on my side running the scripts seems to work as needed, making center line traced outline objects...
Hi Joe, Happier New Year, really appreciate your reply and confirmation the scripts work on your system and CorelDRAW version.I assume you ran the scripts as is, or please let know of any changes?2) please confirm you substituted cdrTraceLineDrawing in place of cdrTraceLineArt in the scripts?, and did cdrTraceLineDrawing work?,3) please let know which version of CorelDRAW, and on what system your successfully running the cdrTraceLineDrawing script?, (i'm using Win7 &i tried to list complete system configs below, but the "Brand" names we're apparently flagged as advertisements)..Screenshot "1_.." is a frame 572 of project footage,screenshot 1a_, is Manual Bitmaps > Centerline trace > Line Drawing results,screenshot 1b_, is Manual centerline trace Curve results,screenshot 2_, is script 2), function TraceSettings used with working cdrTraceLineArt enumerator,screenshot 3_, is TraceSetting script Successful results bitmap tracing Outlines,screenshot 4_, is TraceSetting script Failure with cdrTraceLineDrawing, producing only linear path instead of bitmap tracing Centerlines.I plan to achieve a script that converts each CDR bitmap-Layer to a Centerline Trace, Line Drawing.Look forward to talk soon,thx again,Jeff
Now I get it!
As far as I can tell it was using the DetailLevelPercent of 100 with the original image. Seems like it does the exact opposite of what it sounds like.
One option is to lower that value, but to me it feels like making a sort-of preview image where you can adjust the settings a little better isn't a bad idea either. So I changed your code a little:
Sub TraceEachPage() Dim ShapeToTrace As Shape, BitmapsToTrace As ShapeRange, PagesToTrace As Page For Each PagesToTrace In ActiveDocument.Pages PagesToTrace.Activate Set BitmapsToTrace = ActivePage.Shapes.FindShapes(, cdrBitmapShape) Set ShapeToTrace = ActiveShape For Each ShapeToTrace In BitmapsToTrace ShapeToTrace.Bitmap.ConvertToBW cdrRenderLineArt, 100, 24 With ShapeToTrace.Bitmap.Trace(cdrTraceLineDrawing, 25, 50, cdrColorBlackAndWhite, , 2, True, True) .Finish End With Next ShapeToTrace Next PagesToTrace End Sub
You can comment out the trace lines and adjust that 24 number up and down a little to see how close to a clear linework you can get that initial image. Then go back to tracing and the results should be close to what you wanted.
Or, if the less detailed version you have as an example is what you want just change the 100 in your original code.
May I ask what the final use of this is? Was just wondering, since that middle line trace does not look that great, no matter what you adjust.
Thanks again Joe, great news and diagnostic, just got in for parameter update,i'd tried the scripts with DetailLevelPercent = 80, which evidently still high enough to render no curves since setting only prolificates centerlines at lower values. So my Manual(image 1b) trace settings (D45, s80, cs75) will work, awesome!(this inverted order of Detail and Smoothing in trace window, is reason i adjusted smoothing in scripts thinking it detail, while actually leaving it at 100)4) were the following Bitmap method, enumerator &settings also required for cdrTraceLineDrawing to render?, (really good to know thx, also for line quality control, found neither used in tracing script examples) ShapeToTrace.Bitmap.ConvertToBW cdrRenderLineArt, 100, 24- also assume this the line you mentioned 'can comment out?,Yes, images 1a-1b is desired version, these cleanable but accurate Centerlines are used in semi&fully-automated 2.2.3D(tm), cinematic conversion methods.Hope Corel also recognizes your value, CDR's great but they don't know or support VBA automation, esp. for the obscure and undocumented as much of equivalent scripting language.Appreciate it,looking forward,Jeff
Hi Joe, happy confirming the scripts are now producing Centerlines, but not near as many as manually produced(Image 1b), and mainly in the blank(black) area's as if ignoring color information.see screenshots:6.jpg = my scripts producing only 5 curves7.jpg = your script producing only 2 curves8.jpg = my script, with curves UNgrouped.Regardless of Detail, Smoothing &CornerSmoothing settings, Trace scripts will produce no more than 3 - 5 curves only in black areas, unlike correct results when manually centerline traced.5) are your Trace script results like my manual results in screenshots 1a-1b.jpg?, might you send a screenshot please?Thanks again for any suggestions or solutions,Jeff
Hello again!
Not good news... Now that I have tested it a little more I can confirm that something is wrong with tracing using macros. The settings affect almost nothing...
I used that b/w bitmap method to find the best settings (in my opinion) for tracing nice lines:
My choice was 26. Then, while trying to trace that using code this happens:
(Yes, made a macro that changes the settings and exports an image for each one )
But as we can see something is broken with their settings - the results are nothing like doing it manually...
Sounds like the only real choice to get the look you want is to either play around with the threshold to get something close and/or possibly try and edit the image more so that the macro tracing works better somehow.
I will probably try to have a look at how lines like the ones you want could be achieved using a macro, now that there's a better idea of what is needed and for what purpose.
Actually, hold on!
The settings my be acting weird in the macro, but also we need to keep in mind that the percentages we perceive as (0-100) are, apparently, byte values when using macro - so they go 0-255 not 0-100.
If we keep that in mind and convert the values like this:
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, 80 * 2.55, 45 * 2.55, , , 2, False, , True) .Finish End With Next s Next p End Sub
The results look much closer to what you have by hand.
Hopefully this helps a little.