.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Adding an Update Feature

7 REPLIES 7
Reply
Message 1 of 8
szenert
437 Views, 7 Replies

Adding an Update Feature

I'd like to add an update feature to my customization... either by way of Windows Service, toolbar button or some other way that somebody might know I want to check the release date of the currently used customization DLL and the release date of the DLL stored on a network drive.

The unknown element to me is what needs to happen within AutoCAD... if I have the service/command simply overwrite the old DLL with the new one from the website, will the new customization commands be available right away (I have the DLL location referred in the registry so I don't need to use netload)? Or will I need to restart AutoCAD or run a netload on the new DLL?

I don't know if the update manager built into AutoCAD can be utilized either, so if it can then I would love to know how.

Thanks!
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: szenert

szenert wrote:

> simply overwrite the old DLL with the new one from the website ...

That could be a problem since the DLL may be loaded in AutoCAD and
can't be unloaded or overwritten. Currently I have an EXE in our
programs group under the Start menu that checks to see if AutoCAD is
running and warns of that or does the update work. Unfortunately that
requires the user to remember to run it so ...

On my to-do list is a System Tray application that checks periodically
for updates, pulls them down to a \Stored location when internet usage
is low, then slams them to the install folder when it catches AutoCAD
not running.

Good Luck,

Terry
Message 3 of 8
arcticad
in reply to: szenert

The way I have been handeling this is to check if an update is available then setting a registry key.

When Autocad has closed I can then update the changes. This runs in the background on startup.

You could also just check if autocad is running then run the code.

{code}

Module MyCode

Public _AcadProcessList() As String

Public Sub setAcadEvent()

Dim ProcessList As System.Diagnostics.Process()
Dim Proc As System.Diagnostics.Process

ProcessList = System.Diagnostics.Process.GetProcesses()
Try
For Each Proc In ProcessList
If UCase(CStr(Proc.ProcessName)) = UCase("acad") Then
If Not hasValue(_AcadProcessList, CStr(Proc.Id)) Then
inc(_AcadProcessList)
_AcadProcessList(UBound(_AcadProcessList)) = (CStr(Proc.Id))
Proc.EnableRaisingEvents = True
AddHandler Proc.Exited, AddressOf MyCode.ProcessExited
End If
End If
Next
Catch ex As Exception
End Try
End Sub

Friend Sub ProcessExited(ByVal sender As Object, ByVal e As System.EventArgs)
' Autocad has closed run update code
End Sub


Public Function hasValue(ByVal myArray, ByVal value) As Boolean
Dim item As Object
Dim rtnCheck As Boolean = False
If isValid(myArray) Then
For Each item In myArray
If item = value Then
rtnCheck = True
Exit For
End If
Next
Else
End If
Return rtnCheck

End Function

Sub inc(ByRef aryValue() As String)
' Check if aryay has a substring then add one
If isValid(aryValue) Then
' Don't erase any old information
ReDim Preserve aryValue(aryValue.Length)
Else
ReDim aryValue(0)
End If
End Sub


End Module

{code}
---------------------------



(defun botsbuildbots() (botsbuildbots))
Message 4 of 8
Anonymous
in reply to: szenert

For AutoCAD extension dlls the easiest way to do that is to
create a seperate executable that can perform file coping or
other related updating, and run it when AutoCAD closes.

Have the executable wait until the AutoCAD process has
completely shut down, before it peforms the updating.

You can make the standalone updater generic so it can be
used with any apps that you want to auto-update.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm


wrote in message news:6160955@discussion.autodesk.com...
I'd like to add an update feature to my customization... either by way of
Windows Service, toolbar button or some other way that somebody might know I
want to check the release date of the currently used customization DLL and
the release date of the DLL stored on a network drive. The unknown element
to me is what needs to happen within AutoCAD... if I have the
service/command simply overwrite the old DLL with the new one from the
website, will the new customization commands be available right away (I have
the DLL location referred in the registry so I don't need to use netload)?
Or will I need to restart AutoCAD or run a netload on the new DLL? I don't
know if the update manager built into AutoCAD can be utilized either, so if
it can then I would love to know how. Thanks!
Message 5 of 8
szenert
in reply to: szenert

So it is as I feared, the DLL is in use. I had contemplated making a service that runs under network credentials and checks for new versions when the computer starts and every subsequent 4 hours... I'll just make sure it checks to see if acad is running at the time as arcticad suggested.

Thank you everyone, and have a great day.
Message 6 of 8
Anonymous
in reply to: szenert

I don't know how you've implemented loading the dll into AutoCAD, but here's what I do. Since I use an enterprise CUI, I created a .mnl file that matches the enterprise CUI name. This gets loaded automatically. I wrote the lisp below to solve the update problem. This copies the file from the network and places in a local folder, and then loads it. For updates the user simply has to restart AutoCAD. Obviously it fails to copy if it is loaded, but it still loads it into the current session.

Of course, this tries to load the dll whenever a drawing opens, but since a dll can't be reloaded it doesn't matter. I figure that in this case lisp is the easiest thing to implement, since it bypasses all the credentials and services stuff.

I then wrote this function:
(vl-load-com)
;*****************************Network Netload from local********************************
;Copies files to local folder, and netloads them
;have to vl-load-com
(defun netcopy(companyfoldername networkdll networkdllpath)
;this sticks my dll in the autocad roamable folder
(setq prog (getvar "ROAMABLEROOTPREFIX"))
(setq localcompfolder (strcat prog companyfoldername))
(setq localdll (strcat localcompfolder "\\" networkdll))
(vl-mkdir localcompfolder)
(vl-file-delete localdll)
(vl-file-copy networkdllpath localdll)
(setvar "cmdecho" 0)
(command "netload" localdll)
(setvar "cmdecho" 1)
)

and then I use it here to load the dll I want (or any dll).

(netcopy "PGI AutoCAD" "PGI.dll" "N:\\EngShare\\CAD\\ACADLibrary\\Common\\Custom\\PGI.dll")
Message 7 of 8
szenert
in reply to: szenert

Forgive me, I've never really worked in-depth with LISP, I only have a basic understanding... but this function you're using deletes, recopies and netloads the DLL from a mapped drive every time you start AutoCAD, correct? Putting it in the Enterprise CUI's MNL means it would be happening after the CUIs, partial CUIs, ARX files, session LISP files and document LISP files have loaded... that seems kind of late in the startup process to me but I really don't know, that's one of the aspects of my customization I haven't really tackled yet. What I really don't get is how you can do this without credentials (unless everyone has read/copy access to that location), we limit all access to certain places where I store my customization content and use designated credentials to allow programmatic access.

The way I load the DLLs into AutoCAD is using the registry... if you put a named key in HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R18.0\ACAD-8001:409\Applications with (most notably) a string value called LOADER with the location of the DLL it automatically loads that DLL with AutoCAD... but to be honest, I don't know when that load takes place in the grand 22-step startup sequence that AutoCAD uses. I wanted my customization to be very simple to install, so my installation program basically copies certain customization files to the user's local drive and then writes the registry keys that reference them.

I don't know if I'm really going anywhere with all this... I think I'm just trying to make sense of it while explaining how my customization works in my environment. Thanks for the code though, it's definitely worth considering.
Message 8 of 8
Anonymous
in reply to: szenert

Thankfully, the enterprise cui is one of the first items loaded--before all other cui's at least. I think maybe the acad.rx is loaded before it, but not a whole lot else. I actually use the mnl instead of acaddoc.lsp or acad.lsp, b/c you just never know what other program is going to try to use on their startup. I think AutoCAD MEP was using the acaddoc.lsp in their install, which prompted me to rely solely on the enterprise cui.



I suppose I'm sort of fortunate to only have one server or anything to deal with, I've hard coded my app to only run on our server, so I don't worry about the credentials or anything.



I really think typing the dll to a CUI is the simplest way to go. At some point, you'll have to create the buttons, and stuff to make it easy to launch your commands, and loading from an mnl is automatic if they are using your cui file. If they don't use a cui...they're going to have to memorize all your commands.



I guess the advantage of my method is that you don't need an installation program. If the AutoCAD deployment is created with the enterprise cui path, you have immediate control through your mnl and thus your dll.



The other thing you'll want to do is use an IExtensionApplication interface so that anything you need initialized will be when the program is netloaded.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost