Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
PML-only project file.
This csproj does not compile any code or produce a DLL.
It copies *.pml* files to the appropriate pmllib subdirectory on build.
-->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net481</TargetFramework>
<RootNamespace>PMLMLNetPredictTemplate</RootNamespace>
<AssemblyName>PMLMLNetPredictTemplate</AssemblyName>
<!-- Disable actual compilation - no DLL output -->
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<EnableDefaultItems>false</EnableDefaultItems>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<CopyBuildOutputToOutputDirectory>false</CopyBuildOutputToOutputDirectory>
<CopyOutputSymbolsToOutputDirectory>false</CopyOutputSymbolsToOutputDirectory>
<!-- Suppress warning CS2008: No source files specified (expected for PML-only projects) -->
<!-- Suppress warning CA1016: No binaries are generated as part of building this project -->
<NoWarn>CS2008;CA1016</NoWarn>
</PropertyGroup>

<PropertyGroup>
<!-- Use CUSTOM_PMLLIB environment variable for destination -->
<PmlLibPath Condition="'$(CUSTOM_PMLLIB)' != ''">$(CUSTOM_PMLLIB)</PmlLibPath>
<PmlLibPath Condition="'$(PmlLibPath)' == ''">$(MSBuildProjectDirectory)\..\..\pmllib\</PmlLibPath>
</PropertyGroup>

<!-- Include PML files as None items so they appear in the project -->
<ItemGroup>
<None Include="**\*.pml*" />
</ItemGroup>

<!-- Target to copy PML files to pmllib - runs after Build -->
<Target Name="CopyPmlFiles" AfterTargets="Build">
<Message Importance="high" Text="PML-only project: Copying PML files to $(PmlLibPath)..." />

<!-- Find all *.pml* files in the project directory -->
<ItemGroup>
<PmlFormFiles Include="$(MSBuildProjectDirectory)\*.pmlfrm" />
<PmlObjectFiles Include="$(MSBuildProjectDirectory)\*.pmlobj" />
<PmlFunctionFiles Include="$(MSBuildProjectDirectory)\*.pmlfnc" />
</ItemGroup>

<!-- Copy form files to pmllib\forms -->
<Copy SourceFiles="@(PmlFormFiles)"
DestinationFolder="$(PmlLibPath)forms\"
SkipUnchangedFiles="true"
Condition="'@(PmlFormFiles)' != ''" />
<Message Importance="high" Text=" Copied %(PmlFormFiles.Filename)%(PmlFormFiles.Extension) to $(PmlLibPath)forms\"
Condition="'@(PmlFormFiles)' != ''" />

<!-- Copy object files to pmllib\objects -->
<Copy SourceFiles="@(PmlObjectFiles)"
DestinationFolder="$(PmlLibPath)objects\"
SkipUnchangedFiles="true"
Condition="'@(PmlObjectFiles)' != ''" />
<Message Importance="high" Text=" Copied %(PmlObjectFiles.Filename)%(PmlObjectFiles.Extension) to $(PmlLibPath)objects\"
Condition="'@(PmlObjectFiles)' != ''" />

<!-- Copy function files to pmllib\functions -->
<Copy SourceFiles="@(PmlFunctionFiles)"
DestinationFolder="$(PmlLibPath)functions\"
SkipUnchangedFiles="true"
Condition="'@(PmlFunctionFiles)' != ''" />
<Message Importance="high" Text=" Copied %(PmlFunctionFiles.Filename)%(PmlFunctionFiles.Extension) to $(PmlLibPath)functions\"
Condition="'@(PmlFunctionFiles)' != ''" />

<Message Importance="high" Text="PML file copy complete." />
</Target>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
--------------------------------------------------------------------------------------------------
--
-- (c) Copyright 2024 to Current Year AVEVA Solutions Limited
--
-- File: PMLMLNetPredictTemplate.pmlfnc
-- Author: AVEVA
-- Type:
-- Group:
--
-- Keyword:
-- Module: AVEVA E3D Design
-- Replaces:
--
--
-- Description:
-- Function to get an array of predictions from your ML NET Model
-----------------------------------------------------------------------------------------------------
define function !!PMLMLNetPredictTemplate(!element is dbref) is ARRAY

import 'Aveva.Core3D.Interaction.Generic'
handle (1000, 0)
-- Already imported, safe to ignore
elsehandle any
write /t error.text
-- TODO add sensible error handling
endhandle

using namespace 'Aveva.Core3D.Interaction.Generic.PredictiveGenDAI'

--Import and create an object for the Prediction
!modelName = ''
if (!modelName.empty()) then
!!alert.Message('Pleae update your template code and set modelName.')
return
endif
!predictHelper = object PREDICT(!modelName)
!predictHelper.LoadModel()
!featureList = !predictHelper.GetFeaturesList()

--Add features to your Predict Object
!features = object FEATUREOPTIONS()

-- Repeat for all features you want to include
!featureName = ''
!featureValue = ''
if (!featureName.empty() or !featureValue.empty()) then
!!alert.Message('Please update your template code and set featureName and featureValue.')
return
endif
!features.addFeature(!featureName, !featureValue)

--Assign Features to predict helper to enable predictions
!predictHelper.SetFeatures(!features)

--Get predictions
!predictions = object ARRAY()
!predictions.append(!predictHelper.PredictValue())

return !predictions

endfunction
23 changes: 23 additions & 0 deletions templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Current template folders in this repository:
- NetGridAddInTemplate
- PMLExtensionTemplate
- PMLGridTemplate
- PMLMLNetPredictTemplate

### DockedFormAddInTemplate

Expand Down Expand Up @@ -250,6 +251,28 @@ You need a simple starting point for PML form/grid development and plan to build

**Note:** This template is intentionally minimal compared with docked-form templates.

### PMLMLNetPredictTemplate

**Purpose:** Template for creating ML.NET-based prediction functions callable from PML scripts.

**Description:**
The PMLMLNetPredictTemplate provides a foundation for integrating machine learning predictions into AVEVA Unified Engineering using ML.NET. It includes:

- **PMLMLNetPredictTemplateMethods.cs** - C# implementation of ML.NET prediction logic
- **PMLMLNetPredictTemplate.pmlfnc** - PML function definition file for invoking predictions
- **PMLMLNetPredictTemplate.csproj** - C# project file with ML.NET package references

**Use When:**
You need to integrate trained machine learning models into PML workflows, enabling data-driven predictions and intelligent automation within AVEVA Unified Engineering.

**How to Use:**

```powershell
.\scripts\New-UEAddin.ps1 -AddinName "MyMLPrediction" -Template "PMLMLNetPredictTemplate"
```

**Note:** This template requires ML.NET packages and a trained model file for full functionality.

## Adding New Templates

To add a new template to this directory:
Expand Down
Loading