Common Background

Started by PiP, April 27, 2019, 01:31:17 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

PiP

Hello again,

What is the best way to organise / arrange a set of visio drawings that will sit across several files (say as a result of being created by different users) such that they all reference the same background diagram?

Regards,

PiP

Nikolay

Hallo PiP,

What do you mean by "background diagram"?
In principle, Visio has templates. You can make one, and tell others to use it as a starting point.. or?

Paul Herber

There can only be background pages.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

PiP

Apologies, my wording maybe not useful.

If I have multiple users all using a particular background across multiple files, and I want to make a change to that background do I need to edit each file individually to get that change to take effect for each of the files, or is there someway to have the background file as a separate single entity (file) that is referenced by all the other files such that they inherit any changes as they are made?

vojo

means that you have to update each file because background pages are tied to the file.
(visio doesn't have any sort of "inheritance" among drawing files...nothing like C++ or Python classes).
(only sort of like "inheritance" is stencil constructs).

Now you could do this (still have to edit each file, but shifts some of the work to users).
- make your background page a group of shapes
    - Set behavior to group only
    - Set protections to prevent different types of edits
    (these two settings will prevent the user from editing the background group by mistake)
- put in a stencil
-in each file, add that stencil to the stencil list
- pull background group shape
- place it on the sheet and use layers to put "behind" everything else

You could probably automate this with VBA if you want to dig in

Future changes should get reflected in the new stencil...so when each user opens, he can replace it.

PiP

Thanks Vojo. 

I'll have a think about what that means and how much effort and complexity I want to commit to to otherwise automate.

Yacine

You could try to insert the common drawing as OLE object on the background page.
But in general this whole concept looks quite fragile.
Yacine

Nikolay

Quote from: PiP on April 28, 2019, 03:44:33 AM
If I have multiple users all using a particular background across multiple files, and I want to make a change to that background do I need to edit each file individually to get that change to take effect for each of the files, or is there someway to have the background file as a separate single entity (file) that is referenced by all the other files such that they inherit any changes as they are made?

Do you want to keep consistency of diagrams across your organization (like providing a company logo on diagrams, or a specific brand background, or a specific color palette)?
If so, Visio templates is that tool that was specifically designed to support these sort of things. You just need to create a specific template and tell your users to use it.
Visio even offers some admin configuration to facilitate organization-specific templates, so that user see them when they start the app.

But this is all good if you start from scratch. What if what you already have is a "mess"? The optimal strategy would depend on how big it is.
If it a dozen of diagrams, just go and fix them manually. If there are hundreds, it'll be faster to make a script (vbscript, powershell, c#, or even python - Visio supports basically any scripting by exposing it's COM API, which is supported by most of script engines available on windows)

Visio Guy

Just as some background: I believe AutoCAD had some sort of "XREF" feature that let you reference other drawings as, say, backgrounds for various files.

Visio simply doesn't have that kind of feature...other than the OLE linked/embedded object that Yacine mentioned. I also don't trust OLE linking, but it is pretty cool when it works! I think it would make load times very slow, and might not be worth the effort.

I think the best way to handle it would be to periodically generate background bitmaps or metafiles from the "background source diagrams", then figure out which drawings in your employee library need to be updated with which backgrounds.

For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Hey Ken

PiP:

   Maybe this is too simple a solution or maybe you don't want macros, but you could add a macro to simply replace the background image every time someone opens the drawing.  See sample code below to be saved in every document's ThisDocument module.  It assumes your background page already exists.  You'll need to replace the value for YourPicture with the fully-qualified path and file name of your background picture (stored locally or on the web) , and change YourBackgroundPageName to the proper, pre-existing background page name.

   Missing from the example is scaling of the final picture, if you need to; it assumes that the picture stretches to cover the entire page.  Also missing is error handling in case the picture file or background page doesn't exist.  In that case you can change the code to just leave the existing background intact.

   Hope this helps,

   - Ken





Option Explicit

Sub Document_DocumentOpened(ByVal doc As IVDocument)

Const YourBackgroundPageName = "Dynamic Background"
Const YourPicture = "C:\Wherever\Interesting Isometric Shape.png"

Dim BackgroundPage  As Page
Dim ImportedPicture As Shape
Dim TheShape        As Shape
Dim I               As Integer

' Point to the background page
Set BackgroundPage = ActiveDocument.Pages.Item(YourBackgroundPageName)

' Delete existing picture(s) on the background page
For I = BackgroundPage.Shapes.Count To 1 Step -1
    Set TheShape = BackgroundPage.Shapes(I)
    TheShape.Delete
    Next I

' Import new picture
Set ImportedPicture = ActiveWindow.Page.Import(YourPicture)

' Scale it to fit entire page
ImportedPicture.Cells("Height").Formula = BackgroundPage.PageSheet.Cells("PageHeight").Result(0)
ImportedPicture.Cells("Width").Formula = BackgroundPage.PageSheet.Cells("PageWidth").Result(0)

' Display first page in file
ActiveWindow.Page = ActiveDocument.Pages.Item(1)

End Sub


Ken V. Krawchuk
Author
No Dogs on Mars - A Starship Story
http://astarshipstory.com

PiP

All, a genuine thanks for taking the time respond - I am pretty well satisfied that I wasn't missing an important feature of visio, and yes, it was the xref feature of autocad that got me thinking along these lines (but even that in its basic form, as I understand it, is a manual pull by the user not a push by the admin). 

I'll get my head into the vba code and try to make some sense of it all, particularly given you've made the effort to present.

Regards,

PiP