TheSwamp

Code Red => .NET => Topic started by: Jeff H on March 31, 2017, 01:39:43 AM

Title: Updating Add-ins from server
Post by: Jeff H on March 31, 2017, 01:39:43 AM
I will go more detail in later post if needed but attached is project that should work for 2016 and from description below and looking at code should be able to figure out how it works.

This has worked well for me for everyone getting the latest dlls, cuix, etc..  in an environment where there is a The attachment contains the following folders with short description.
Here is how it works.


How to get it working after download and unziping.


TheSwampAddinLoader.loadconfig
Code: [Select]
<?xml version="1.0" encoding="utf-8" ?>
<AddInLoaderUpdatePath
  UpdateDirectory="%userprofile%\Documents\Visual Studio 2015\Projects\Server Folder\TheSwampApps\v20.1">
</AddInLoaderUpdatePath>
TheSwampAddInLoaderData.loadData
Code: [Select]
<?xml version="1.0" encoding="utf-8" ?>
<AddInLoaderData CopySubDirectories ="false" ExtensionFilter =".dll|.cuix|.mnr">
  <LoadFiles>
     <LoadFile>TheSwampAddin1.dll</LoadFile>
    <LoadFile>TheSwampAddin2.dll</LoadFile>   
  </LoadFiles>
</AddInLoaderData>
Title: Re: Updating Add-ins from server
Post by: MexicanCustard on March 31, 2017, 08:00:38 AM
Nice work Jeff.  I've been working on something similar that uses FileSystemWatcher to look for folder changes then prompts the user. If the user chooses to update, it spins up the updater, and shuts down Autocad.  The updater waits for Autocad to shut down and copies over the files then fires up Autocad again and shuts down.
Title: Re: Updating Add-ins from server
Post by: Jeff H on March 31, 2017, 09:39:40 AM
Nice work Jeff.  I've been working on something similar that uses FileSystemWatcher to look for folder changes then prompts the user. If the user chooses to update, it spins up the updater, and shuts down Autocad.  The updater waits for Autocad to shut down and copies over the files then fires up Autocad again and shuts down.
Thanks,
If it was used for something main stream or commercially available app then would need something like you got.
Title: Re: Updating Add-ins from server
Post by: Atook on March 31, 2017, 01:52:48 PM
Great stuff Jeff, thanks for posting example code and an explanation.
Title: Re: Updating Add-ins from server
Post by: pBe on April 05, 2017, 11:21:28 AM
Hi Jeff H,

Great code, one question though. I change  R20.1 to 19.0...

Code - C#: [Select]
  1. <RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD|AutoCAD*" SeriesMin="R19.0" SeriesMax="R21.0" />

It worked with versions 14,16 and 17 but not with Autocad 2015? Is it just me or there's something else that needs changing?

Thank you in advance.

pBe
Title: Re: Updating Add-ins from server
Post by: Jeff H on April 05, 2017, 12:06:17 PM
Hi Jeff H,

Great code, one question though. I change  R20.1 to 19.0...

Code - C#: [Select]
  1. <RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD|AutoCAD*" SeriesMin="R19.0" SeriesMax="R21.0" />

It worked with versions 14,16 and 17 but not with Autocad 2015? Is it just me or there's something else that needs changing?

Thank you in advance.

pBe
Not sure I had mine broken out into separate folders for each year(also the builds had a separate "Update folder") and below is what I used unmodified. It worked for 2015 and I do not see anything that would need changing. I got 2015 and will try testing it here later today with the attached example.
Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<ApplicationPackage SchemaVersion="1.0" AutodeskProduct="AutoCAD" ProductType="Application" Name="HpadCad" AppVersion="1.0.0" Description="AutoCAD Plug-in" Author="Jeff H" ProductCode="{FF4A6B1C-33C3-7DM3-8F61-423D6048EFA8}">
<CompanyDetails Name="Hpad" Phone=" " Url=" " Email="" />
<Components>
<RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD|AutoCAD*" SeriesMin="R19.0" SeriesMax="R19.0" />
<ComponentEntry AppName="HpadCad.AddinLoader" ModuleName="./Contents/Windows/2013/HpadCad.AddinLoader.dll" LoadOnAutoCADStartup="true"/>
</Components>
<Components>
<RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD|AutoCAD*" SeriesMin="R20.0" SeriesMax="R20.0" />
<ComponentEntry AppName="HpadCad.AddinLoader" ModuleName="./Contents/Windows/2015/HpadCad.AddinLoader.dll" LoadOnAutoCADStartup="true"/>
</Components>
<Components>
<RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD|AutoCAD*" SeriesMin="R20.1" SeriesMax="R20.1" />
<SystemVariables>
<SystemVariable Name="LAYERMAPSTYLE" PrimaryType="String" StorageType="Database" Value="Standard" Flags="Create"/>
</SystemVariables>
<ComponentEntry AppName="HpadCad.AddinLoader" ModuleName="./Contents/Windows/2016/HpadCad.AddinLoader.dll" LoadOnAutoCADStartup="true"/>
</Components>
</ApplicationPackage>
Title: Re: Updating Add-ins from server
Post by: pBe on April 05, 2017, 12:13:10 PM
Thank you for the quick reply Jeff H. I will try this as soon as i get back to the work.

