Visio Guy

Visio Discussions => General Visio => Topic started by: Yacine on April 25, 2013, 06:13:04 AM

Title: Screen shot of part of drawing
Post by: Yacine on April 25, 2013, 06:13:04 AM
Hi everybody,
I'm looking for a possibility to export parts of a drawing as bitmap images and tought remembering, that when you save your drawing as a bitmap file, after having selected a shape, visio would create a bitmap with that same shape, but also all the shapes within the boundaries of the selected shape.
I must have dreamt it, because I cannot replicate that behaviour (Visio 2007) - only the selected shape itself is shown in the bitmaps.
Do I really need to save the whole drawing and crop it programatically afterwards?
Title: Re: Screen shot of part of drawing
Post by: Paul Herber on April 25, 2013, 06:25:33 AM
Hi Yacine, if a shape (or shapes) are selected then only that (those) shapes will be saved into the image.
If you create a selection area with the mouse then all shapes within the area will be saved. Whether or not shapes partially in the area are saved depends on the options setting "Select shapes partially within area".

Title: Re: Screen shot of part of drawing
Post by: Yacine on April 25, 2013, 03:44:46 PM
Hi Paul, You're right, but it doesn't cut the connectors at the box boundary. So you either select only the shapes, that are completely within the box and won't get the connectors leaving the box at all, or you include the connectors crossing the boundaries and get a "hairy" box. ;-).

PS: This applies also for the shapes shown in the example, which are only partially in the box.
Title: Re: Screen shot of part of drawing
Post by: Paul Herber on April 25, 2013, 07:58:40 PM
For screenshots like this I just capture the whole screen (using PtrScn) and crop in an editor (I use PaintShop Pro) or do a capture directly in PaintShop Pro).
I don't think Visio can do so directly.
Title: Re: Screen shot of part of drawing
Post by: JuneTheSecond on April 26, 2013, 12:20:39 AM
If Visio can do so, we can save much time.
Time is money. :)
Title: Re: Screen shot of part of drawing
Post by: Jumpy on April 26, 2013, 06:32:48 AM
I thougth I read an article (from VisioGuy?) with sth. like a magnification lens or some such. But I can't find it with the search, maybe I just dreamed about it. But if that article realy exists it would have faced a similiar problem.
Title: Re: Screen shot of part of drawing
Post by: AndyW on April 26, 2013, 07:18:21 AM
If your using Win 7 or later, you could always use the windows Snipping Tool.

Alternatively, you could implement your own screen capture using VB. If you need to change grid, layer visibility etc then this is the way I would go.
Title: Re: Screen shot of part of drawing
Post by: JuneTheSecond on April 26, 2013, 12:30:46 PM
Thank you, AndyW.

I forgot Snipping Tool.
It is useful to me.
It may be useful too to Yacine, isn't it?
Title: Re: Screen shot of part of drawing
Post by: Yacine on April 26, 2013, 08:25:20 PM
Thank you for the participation all.
But no, the snipping tool does not help. I use it too, but here I need a tool that can make dynamically snapshots based on coordinates stored in a database.
We are talking about 100 (?) snapshots. And I want to be able to update them automatically, when needed.

I will try the following: export the whole page, open the so saved image, then knowing the coordinates of my rectangle compare the pixel width and height to the actual visio coordinates of both the page and the rectangle, then crop the bitmap accordingly.

I will let you know, when I have worked it out.
Cheers, Yacine.

Title: Re: Screen shot of part of drawing
Post by: vojo on April 27, 2013, 09:29:01 PM
Assume the background is what you want....why not just some screen scrap...I have used MWsnap for 10 years quite nicely for this
Title: Re: Screen shot of part of drawing
Post by: Yacine on April 28, 2013, 10:11:07 AM
Alright, I got it.
Actually it was just a matter of putting together code snippets available over the net.
Here is a setup, that allows you on double click on the red rectangle to save the shapes and images shown inside the rectangle as a PNG bitmap.
The connection to the database is not implemented here, but that should not be a big deal.
One restriction to this solution, is that all shapes need to be within the boundaries of the page, otherwise the formulas will not work properly. By means of more control and correction structures this problem could be overcome.
For now, this solution just provides the basics of what I described earlier as my problem.

