EKL Language Support (Cursor/VS Code)
This extension provides syntax highlighting and basic language configuration for Dassault Systèmes EKL scripts and rules.
Features
- File associations:
*.ekl , .CATRule , and generic CAT rule files *.CAT*
- Syntax highlighting for:
- Keywords:
let , set , function , returns , for , while , if , else , return , include , exit , exitfunction
- EKL types:
VPMReference , AdvisorParameterSet , DTSheetType , List , String , Integer , Real , Boolean , Map , HTTPClient , DataTreeNode , KWETuple , ValuePointer , and common DS geometry (e.g., Hole , Surface , Curve , Line , Point , Plane , Body )
- Constants:
TRUE , FALSE , NULL
- Operators:
:: , -> , == , <> , <= , >= , < , > , = , + , - , * , / , % , & , | , ! , ^ , ~
- Numbers and units: e.g.
5 mm , 10deg , 2.5 s
- Strings with escapes
- Single-line
// and block /* */ comments
Language constructs
Variable declaration (let)
- Single variable with type:
Let a(Integer)
Let s(String)
Let p(Point)
- Multiple variables of the same type (client side):
Let a,b,c,d(Integer)
Let l(List)
a = 1
b = 2
c = 3
d = 4
l.Append(a)
- Initialization with constants (not formulas):
Let x = 5 mm
Let a(Integer)
if a == 2
{
Let b(Integer)
b = a + 10
}
Typed access and reassignment (set)
- Convert/cast a variable to a compatible subtype and access attributes:
Let y(Hole)
Set y = x
if (y <> NULL) Message("Hole diameter is #", y.Diameter)
- If the value is not compatible,
Set yields NULL .
Persistent parameters and pointers
ValuePointer gives access to persistent parameter metadata:
Let vp(ValuePointer)
vp.ValuatePointer(Length.1, "", "Length")
// or
vp.ValuatePointer(PartBody\Point.1, "X", "Length")
vp.Delete() // delete a user persistent parameter
- Helper APIs highlighted:
GetAttributeValuePointer , ListAttributesValuePointers , AuthorizedValues , ValuatePointer , Delete .
Parameter paths
- EKL parameter paths use backslashes to navigate into features/attributes:
if PartBody\Hole.1\Diameter > 5 mm
{
PartBody\Hole.1\Activity = FALSE
}
Control flow and functions
Function Foo(n(Integer)) Returns Integer
{
if n == 0 { exitfunction }
return n + 1
}
include "MyLib"
Let i(Integer)
if i == 0 { exit }
Notify("Result:: #", MyLib::Foo(1))
Examples
Query parameter sets and export to CSV
Let roots(List)
roots = GetEditorRoots("VPMReference")
if(roots.Size() <> 1) { Notify("Select exactly one node"); return }
Let ref(VPMReference)
Set ref = roots->GetItem(1)
Let sh(DTSheetType)
Let path(String)
path = "C:\\Temp\\" + ref.V_Name + ".csv"
Set sh = CreateSheet(path)
if(sh == NULL) { return }
// headers
sh->SetCell(1,1,"Name")
sh->SetCell(1,2,"ID")
// values
sh->SetCell(2,1, ref.V_Name)
sh->SetCell(2,2, ref.PLM_ExternalID)
// read parameter by name across sets
Function ReadParam(r(VPMReference), p(String)) Returns String
{
Let sets(List)
sets = r->Query("AdvisorParameterSet", "")
Let s(Integer)
s = 1
for s while s<=sets.Size()
{
Let aps(AdvisorParameterSet)
Set aps = sets->GetItem(s)
Let names(List)
names = aps.ListAttributesValuePointers("")
Let params(List)
params = aps.Parameters
Let i(Integer)
i = 1
for i while i<=params.Size()
{
if(i<=names.Size() AND names.GetItem(i) == p) { return params.GetItem(i) }
i = i + 1
}
s = s + 1
}
return ""
}
Installation
- Build a VSIX: run
vsce package in this folder, then install the VSIX in Cursor/VS Code.
- Or copy the
ekl.tmLanguage.json and language-configuration.json into a custom extension skeleton.
File associations
The extension declares:
- Extensions:
.ekl , .CATRule
- Filename patterns:
*.CAT*
If a file opens with the wrong language mode, switch it via the status bar (Select Language Mode → EKL).
Troubleshooting
- After installing or updating the extension, reload the window: Command Palette → “Developer: Reload Window”.
- If highlighting looks incomplete, ensure you’re using the latest VSIX and that the file’s language mode is EKL.
License
MIT © 2025 kei4
Repository
https://github.com/kaessajidi/ekl-syntax
| |