It's beer time :)
Title: Re: Updating Add-ins from server
Post by: pBe on April 06, 2017, 06:00:33 AM
I'm still not getting why plugins skips 2015, it reads the XML but doesn't load the DLL.

Can you give it a try with the attached test bundle from ADN DevBlog. It runs on all versions except 2015.

..
Command: RunMeFirst
Unknown command "RUNMEFIRST".  Press F1 for help.
..

while the rest has [ 14, 16 and 17 ]
..
Command: RunMeFirst
Hello World
..

Any ideas?
Title: Re: Updating Add-ins from server
Post by: Jeff H on April 06, 2017, 09:29:17 AM
I thought I had 2015 installed but I must of un-installed it.
For 2015 I think it should be
Code: [Select]
SeriesMin="R20.0" SeriesMax="R20.0"
Title: Re: Updating Add-ins from server
Post by: pBe on April 06, 2017, 03:07:49 PM
Jeff H,

I installed a fresh copy of Autocad 2015 on a my home computer , and what do you know, "THESWAMP" appeared on the on the Ribbon Panel. Close 2015 and restart 2015. Its still there.

I then launch Autocad 2017 and it works as expected. Yipee!!!

But wait..

Start Autocad 2015 again... gone... and the only hint i got is the "Beep" sound

Code - C#: [Select]
  1.         public void Initialize()
  2.         {
  3.             try
  4.             {
  5.                 Loader load = new Loader();
  6.                 load.Load();
  7.             }
  8.             catch (Exception)
  9.             {
  10.                 Console.Beep();  /// <--- This beep not the one on the ExtensionApplication Class
  11.                 throw;
  12.             }
  13.         }

What do you make of it?
Title: Re: Updating Add-ins from server
Post by: Jeff H on April 06, 2017, 03:52:39 PM
Did you have 2017 and 2015 open at same time?
I have not had problems having multiple instances of acad open same or different year, but the versions had separate folders and addinloaders.
 
Title: Re: Updating Add-ins from server
Post by: pBe on April 07, 2017, 02:29:56 PM
Not at the same time, I did create two sets of addinloaders [  2015/2017 ] but still no joy. still hearing the beep which means it recognize the xml.

It appears that both TheSwampAddinLoader.dll and TheSwampAddin1.dll did not finish its task. The cuix wasnt loaded and the files are not copied, also Unknown command "THESWAMP".  Press F1 for help.

The thing that gets me is it works on 14 , 16 and 17 using just one set of dlls. Were you able to test 2015 on your end?

Thanks
Title: Re: Updating Add-ins from server
Post by: Jeff H on April 10, 2017, 09:48:00 AM
I did use it for 2015, but uninstalled it. I am confrused also why its not working.
Title: Re: Updating Add-ins from server
Post by: pBe on April 10, 2017, 01:14:36 PM
I ended up using this for Autocad 20105
Code - Auto/Visual Lisp: [Select]
  1. <RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD|AutoCAD*" SeriesMin="R20.0" SeriesMax="R20.0" />
  2.     <ComponentEntry AppName="Appname" " ModuleName="./Contents/Resources/Company.lsp" PerDocument="True" LoadOnAutoCADStartup="true" LoadOnCommandInvocation="True"/>
  3.    <ComponentEntry AppName=""Appname"  ModuleName="./Contents/Resources/2015/Company.cuix" AppDescription="Company CuiX"  AppType="CuiX"/>  

But it does not copy/update files from the Server Folder like it does for 2017. I'm not even sure loading a partial cuix from XML is a good thing.

Sure hope you anyhone can come up with an answer on why TheSwamp Loader is not working om 2015.

Question for you: Can we call an EXE file from the PackageContents.xml?

BTW: Thank for all your help.

EDIT: Makes me wonder did it ever worked on 2015 as i mentioned on the other post. I wanted it to work so bad that i imagined it working the first time
Title: Re: Updating Add-ins from server
Post by: Jeff H on April 10, 2017, 02:17:45 PM
I ended up using this for Autocad 20105
Code - Auto/Visual Lisp: [Select]
  1. <RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD|AutoCAD*" SeriesMin="R20.0" SeriesMax="R20.0" />
  2.     <ComponentEntry AppName="Appname" " ModuleName="./Contents/Resources/Company.lsp" PerDocument="True" LoadOnAutoCADStartup="true" LoadOnCommandInvocation="True"/>
  3.    <ComponentEntry AppName=""Appname"  ModuleName="./Contents/Resources/2015/Company.cuix" AppDescription="Company CuiX"  AppType="CuiX"/>  

