UDD Script Libraries

Base classes and data files shared between similar UDDs can be organized to reuse the code in a better way. All script-library and other support files need to be in a Lib sub-directory under the UserDefinedDefinitions directory. Any .py files found in such Lib directories are ignored and not displayed in the GUI as a valid UDD choice. For a UDD script at any given directory depth, all Lib directories in its parent directories will be automatically added to the system include path (and so, any support script files from any Lib directory through the top level UserDefinedDefintions directory can be imported).

The UDD functionality uses IronPython so we have access to all the .NET assembles. If needed, any subset of the UDD functionality can be implemented in any .NET language and used by the UDD script. There are simple rules to follow to achieve this.

  1. Build your .NET assembly for .NET 2.0 runtime.
  2. Drop the built assembly in any Lib directory upstream of the UDD script location: that is, if you have your UDD script in C:\Users\x\PersonalLib\UserDefinedDefintions\a\b\c\myudd.py and have a .NET assembly called com.Acme.UDDLib You can keep the .NET assembly under:
    • UserDefinedDefintions\Lib
    • UserDefinedDefintions\a\Lib
    • UserDefinedDefintions\a\b\Lib
    • UserDefinedDefintions\a\b\c\Lib
  3. Add the following lines to your Python script:
    • Import clr
    • clr.AddReference("com.Acme.UDDLib")
    • import com.Acme.UDDLib -or- from com.Acme.UDDLib import * etc

If for some reason you cannot place the .NET assemblies into a Lib directory under UserDefinedDefintions, you need to do a couple more steps before step 3 listed above:

Related Topics:

User Defined Documents: Python Script API