As explanation for what I worked out:
Main deal was to understand how the "foreing image info" section works. That is a section that you will only see on imported pictures (??? not sure about the absolute trouth about this !!!)
Just keep im mind, that you can scale your image as you like, but need then to correct the values of ImgWitdth  and ImgHeight to their initial values as Visio will automatically scale them proportionally to the dimensions of the shape.
The offset values depend only on the left and the bottom values of the desired cropping.
There is no more to it.

What you got whit this, is the capability to remote control the screenshots of a drawing ... with automated naming, attached comments (in a DB), animated exploration of the drawing, etc.

Enjoy, Y.

P.S.: By the way, I did find him!
Title: Re: Screen shot of part of drawing
Post by: Yacine on March 05, 2023, 11:08:46 AM
So they (M$) improved Visio again. Now when you insert a big bitmap into a drawing, Visio decreases automatically the resolution so much that it the picture gets useless. Blurry to a level of unreadable.


That is very pity because my snapshot tool based on being able to export the whole drawing as bitmap, re-import and crop it, then save again to get the desired extract of the drawing.
F*/k!


Googling the issue shows that M$ is informed and has no urge to solve the problem.


So I'm again into solving the problem of needing to make snapshots of big (very big) drawings to produce documentations.
The snapshots are meant to be inserted as images in an attachment field in an Access Database.


I don't know if any of you has a solution to this issue. Any hint is welcome.