But it does not copy/update files from the Server Folder like it does for 2017. I'm not even sure loading a partial cuix from XML is a good thing.

Sure hope you anyhone can come up with an answer on why TheSwamp Loader is not working om 2015.

Question for you: Can we call an EXE file from the PackageContents.xml?

BTW: Thank for all your help.

EDIT: Makes me wonder did it ever worked on 2015 as i mentioned on the other post. I wanted it to work so bad that i imagined it working the first time
I know I used it on 2015 for months. I will see if I can find a copy of 2015 to try it on.
Title: Re: Updating Add-ins from server
Post by: Jeff H on April 12, 2017, 03:00:42 PM
Someone here has 2015 on their computer and will test it when they leave today.
Title: Re: Updating Add-ins from server
Post by: Jeff H on April 13, 2017, 01:15:05 PM
I tested on two different Windows 7 machines with AutoCAD 2015 and worked fine.
Attached is zip file where Projects folder is in Documents folder of user.

You could also edit the catch block print out the exception message and see what it is.
Title: Re: Updating Add-ins from server
Post by: pBe on April 14, 2017, 04:20:49 AM
... You could also edit the catch block print out the exception message and see what it is.

Now why didn't i think of that before. Using Windows 10 and Autocad 2015

Here is the error message Jeff_H, thank you for your patience.

Object reference not set to an instance of an object

Works on Autocad 2017 on the same machine.
Title: Re: Updating Add-ins from server
Post by: Jeff H on April 14, 2017, 10:55:36 AM
... You could also edit the catch block print out the exception message and see what it is.

Now why didn't i think of that before. Using Windows 10 and Autocad 2015

Here is the error message Jeff_H, thank you for your patience.

Object reference not set to an instance of an object

Works on Autocad 2017 on the same machine.
I know I used on a machine with windows 10 for 2015 also.

Can you tell which object is null?
That will definitely narrow down and figure out what is going on.
Title: Re: Updating Add-ins from server
Post by: pBe on April 14, 2017, 11:44:43 AM
Thank you Jeff H

Here's what i did

Code - C#: [Select]
  1.                 public Loader()
  2.         {
  3.                 _ed = Application.DocumentManager.MdiActiveDocument.Editor;
  4.                 _netLoaderDirectoryPath = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
  5.                 System.Windows.Forms.MessageBox.Show("Loader " + _netLoaderDirectoryPath.ToString());
  6.         }

Shows path on 2017
Shows error on 2015 and skipped the first MessageBox

Hope this makes sense.

Thank you for looking into this

EDIT: I think it never got passed _ed

Code - C#: [Select]
  1.             _ed = Application.DocumentManager.MdiActiveDocument.Editor;
  2.             System.Windows.Forms.MessageBox.Show(_ed.ToString());                      
  3.             _netLoaderDirectoryPath = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
Title: Re: Updating Add-ins from server
Post by: Jeff H on April 14, 2017, 08:58:37 PM
Try this one on 2015 only and see what the messagebox displays

Title: Re: Updating Add-ins from server
Post by: pBe on April 15, 2017, 02:42:34 AM
Jeff H

Good day to you.

I'm using Visual Studio 2015 / Windows 10 / Autocad 2015.

I copied the files/folders as shown on post #1. Launch Autocad 2015, no message box, no  beep but files were copied. 
Edit the TheSwampAddin1 and update, same result

I now rebuild the whole solution and replace files on the bundle folder, Launch Autocad 2015, It shows the same error as the previous post for 2015 and a beep.

Run Autocad 2017 the first time since i replaced the files from project.zip, the files were copied and cuix loaded.

I then edited the PackageContents.xml contents and replace TheSwampAddin1.dll with of TheSwampAddinLoader.dll. and manually copied the cuix files to .\Autodesk\ApplicationPlugins\TheSwamp.AddinLoader.bundle\Contents\Windows\2016

Code - Auto/Visual Lisp: [Select]
  1. <ComponentEntry LoadOnAutoCADStartup="true" ModuleName="./Contents/Windows/2016/TheSwampAddin1.dll" AppName="TheSwampAddinLoader"/>

The cuix loaded on 2015 and 2017. it appears the Loader class is having an issue with 2015 and/or Windows 10. Not really sure whats happening kind sir.

Thank you
Title: Re: Updating Add-ins from server
Post by: pBe on July 15, 2019, 03:25:28 PM
Hi Jeff,

Is there a version of this for Revit?

Title: Re: Updating Add-ins from server
Post by: Jeff H on July 15, 2019, 03:43:03 PM
I never built one for Revit.

Title: Re: Updating Add-ins from server
Post by: pBe on July 19, 2019, 07:14:58 AM
No worries Jeff H. I will try to configure it to work with Revit. Thanks for all your help .