Author Topic: issue with addin and stencils  (Read 6573 times)

0 Members and 1 Guest are viewing this topic.

perry59

  • Full Member
  • ***
  • Posts: 249
issue with addin and stencils
« on: July 26, 2021, 10:24:37 AM »
I have an addin that that I built using Nikolay's awesome template. When it installs it also "publishes" stencils and templates to folders in the addin's directory.
they show up there just fine, but visio is still looking at old directories. I thought "publishing" would set visio's file locations to the addins location.
Is that not the case? How do I get the addin to change visio's file locations to the correct place?
Thanks

JohnGoldsmith

  • Sr. Member
  • ****
  • Posts: 354
    • John Goldsmith's visLog
Re: issue with addin and stencils
« Reply #1 on: July 27, 2021, 10:22:21 AM »
Hi,
These are two independent mechanisms:You should use one or the other but not both (for the same solution).
If your stencils and templates are coming from your install directory and being surfaced in the UI via Publishing, then you can delete those paths from the respective File Locations fields.  Does that work for you?
Using the Publishing route is usually a better option if you're using an installer as it allows you to create language specific versions of your files (only surfacing the correct one for the current language), to separate the physical location of the file from the path that the user sees in the UI.  It also allows for an easier uninstall/update experience as the content files get uninstalled along with the addin.
Does that answer your question?
Best regards
John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

perry59

  • Full Member
  • ***
  • Posts: 249
Re: issue with addin and stencils
« Reply #2 on: July 27, 2021, 11:04:02 AM »
I'm not even sure I understand the answer!
I thought surfacing was something you did with an old bowling ball?
When my installer (Wix based) runs it creates a directory for my application. In that directory is the VSTO file, config file, etc. it also create two subfolders for stencils and templates and does copy the applicable files there.
when visio starts it does not show these templates and stencils in the UI and the paths are not appended to existing paths in options->file locations.
I thought that in the past that the installation did do this, the only thing I remember changing is putting the stencils/templates in their own subfolders rather than dumping them into the applications directory.
I don't think my installer does anything with "path discovery".
Perry

Nikolay

  • Hero Member
  • *****
  • Posts: 1072
    • UnmanagedVisio
Re: issue with addin and stencils
« Reply #3 on: July 27, 2021, 11:23:25 AM »
Quote
when visio starts it does not show these templates and stencils in the UI

There is no need to modify options => file locations. The installer does not touch them (and it is not supposed to, these are considered user settings)
The stencils are registered using component publishing (adding registry entries).
Even if you clear all the fields in the "path" dialog, the installed stencils / templates should still stay available.

If you are not seeing them, that could be another Visio feature - you have "metric" stencils and "imperial" template (or vice versa).
Try naming your stencils the way they end with "<yourname>_m.vssx" or "<yourname>_u.vssx" (add suffix _m or _u depending on the type you want your stencil to show up).

I believe this is a feature of Visio 2013 and above, but may be mistaking.
Probably a warning could be added for the case stencils do not end with _u or _m and Visio 2013 and above is targeted.

Also, you need to specify menu path where you want your stencils to show up, i.e. to surface.
I mean, in the installer, in the <visio:PublishStencil ...> element. If you don't have <visio:PublishStencil> then please add it, this is doing the registration.
Means, the installer does not automatically register all stencils, only those which you register with the construct above. Could look something like this:
Code
<File Name="StencilA_m.vssx">
  <visio:PublishStencil MenuPath="My Solution\Stencil A" />
</File>
If you create a blank project and add stencils directly in the project wizard, it adds this code automatically.
« Last Edit: July 27, 2021, 12:56:50 PM by Nikolay »

perry59

  • Full Member
  • ***
  • Posts: 249
Re: issue with addin and stencils
« Reply #4 on: July 27, 2021, 12:11:12 PM »
my typical publish statement in "product.wxs" looks like this:

<Component>
        <File Name="Components.vss">
          <visio:PublishStencil MenuPath="VisioElectrical\Stencils\Components" />
        </File>
 </Component>

I wonder if the problem my stencils and templates still have the "old" suffix's, i.e. vss instead of vssx?
perhaps I should explicitly open each one and re-save them in the "new" format and edit my wxs file?

Thanks
Perry

Nikolay

  • Hero Member
  • *****
  • Posts: 1072
    • UnmanagedVisio
Re: issue with addin and stencils
« Reply #5 on: July 27, 2021, 12:55:59 PM »
That looks fine.. i would try renaming the file to stencil_m.vss first, this if AFAIK the most common case.

It may be also new template (vstx) vs old stencil (vss).
But basically it "should work" :)

perry59

  • Full Member
  • ***
  • Posts: 249
Re: issue with addin and stencils
« Reply #6 on: July 27, 2021, 01:07:20 PM »
I'll try appending the "_u" to my stencils when I get home tonight and see how that does and let you know in the morning.
Thanks Nikolay!

perry59

  • Full Member
  • ***
  • Posts: 249
Re: issue with addin and stencils
« Reply #7 on: July 27, 2021, 01:30:22 PM »
I played around with this a little at work. One thing I noticed that I did not like is the "_U" shows up when browsing stencils.
it does not do that for the ones installed by microsoft, strange.

