Print display feature

Having problems with or questions about SheetCam? Post them here.
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Print display feature

Post by David_Lelen01 »

Hey Les, just wondering if you ever got any free time to make any progress on this. And adding a layout picture to the job reports?
User avatar
Les Newell
Site Admin
Posts: 3668
Joined: Thu May 11, 2006 8:12 pm

Re: Print display feature

Post by Les Newell »

I'll see what I can do but no promises on getting anything done on it for the upcoming release, which will be out next week, honest!
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Print display feature

Post by David_Lelen01 »

Les, any chance you have gotten anywhere with this or putting a picture in the job report? I really cant tell you how wonderful that would be. *nudge nudge. lol
User avatar
Les Newell
Site Admin
Posts: 3668
Joined: Thu May 11, 2006 8:12 pm

Re: Print display feature

Post by Les Newell »

I need to completely redesign the job report to put pictures in the output and i'm afraid that job keeps getting put on the back burner.
wxWidgets recently added a SVG renderer so I may be able to generate an SVG based report. Another alternative would be to generate a pdf but I have absolutely no experience with PostScript.
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Print display feature

Post by David_Lelen01 »

Understandable. To be honest, I'm kind of surprised there's not more people behind me pushing for some pictures in the reports. But I suppose the majority of users don't even use the reports, they cut the jobs as they create them. I guess we just operate on a bit larger of a scale here haha. We typically have a stack of 10+ jobs each on 4 different machines at any given time, so the more details I can put in the reports, the better.

Does HTML not handle pictures well or is there no way to get the picture from sheetcam to the html report? I cant see what's going on behind the scenes when a report is run, so I don't know. I probably wouldn't understand it anyways to be honest. I like to think I understand more than I do, lets face it, g-code, the post codes, and the html reports are probably about as rookie level as it gets.
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Print display feature

Post by David_Lelen01 »

Wild thought here, don't know if its possible so I thought id ask since its apparently primarily me that wants this or would use it... could I insert some code somewhere to just take a screenshot of the current display area and save it to somewhere (job folder perhaps) and then put in the html report code to insert that picture? I guess I cant edit any of the code that would be necessary to take the screenshot before the report is run though... maybe I could have the post do that somehow since I always run the post before the report anyways. idk, just a thought.
User avatar
Les Newell
Site Admin
Posts: 3668
Joined: Thu May 11, 2006 8:12 pm

Re: Print display feature

Post by Les Newell »

I think report gets mostly used for costing.

In your post try this code in function OnFinish()

Code: Select all

--save screen shot as 'screen.png' in g-code directory
local path = wx.wxFilename(fileName):SetFullName("screen.png"):GetFullPath()
local bmp = sc.Parts:Get().glDisplay:GetBitmap()
bmp:SaveFile(path, wx.wxBITMAP_TYPE_PNG)

-- pop up the job report dialog
local mgr = sc.wxActionManager.Get()
mgr.Execute(sc.actPOST_ESTIMATE)
As long as you save the job report in the same directory as your g-code it should work. You will of course need to modify your report to link to screen.png
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Print display feature

Post by David_Lelen01 »

Its not working. I caught one typo, I believe wx.wxFilename(fileName) should have been wx.wxFileName(fileName), but now its throwing error "attempt to index a nil value".

I honest to goodness tried to figure it out, I have been reading through the wxWidgets documentation online for over an hour now, but the syntax looks so different from what you write.
User avatar
Les Newell
Site Admin
Posts: 3668
Joined: Thu May 11, 2006 8:12 pm

Re: Print display feature

Post by Les Newell »

The problem is that the online docs are for the C++ version of wx. SheetCam internally uses C++ but posts and scripted plugins use a Lua translation layer which has diffferent syntax.

Give this simplified version a try. I'm not siure why I didn't do it this way in the first place.

Code: Select all

--save screen shot as 'screen.png' in g-code directory
local path = filePath .. "screen.png"
local bmp = sc.Parts:Get().glDisplay:GetBitmap()
bmp:SaveFile(path, wx.wxBITMAP_TYPE_PNG)

-- pop up the job report dialog
local mgr = sc.wxActionManager.Get()
mgr:Execute(sc.actPOST_ESTIMATE)
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Print display feature

Post by David_Lelen01 »

Aah... i see.... you just had to throw a curve ball in there :lol:
Any suggestions for references to learn that some? Not that it will do me a substantial amount of good, but may come in handy once in a while. About like learning to say "Where's the bathroom?" in the language of whatever country you plan to visit.

Awesome! The post side of it works great! I'll go work on the html side of it now...

And an added bonus!! You made the report auto pop up after running the post! Sweet!!
User avatar
Les Newell
Site Admin
Posts: 3668
Joined: Thu May 11, 2006 8:12 pm

Re: Print display feature

Post by Les Newell »

wxWidgets is written in C++ so it's documentation is mainly aimed towards C++. C++ is compiled to machine code (which is what processors understand). Compiling is slow and can't be done by the end user. However the compiled code is compact and runs very fast. This is what I use for the main application.

The Lua scripting engine interprets code as it runs. This is much slower to execute but there is no compilation stage so it is quick and easy to edit the code.

Unfortunately there isn't much documentation on using wx on Lua. It's not a common combination. The Python version of wx is much better documented but Python is even slower and it's a bloated monster.

To make things worse there are a lot of extra SheetCam specific additions to Lua. All of the SheetCam specific classes are specified in the SDK folder in SheetCam's installation folder. The .i files are simple text files. For instance at the bottom of sc.i you'll see all of the actions you can trigger with the action manager.
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Print display feature

Post by David_Lelen01 »

I thought wxWidgets looked like C++. I am much more familiar with that, but still nowhere near proficient.
It's not a common combination.
Now that's more my style... doing things that are uncommon :lol:

Oh wow, that is quite a bit of stuff in the SDK folder.... I've never actually peeked in there for some reason. Probably should have long before now.

Okay, back to the topic at hand though. This is so far turning out very nicely. This is exactly what I have been looking for all this time. I'm sure its a very inefficient way to do it, but it works. At least so far. I got the image in the report, but the path is currently hard coded. I am not seeing a way to pass a variable into HTML with the job path since HTML doesn't exactly handle variables well. And to make matters worse and more difficult, certain variables are only available at certain sections of the report. Ideally, I want the picture to be at the bottom of the report, so I am currently trying to put it between the operations section and the footer section. Would the easiest way to do this just be temporarily store the image in a temporary folder, like the user's AppData temp folder, since it's really only needed for a brief time anyways? Then the directory will remain static.
User avatar
Les Newell
Site Admin
Posts: 3668
Joined: Thu May 11, 2006 8:12 pm

Re: Print display feature

Post by Les Newell »

Can you just link to 'screen.png' rather than using the full path? You would need to save the job report to the same folder as your screen shot.
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Print display feature

Post by David_Lelen01 »

Yes, but then I would either need to save a copy of the report.html in each job folder, which is highly unattractive, or just save the screen.png to the reports directory. I'll try saving the screen.png to the reports directory and let it overwrite on each job since I don't see a need for the screenshot to be saved and used later. I'm sure I'll come up with some reason to keep it in a few weeks though :lol:. My only concern there is UAC restricting access to the Program Files (x86) directory where the report templates are saved. We shall see shortly...
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Print display feature

Post by David_Lelen01 »

Can the screen color scheme be changed from the post when saving the screenshot? Like switch from dark scheme to light scheme for a second. And can a custom scheme other than the default dark or light be saved instead of manually changing the colors?
Post Reply