Clipboard
I then thought about using a snapshot application (in my case Windows' Snipping) and insert the image via the clipboard.
But lost patience.


Web control with pan and zoom
Access offers an ActiveX web control that you can feed with an SVG that you would have exported from your Visio Drawing.
In your access form, you would then present the user this SVG, let him zoom and pan to desired section and only store these coordinates.
Fine and good, but when it comes to printing you'll probably need individual pictures again.


Aaaargh!




(https://i.etsystatic.com/23867923/r/il/60708e/4061950150/il_794xN.4061950150_hcvh.jpg)
Title: Re: Screen shot of part of drawing
Post by: wapperdude on March 05, 2023, 03:03:08 PM
Uh...just what is a "big" bit map image?   What kind of Visio settings...page size, scale factor, hardware settings like screen resolution, etc.

Love the cat!
Title: Re: Screen shot of part of drawing
Post by: Yacine on March 06, 2023, 05:29:34 AM
The image is a "little" big. 40378 x 4495 pixels / 350 dpi / 24 bit color depth / 12 MB.

And the good thing in getting up early, the inspiration muses are still flying. Caught one and got kissed.

I could as well zoom and pan the drawing itself.
I mean, I could change the page width and height to the dimensions of my screenshot shape and move its origin also to this shape.
Then do the export of this newly defined page, but this time only once, without re-import and cropping.

I'll let you know of the results




... 2 hours later.
Using a custom page is a bad idea, because the page sizes are defined by your printers. So you won't get arbitrary aspect ratios when printing.
Exporting all doesn't work neither because it exports also shapes outside the page limits.
This path is death.






New one. "Fragmenting"


You will recall that my issue was to get also the shapes that overlap partially the screenshot frame.
If I select all the shapes to be shown and the screenshot frame, I can then fragment everything, select the inner parts and export.
This works, specially with the undo functionality to revert the fragmented shapes to their original state.
Limitations: It works only with plain shapes. No images, no OLE stuff and the like.




Probably my last and best option - The snipping tool.


1. Make the screenshot. (Snipping will automatically paste the image in the clipboard)
2. Paste the image anywhere in the drawing
3. Switch to access and press a button that will do the following:
a. select the last shape on the drawing (activepage.shapes(activepage.shapes.count)). -- Thinking about it, I may rather select the image. This way I won't delete shapes inadvertently.
b. export to a fixed location and filename (eg activeproject.path & "img.png") and delete this last shape.
c. import the so created image file into the attachment file.


There's no big magic in this solution, but it is a simple and effective workflow.


Disadvantage: No automatic batch screenshots generation (eg generating them from coordinates)




I'm probably closing this topic for now, but you guys are of course welcome to add any crazy ideas.




Thanks so far and cheers,
Yacine

Title: Re: Screen shot of part of drawing
Post by: Yacine on March 06, 2023, 07:05:47 AM
... so much muses flying around ... need to close the office window. ;)
Google search "VBA crop png" throws the following link out. https://stackoverflow.com/questions/50215950/how-to-rotate-crop-scale-flip-an-image#50215951 (https://stackoverflow.com/questions/50215950/how-to-rotate-crop-scale-flip-an-image#50215951)
And among the different transformation functions you get:

Sub imgCrop(inFile As String, outFile As String, left As Long, top As Long, right As Long, bottom As Long)
    Dim Img As Object, IP As Object
    Set IP = CreateObject("WIA.ImageProcess") 'create WIA objects
    Set Img = CreateObject("WIA.ImageFile")
    Img.LoadFile inFile 'load image
    IP.Filters.Add IP.FilterInfos("Crop").filterid 'setup filter
    With IP.Filters(1)
        .Properties("Left") = left
        .Properties("Top") = top
        .Properties("Right") = right
        .Properties("Bottom") = bottom
    End With
    Set Img = IP.Apply(Img) 'apply change
    Img.SaveFile outFile 'save image

End Sub


As I know the dimensions of my screenshot shape, it ought to be easy to determine the dimensions for the cropping.
This solution is way better than the previous one:

Thinking it furthermore, I could also think of solutions without a connected Access DB.
One could put the screenshot shapes on a dedicated layer. Switch them on and off to ones needs.
These shapes could even have props holding a sort key for generating a file number and a title - eg "03_Detail so and so.png".
A macro would then iterate over all these shapes and generate the screenshots.
This workflow is in so far nice, as the set of images can be edited at any time.
A wise thought would be to create a timed folder, so you can manage the export versions.
Title: Re: Screen shot of part of drawing
Post by: wapperdude on March 06, 2023, 07:39:55 AM
...and was is the practical application of thid?  Hmmmm.  Let me rephrase, what is your real world usage?

Title: Re: Screen shot of part of drawing
Post by: Yacine on March 06, 2023, 08:20:38 AM
I draw these P&IDs (process and instrumentation diagrams) of production plants consisting of 1 to about 20 machines.
(We manufacture plants that produce candies of all kinds - https://www.rotzingergroup.com/food-confectionery/confectionery-production (https://www.rotzingergroup.com/food-confectionery/confectionery-production))
The document consists of up to abt. 20 pages.

As part of the documentation we supply a functional specification in which we explain what each part or group of parts does, we show the production paths of the product flow or the paths for cleaning.

To keep it manageable - such a document goes from about 20 to 100 pages - I split the explanations in small snippets consisting of texts in different variations and a picture showing what part of the P&ID I am explaining.

So I have on the left monitor my Visio drawing, on the right my Access database, and travel over all the functional groups of each machine.

I would love to show some examples, but can't for obvious reasons.




I could of course also provide only the coordinates in the drawing, but this doesn't feel right (too lazy).



For a limited group of people, I could set up a Teams meeting and do a small presentation of my "Visio" stuff, including the Functional Specification and Screenshot part. Just let me know. I know you're not so keen in participating in such meetings. I'm offering it nonetheless. ;)
Title: Re: Screen shot of part of drawing
Post by: wapperdude on March 06, 2023, 03:29:25 PM
Ah!  Thank you.  Yeah, no need for proprietary stuff.  The explanation takes this from the vague/abstract to a more concrete visualization.

Obviously, the visualization is incomplete, but 2 thoughts occur, and both avoid using bitmap altogether.  My assumption is that you have a Visio drawing of the entire process, so...
1) might you use layers to identify the various sections that you want to closely focus upon?
      > the layer might be invoked to highlight the topic region on the full diagram
      > there could be a page for each layer for a closer look.
      > connectors that are transitions between "regions" could belong to both
2) use code and spatial neighborhoods.  This is more tricky because the page concept/construct requires specifically define regions.  But, the thought is that you select your focus region, and then spacial neighborhoods would catch the partials that reach out beyond.
3) Ah.  Bonus thought.  Use containers.  The containers would work much the same as the layers.

Anyway, seems like a sweet problem to solve.   :o ;)
Title: Re: Screen shot of part of drawing
Post by: Yacine on March 07, 2023, 06:02:37 AM
Thanks Wapperdude,
The assumption of having Visio does unfortunately not apply to all my "customers". Both the actual customer and my programmers don't necessarily have Visio.
Otherwise I would just pan and zoom on the related shapes that I collect anyway. That would be easy.
Furthermore there is the difficulty that the end product is a PDF. That means that I collect all my text snippets and images and present them in a neat report.
The industry world hasn't switched yet to full electronic documents. There are so many out there still printing their documents.

