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.
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
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.
That's brilliance, thanks Joe. This helps Corel far more than a little and just me, since this flaw affects All VBA scripting with equivalent undocumented, catastrophic, byte value range conversions. Corel should be made aware and desperate to correct this oversight preventing clients effectively scripting\automating entirety of CorelDRAW\PHOTOPAINT. Look forward to running your latest macro, greatly appreciated!6) you suggested 'playing with threshold, is that same as Detail level, or is there an actual "Threshold" setting to edit?,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?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?9) attached screenshots 9-10.jpg show ArtCAM's ColorReduction then Create Centerline applied to "Disconnected open vectors"(=vertical centerlines), then successfully to "Closed vector loops"(=lateral centerlines) respectively. Can this or equivalent method be applied in CorelDRAW macro to prevent the Vertical centerlines in your sceenshot results of latest macro?..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.Look forward to next soonest,U da Man Joe,thx,Jeff
..bit more good news: have developed CDR pathway equivalent to ArtCAM's ColorReduction, CreateCenterline &Closedvectorloops;CDR = - Bitmaps > Outline Trace > Line Art,- Bitmaps > Outline Trace > Line Art \ Colors(tab): Number of Colors=8,- select palette colors appropriate to "Merge" into mono-colored, masked(roto'd), target objects(characters),- save as vectors, - Bitmaps > Convert to Bitmap,.- Bitmaps > Centerline Trace > Line Drawing,. with my configs...this produces lateral Centerline vectors near accurate ArtCAM's, and far! less to cleanup\cut-away with Outlines from auto-rotoscoper.Hopefully you've still a bit of time to script this additional algorithm into 'lines of needed functions achieved using a macro?,I'm attempting same, adding the Outline Trace > Line Art color reduction\Merge &ConvertToBitmap to the sofar invariable Centerline macro.Come a long way in few hours toward full function thanks again to you,talk soon,Jeff
dancemanjc said: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.
dancemanjc said: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.
dancemanjc said: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.
dancemanjc said:..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
dancemanjc said: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.
So cool, thanks for the rapid algorithmic implementation.Besides the Ineffective-macro-settings-Bug, all that remains to script prior to ConvertToBitmap is:a) select palette colors appropriate to then "Merge"(button) into mono-colored, masked(roto'd), target objects(characters), perhaps: MergeAdjacentObjects property is applicable?..i'll send screenshots of the order and position of each palette color selection to Merge, which remains consistent thru each sequence loaded into bitmap-layers,.b) save as vectors(OK button), which i think .Finish or S.Finish achieves,..if you can spare a bit more of you valued time for this last implementation(from pending screenshots), it's as always greatly appreciated. I'll be attempting the same as usual. Great to know of other wizards supporting this excellent and singular forum, but of the 15+ combined forums(including this), retail VBA scripting and published Author websites, your the only one to answer, diagnose CDR's bugs and resolve serviceable custom solutions. So for me, you alone had earned what should be CDR payroll for their job well done. From decades of common Bug-reporting, feature-requesting experience, like most corporations these bugs likely aren't high priority enough to fix even when brought to Corel's attention, which i won't waste time attempting. Which again leaves this site and your wizardry's as sole recourse for CDR scripting issues.Always looking forward,talk soon,Jeff
..as promised here's results of Manual color-reduction\Merge as final scripting algorithm: 8 colors ordered 1 - 8 top to bottomscreenshot 11-12.jpg = Select palette colors 5+6(of 8), Merge(button)screenshot 13-14.jpg = Select palette colors 1+5(of 7), Mergescreenshot 15-16.jpg = Select palette colors 4+5(of 6), Mergescreenshot 17-18.jpg = "TraceEachPage" results rendering perimeter landscape centerlines only, No raptors\TRex centerlines i assume due to ConvertToBW the source image...Thanks again Joe,talk soon,Jeff