General XMetaL Discussion
ghkrause March 10, 2009 at 10:51 pm
XMAX and XFT via CTMMarch 10, 2009 at 10:51 pmParticipants 1Replies 2Last Activity 13 years, 8 months ago
We use XMetaL Author EE 5.1 and XMAX 5.1.
We use XFT files via
in CTM file successfully in both applications.
We want to trigger an XFT form when a specific element is inserted and got this running with XMetaL Author using this code in CTM file:
Selection.InsertElement( “q-physicalsymbol” );
var dlg = ActiveDocument.Host.CreateFormDlg( “q-physicalsymbol.xft”, ActiveDocument.Range.ContainerNode );
dlg = null;
Note: The XFT file needs to be located in Application.Path of XMetaL Author to be opened successfully.
This code triggers an errors in XMAX:
XFRunner: Can not open file “q-physicalsymbol.xft”.
Run-Time Error: Line 4, Column 10, Description: 'dlg' is null or not an object
The XFT file is part of the XAC file created for XMAX.
The same XFT file opens fine in XMAX for exisiting elements via
You may already guess my question: Where to place the XFT file or how to address the XFT file.
Your help is appreciated.Derek Read March 13, 2009 at 7:37 pm
Reply to: XMAX and XFT via CTMMarch 13, 2009 at 7:37 pm
XMAX does not know where it is installed because what that really means to most people is where the location of the application hosting XMAX. For example, if you have embedded XMAX in an HTML page being hosted in IE, or in a VB application, etc, telling you where the xmcontrol.dll itself is located on your machine is typically not much use, nor would you care where iexplore.exe is. I mention this because one solution for XMetaL Author in this case is to place your XFT files into a folder and then reference them using something like [code]Application.Path + “\Forms\myfile.xft”[/code]
There is no Application object for XMAX (like XMetaL Author has) because that is something we expect the hosting application to provide with associated properties and methods. For example, VB6 has App.Path, VB.NET and C# have Application.ExecutablePath and Application.StartupPath, etc.
In your case (because you are scripting the CTM functionality) you will need to provide a full path to any XFT you wish to locate. XMAX does not make any assumptions in this case either.
With an XAC file the XFT files will be extracted to the same folder as the rest of the contents of the XAC before being loaded and there are several ways to locate this folder.
var myXFTFilePath = ActiveDocument.ResourceSet.Root + “\q-physicalsymbol”;[/code]
In that case the folder returned is the one containing the CTM file.
var XACTempFolder = ActiveDocument.RulesFile.substring(0,ActiveDocument.RulesFile.lastIndexOf(“\”));
var myXFTFilePath = XACTempFolder + “\q-physicalsymbol”;[/code]
The first method would probably be my preferred one, however, there are people out there that have relied on the second method so they may be more familiar with it. It is also possible to locate the CSS file using ActiveDocument.DisplayStylesFile (and that could be used in place of the API in the second method).
Refer to the XMetaL Developer Programmers Guide for more information about these APIs. ResourceSet may be of particular interest as it is has a number of properties, methods and objects associated with it that allow you to query the content of XAC files in detail.
- You must be logged in to reply to this topic.