Custom Component Depoloyment (ESRI) – better to use TARGETDIR

I think ESRI may be wrong on how to properly set up a custom installer for your custom dll’s for ArcMap etc.

How to deploy a custom component using a setup project

 

custom install

 

It’s basically implying that you should use:

[ProgramFilesFolder]\[ProductName]\bin\foo.dll

Which translates to soemthing like “C:\Program Files(x86)\MyCompany\bin\foo.dll”

But this may not always be true, what happens when your user wants to install to a custom installation directory?  The ESRIRegAsm.exe tool will always fire against – C:\Program Files(x86)\MyCompany\bin\foo.dll, and not where the user selected to install! – it’s basically hard wired so that means your customers could have problems trying to install your software.  It’s better to use:

[TARGETDIR]foo.dll

Which is basically the value you get back from this stage in the installation process (although it’s not very clear as you don’t see that as a variable in the properties window for this stage!):

install folder

 

This will then run ESRIRegAsm.exe against where the user decided to install your dll’s, properly installing the dlls into ArcMap etc.  This is, I believe more foolproof.  However if I have got this wrong, I’m happy to be proved wrong 🙂

Advertisements

Null value gotcha for Field Calculator in Python

I had a problem trying to do a field calculation with field values that had <Null> ‘s.  You need to convert these to strings first apparently!!  Read below!

When Calculate Field evaluates your expression, it looks for null values and if any are found, the expression is not evaluated. This prevents divide-by-zero errors and other undefined operations.

If your field contains null values, you need to turn it into a string (using str()) in the expression, even if it’s already a string field e.g

str(!FooField!)

Plus, if you want to return a null value back to the cell, then just return “None” – without quotes 🙂

Get rid of connections to SDE

When running a script sometimes you can get an error, especially when trying to delete a featureclass – something like:

 

ExecuteError: ERROR 000601: Cannot delete Database Connections\foo.sde\foo.barfc.  May be locked by another application.

 

Use the following to get rid of any SDE connections:

arcpy.ClearWorkspaceCache_management()

 

Where ArcGIS 10.1 stores sde files

Want to know where ArcGIS stores the *.sde files, then look below:

 

In Windows XP they were here:
C:\Documents and Settings\username\Application Data\ESRI\ArcCatalog

In Windows 7 they are here:
C:\Users\username\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog

If not there, try here:
C:\Users\username\AppData\Local\ESRI\Desktop10.0\ArcCatalog