I thought also using Nikolay's SVG export tool. But haven't advanced enough with it yet.
Title: Re: Screen shot of part of drawing
Post by: wapperdude on March 07, 2023, 06:47:59 AM
Oh the real world.  😲 😞

It did seem like a strange approach, uncharacteristic of what you do.  Yeah.  PDFs are here to stay for awhile longer.
Title: Re: Screen shot of part of drawing
Post by: Surrogate on March 07, 2023, 07:24:58 AM
Quote from: Yacine on March 06, 2023, 05:29:34 AM
The image is a "little" big. 40378 x 4495 pixels / 350 dpi / 24 bit color depth / 12 MB.
WOW !!! How big will it be on paper?
Quote from: Yacine on March 07, 2023, 06:02:37 AM
The industry world hasn't switched yet to full electronic documents. There are so many out there still printing their documents.
Are such documents created for ages? Or do changes happen every day and the document is printed again?
Title: Re: Screen shot of part of drawing
Post by: Yacine on March 07, 2023, 09:14:23 AM
@Surrogate,
The drawing page spans over 12 landscape A3 pages. But it depends on the project. Minimum 2, Max yet 20.

Yes and no. The final document must last as long as the equipment itself (20 - 50 years or more), but on its way to becoming final it goes over several revisions. Concept phase, design, design freeze, electrical design, manufacturing, programming, installation and commissioning. Each phase finds errors or "sub-optimal solutions" ( ;) ) and this requires the docs to be updated.
That is why regenerating all docs in very few and preferably automated steps is essential.
Title: Re: Screen shot of part of drawing
Post by: vojo on March 07, 2023, 03:05:39 PM
why dont you do the following
- screen scrap the area of interest
- paste into a doc
- save the doc to pdf format

For that matter, pdf995 has done a great job of printing to pdf for last 20 years...if you dont want the 3 step recipe

I do the 3 step recipe (for word or ppt) as well as pdf995 (for PDF only) quite regularly 
(pasting native visio drawings just blows up to an error starting in visio 2007).
Title: Re: Screen shot of part of drawing
Post by: Yacine on March 08, 2023, 06:06:18 AM
Hi Vojo,
I need to get the image in an Access database. From there is goes to PDF. The import via clipboard works only with OLE objects, but I need attachments because there may be several images per text.
It is when I tried to convert from Clipboard or from OLE to attachment that I lost patience.

Using any standalone screenshot tool is feasible but because you save the screenshot as file, then switch over to Access retrieve the file, the "writing flow" gets so much interrupted that I'm looking for a faster solution.
Title: Re: Screen shot of part of drawing
Post by: vojo on March 08, 2023, 02:21:55 PM
good luck
Title: Re: Screen shot of part of drawing
Post by: wapperdude on March 08, 2023, 05:43:25 PM
Quote from: Yacine on March 08, 2023, 06:06:18 AM
I need to get the image in an Access database. From there is goes to PDF.

Ok.  I'm not quite getting this bmp thing....and exporting to Access.  Sorry for my being so dense.

I get that there's an issue with size of drawing and if needs to be spread out over multiple pages and then refined into smaller, more detailed pieces, and ultimately rendered to pdf.

For sake of initial argument, why is bmp sent to Access? ....so it can be viewed by all as a stand-alone reference?!?     And then into pdf?  Why not into pdf 1st and just export that?  Apology for my ignorance.

2nd argument... Why the bmp?  Do it all within Visio and then go to PDF.
    > 1) Visio can convert large drawing into multiple pages.  Perhaps this is too arbitrary.? 
    > 2) re-draw to get desired page breaks and utilize off page connectors to maintain page to page flow.
    > 3) re-draw such that top level (1st page) is a more coarse, block diagram view.  Perhaps to fit to just 1 or 2 pages.  Then each block becomes progressively more detailed.  Then hyperlinks can be used to either navigate between the blocks and detailed pages, and/or supplemented with a Table of Contents that links to desired topic/page.


Title: Re: Screen shot of part of drawing
Post by: Yacine on March 08, 2023, 06:40:49 PM
Hi Wapperdude,
I'll try to answer first with some pictures.

1) Here's how such a drawing looks like on the screen. The frames show that the printout spans over several pages.
You might ask, why such a big drawing. That is because all the machines are connected and there are different flow paths depending on the production mode or the cleaning procedure. I do visualize this aspect by highlighting these paths. That wouldn't work with split drawings.
2) The second image shows the input form in Access

The tree on the left is used for navigating all contents and structuring them.

Title: Re: Screen shot of part of drawing
Post by: Yacine on March 08, 2023, 06:45:47 PM
3) Then you have of course the table in Access which holds the data (obviously)
4) And finally from the contents in the table and using Access' great report functions (Sorting, Grouping, Macros, Formatting, etc.) I produce the PDF showing the result. It has different chapters and each one can have a describing text and an image.
Title: Re: Screen shot of part of drawing
Post by: Yacine on March 08, 2023, 06:49:43 PM
Quote from: wapperdude on March 08, 2023, 05:43:25 PM
I get that there's an issue with size of drawing and if needs to be spread out over multiple pages and then refined into smaller, more detailed pieces, and ultimately rendered to pdf.
Right.

Quote from: wapperdude on March 08, 2023, 05:43:25 PM
For sake of initial argument, why is bmp sent to Access? ....so it can be viewed by all as a stand-alone reference?!?     And then into pdf?  Why not into pdf 1st and just export that?
2nd argument... Why the bmp?  Do it all within Visio and then go to PDF.
I need small extracts. Each page contains about 100-200 shapes, representing 10-20 function groups. Showing everything from one page would not help. Otherwise it would be enough to mention that the stuff is on page x.
Sending the drawing to PDF isn't the solution because the main information is the text I write into Access. The picture is optional and only there to help the reader orienting himself in that big drawing.
Why Access at all? Any normal guy would have taken Word for this task. But I'm trying to modularize my descriptions so I can re-use them.

Quote from: wapperdude on March 08, 2023, 05:43:25 PM
    > 1) Visio can convert large drawing into multiple pages.  Perhaps this is too arbitrary.? 
Sure that's what I'm doing already. But the many details on each page...

Quote from: wapperdude on March 08, 2023, 05:43:25 PM
    > 2) re-draw to get desired page breaks and utilize off page connectors to maintain page to page flow.
    > 3) re-draw such that top level (1st page) is a more coarse, block diagram view.  Perhaps to fit to just 1 or 2 pages.  Then each block becomes progressively more detailed.  Then hyperlinks can be used to either navigate between the blocks and detailed pages, and/or supplemented with a Table of Contents that links to desired topic/page.
Not really, the drawing would become too big and illegible.
The Functional Description is also only one use case of the P&ID. There are many other crafts using it. Optimizing it for only the description task, would penalize the other crafts.

I hope this is some how better understandable now?

Title: Re: Screen shot of part of drawing
Post by: wapperdude on March 08, 2023, 07:26:53 PM
Better.  I get the big drawing.  My musing was merely would it be possible to take each page and at the top level, represent it as simply one or two blocks.  Very low detail, just enough to show flow and connectivity.  Thus, the reader gets a feel for the entire process, front to back, on possibly, A single page.  Then, each block can be explored, drilled down into, progressively revealing more detail.  It just seemed the bmp was an unnecessary step and source of much frustration.  So just threw out a variety of ideas to possibly spur some " Ah ha!" consideration. 

Have fun!

Title: Re: Screen shot of part of drawing
Post by: Yacine on March 08, 2023, 07:32:29 PM
That "multi-level expanding/shrinking" idea is very nice, but it would only work if my final product were only digital. Which it isn't (PDF).
If my customers were only "normal" engineers, I could probably get this idea through. Unfortunately there are also pharmaceuts among them and they love paper so much ;) .
Title: Re: Screen shot of part of drawing
Post by: wapperdude on March 08, 2023, 08:24:59 PM
for navigation, hyperlinks work.  The links may be in the blocks, the pages, or even TOC.  i would think the navigation, organization in Visio would translate into the PDF.  I did a 150 pg Visio document detailing a sound system and then published to pdf.  The pdf navigates just fine.