There doesn't seem to be anything wrong with the code. The problem lies elsewhere. Possibly the project is reloaded or the scene was deleted invalidating your Scene object.
FWIW, this snippet works fine for me (Xpression Developer v10.0).
private void button2_Click(object sender, EventArgs e)
{
xpEngine engine = new xpEngine();
xpScene scene;
string fontName = "Font1";
if (engine.GetSceneByName("MyScene", out scene) && scene.Project.FontExistsByName(fontName))
{
xpFont font;
scene.Project.GetFontByName(fontName, out font);
fontNameDisplay.Text = font.Name;
}
}
------------------------------
JohnCorigliano
Senior Software Engineer
ISC
------------------------------
Original Message:
Sent: 02-24-2023 14:17
From: Nick
Subject: Scene Object Deleted when calling Scene.Project.FontExistsByName from external API
Any idea why this call seems to force reference to the internal scene object to be lost? I'm writing an external build script for use in Developer/Studio versions of XPression and everything works flawlessly except for this random recurring issue where scene objects seem to lose reference when this specific call is made. I generally avoid making engine calls for things that can be made with scene calls to prevent exceptions being raised when I have more than one project loaded but here it seems almost like this call being made from an external script doesn't have permission to query the available fonts?


------------------------------
Nick Huntley
------------------------------