Nikolay

  • Hero Member
  • *****
  • Posts: 1072
    • UnmanagedVisio
Re: issue with addin and stencils
« Reply #8 on: July 27, 2021, 03:05:37 PM »
This is because the stencils are not installed. You probably just specified the path in the application settings. That is, it looks like Visio discovers you stencils using "path discovery", not installation / registration.
When you install a stencil, you specify a name for it in menu in the "menu path" parameter.
This name is basically what you should see in the menu ("Components" in the case below, "VisioElectrical" and "Stencils" should become parent menu items)

<visio:PublishStencil MenuPath="VisioElectrical\Stencils\Components" />

To test that installation works properly, I would to clear the "path" Visio settings, so that they are blank.

Please note that the stencils with "_U" will show up if you select "US Units" when creating a diagram; stencils with "_M" will show if you select "Metric Units" when creating a diagram.
« Last Edit: July 27, 2021, 03:15:50 PM by Nikolay »

perry59

  • Full Member
  • ***
  • Posts: 249
Re: issue with addin and stencils
« Reply #9 on: July 27, 2021, 03:20:54 PM »
Ok. I only renamed them, did not do a re-build and re-install. That's probably the problem.
I'll try that when I get home.
Thanks Nikolay!

Nikolay

  • Hero Member
  • *****
  • Posts: 1072
    • UnmanagedVisio
Re: issue with addin and stencils
« Reply #10 on: July 27, 2021, 03:31:12 PM »
I just did some testing, just to show what it looks like in pictures.
The code includes 4 items: two stencils (metric/us), two templates (metric/us)
Code
      <!-- metric stencil -->
      <Component>
        <File Name="Stencil_1_M.vss">
          <visio:PublishStencil MenuPath="Demo Stencil Folder\Subfolder\Stencil 1 (metric)" />
        </File>
      </Component>
      <!-- metric template -->
      <Component>
        <File Name="Template_1_M.vst">
          <visio:PublishTemplate MenuPath="Demo Stencil Folder\Subfolder\Template 1 (metric)" />
        </File>
      </Component>
      <!-- us stencil -->
      <Component>
        <File Name="Stencil_1_U.vss">
          <visio:PublishStencil MenuPath="Demo Stencil Folder\Subfolder\Stencil 1 (US)" />
        </File>
      </Component>
      <!-- us template -->
      <Component>
        <File Name="Template_1_U.vst">
          <visio:PublishTemplate MenuPath="Demo Stencil Folder\Subfolder\Template 1 (US)" />
        </File>
      </Component>

In the templates you have both (according to the menu path, Templates (tab) => Demo Folder => Subfolder =>


If you create a metric diagram like this:


Then in the menu you have metric stencil (ending with "_m"). Note that "_m" is not displayed, instead the content of the "menu path" is displayed.


Note: there is JUST ONE stencil, although two were registered.
If you select a US template, then you'll see the second stencil in the menu.

The demo project is attached (stencils/templates only no addins)

I believe this whole behavior may be even a bug of some sort.
That is, the thing that in Visio 2013 and above in case a registered stencil has neither "_m" nor "_u" suffix it is not displayed by Visio at all.
I would expect such stencils to show in BOTH cases actually, like it worked in Visio 2010 and below.

In Visio itself, all built-in stencils have either _u or _m prefix (starting with version 2013). My path for example: C:\Program Files (x86)\Microsoft Office\root\Office16\Visio Content\1033
They are just registered by alternative names so taht code like "Documents.Open "Basic.vss" works (note that there are other parameters in <PublishStencil> including this "alternate name" as well.
Visio should be able to find stencil if opened from VBA by any of those names (without path)
« Last Edit: July 27, 2021, 03:53:59 PM by Nikolay »

perry59

  • Full Member
  • ***
  • Posts: 249
Re: issue with addin and stencils
« Reply #11 on: July 27, 2021, 03:36:12 PM »
Thanks Nikolay, you da man!
I'll try that out as soon as I can :)

JohnGoldsmith

  • Sr. Member
  • ****
  • Posts: 354
    • John Goldsmith's visLog
Re: issue with addin and stencils
« Reply #12 on: July 28, 2021, 05:39:49 AM »
Glad you're fixed and will try and be clearer next itme :)
Best regards
John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

Paul Herber

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3094
    • Paul Herber's website
Re: issue with addin and stencils
« Reply #13 on: July 28, 2021, 03:43:01 PM »
The naming for stencils using _M for metric and _U for US (Imperial) units goes back to early days, I had Visio 2000 and it was in use then.
P.S. the spec I remember used uppercase M and U, don't know how important that is, but I've always used uppercase.
Electronic and Electrical engineering, business and software stencils and applications for Visio -

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

Paul Herber

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3094
    • Paul Herber's website
Re: issue with addin and stencils
« Reply #14 on: July 28, 2021, 03:45:56 PM »
Code
"Documents.Open "Basic.vss"

Interesting thought, what if another stencil "Basic.vss" gets installed?
Electronic and Electrical engineering, business and software stencils and applications for Visio -

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