Hello Team,
I am developing an Engineering Base (EB) SDK Plug-in in C# to automate the generation of Valve GAD (General Arrangement Drawings) using Excel data.
The plug-in currently:
Reads data from an Excel file (GAD details_1.xlsx)
Copies the Valves2 Visio template from Templates → Sheets → Others into the Documents folder
Successfully creates a new document (e.g., “GAD_54345”)
However, when I open the generated document, the Visio drawing is blank — no Excel data appears inside the copied sheet.
⚙️ Setup Details
EB Version: Engineering Base 2025 (Plant Engineering)
Language: C# (.NET Framework 4.8)
SDK Namespace: Aucotec.EngineeringBase.Client.Runtime
Goal: Automatically fill the Visio GAD drawing (Valves2) with valve data (e.g., Size, Weight, Tag No, Design Temp, etc.)
Excel File: GAD details_1.xlsx
Sheet: Sizing details_Content
Header Row: 5
Data Row: 6 (for testing single valve record)
Visio Template: Valves2 (contains standard text fields like “SIZE”, “Approx. Wt.Kg”, “Design Temp”, etc.)
✅ What Works
Excel data reading (via Microsoft.Office.Interop.Excel) works perfectly.
The Valves2 template is found and copied into the Documents folder successfully.
The new document appears under the project (shows “successfully created” message).
❌ What Doesn’t Work
When I open the new Visio sheet, it is completely empty/blank.
The Excel values (e.g., Tag No, Size, etc.)
do not appear anywhere in the Visio drawing.
Even basic operations like shape.Text = "54345"; don’t show any visible changes.
🔍 What I Have Tried
Used placeholders like {SIZE}, {TagNo}, etc., inside the Visio template.
Tried to access the active Visio page via:
Visio.Application visioApp = (Visio.Application)Marshal.GetActiveObject("Visio.Application");
Visio.Page page = visioApp.ActivePage;
Verified Excel read logic (values load correctly).
Confirmed that the Valves2 template works when opened manually.
Attempted shape traversal using:
foreach (Visio.Shape s in page.Shapes)
s.Text = s.Text.Replace("{TagNo}", "54345");
🧩 Goal
Automate the creation of multiple GAD drawings from Excel —
each row in Excel corresponds to one new drawing with its valve parameters filled automatically.
✅ Expected Outcome:
After running the plug-in, the copied “Valves2” sheet in Documents should automatically fill with the correct Excel data (e.g., Size, Weight, Tag No, Valve Type, etc.) directly visible on the Visio sheet.
Thank you for your support!
I look forward to your guidance on the correct SDK workflow or API methods for writing Excel data into Visio drawings within Engineering Base 2025.
If anyone could help me to resolve and complete this project, it would be very helpful.
For any further information, you can contact me at:
📧
This email address is being protected from spambots. You need JavaScript enabled to view it.
Kind regards,
Darshan Garagatti
MY CODE C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;
using Visio = Microsoft.Office.Interop.Visio;
using EBClient = Aucotec.EngineeringBase.Client.Runtime;
namespace EB_ValveGAD
{
[System.AddIn.AddIn("ValveGAD_Generator",
Description = "Imports Excel data and fills placeholders on Valves2 Visio sheet",
Publisher = "Darshan Garagatti")]
public class ValveGAD_Generator : EBClient.PlugInWizard
{
public override void Run(EBClient.Application app)
{
try
{
// --- 1. Get project ---
var selected = app.Selection.Cast<EBClient.ObjectItem>().FirstOrDefault();
if (selected == null || selected.Project == null)
{
MessageBox.Show("Please select any object inside your project.");
return;
}
var project = selected.Project;
// --- 2. Excel path ---
string excelPath = @"C:\EBData\GAD details_1.xlsx";
if (!System.IO.File.Exists(excelPath))
{
MessageBox.Show($"Excel not found at {excelPath}");
return;
}
// --- 3. Read Excel (row 6) ---
var data = ReadExcel(excelPath, "Sizing details_Content", 5, 6);
// --- 4. Copy Valves2 to Documents ---
EBClient.ObjectItem templates = GetChild(project, "Templates");
EBClient.ObjectItem sheets = GetChild(templates, "Sheets");
EBClient.ObjectItem others = GetChild(sheets, "Others");
EBClient.ObjectItem valves2 = GetChild(others, "Valves2");
EBClient.ObjectItem docs = GetChild(project, "Documents");
EBClient.ObjectItem newSheet = valves2.CopyTo(docs, true);
newSheet.Store();
string tagNo = data.ContainsKey("{TagNo}") ? data["{TagNo}"] : "Unknown";
MessageBox.Show($"Copied Valves2 as new sheet 'GAD_{tagNo}'.\n\nNow filling data in Visio...");
// --- 5. Replace placeholders in Visio ---
Visio.Application visio = TryGetVisio();
if (visio == null)
{
MessageBox.Show("Please open the new sheet in Visio first, then run
plugin again.");
return;
}
Visio.Page page = visio.ActivePage;
if (page == null)
{
MessageBox.Show("No active Visio page found.");
return;
}
ReplaceText(page, data);
MessageBox.Show($"✅ GAD_{tagNo} filled successfully!");
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}
}
// ---------- Helpers ----------
private static EBClient.ObjectItem GetChild(EBClient.ObjectItem parent, string name)
{
if (parent == null) return null;
foreach (EBClient.ObjectItem child in parent.Children)
if (child.Name.Equals(name, StringComparison.OrdinalIgnoreCase))
return child;
return null;
}
private static Dictionary<string, string> ReadExcel(string path, string sheetName, int headerRow, int dataRow)
{
var result = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Excel.Application app = new Excel.Application();
Excel.
Workbook wb = app.
Workbooks.Open(path);
Excel.
Worksheet ws;
try { ws = wb.Sheets[sheetName]; } catch { wb.Close(false); app.Quit(); return result; }
int cols = ws.UsedRange.Columns.Count;
for (int c = 1; c <= cols; c++)
{
string key = Convert.ToString(ws.Cells[headerRow, c].Value2);
string val = Convert.ToString(ws.Cells[dataRow, c].Value2);
if (!string.IsNullOrWhiteSpace(key))
result["{" + key.Trim() + "}"] = val?.Trim() ?? "";
}
wb.Close(false);
app.Quit();
Marshal.ReleaseComObject(wb);
Marshal.ReleaseComObject(app);
return result;
}
private static Visio.Application TryGetVisio()
{
try { return (Visio.Application)Marshal.GetActiveObject("Visio.Application"); }
catch { return null; }
}
private static void ReplaceText(Visio.Page page, Dictionary<string, string> map)
{
foreach (Visio.Shape s in page.Shapes)
ReplaceRecursive(s, map);
}
private static void ReplaceRecursive(Visio.Shape shape, Dictionary<string, string> map)
{
try
{
if (!string.IsNullOrWhiteSpace(shape.Text))
{
string t = shape.Text;
foreach (var kv in map)
t = t.Replace(kv.Key, kv.Value);
shape.Text = t;
}
foreach (Visio.Shape sub in shape.Shapes)
ReplaceRecursive(sub, map);
}
catch { }
}
}
}