Programmer's Guide > Solid Edge > Environments > Draft > Working with SmartFrames |
SmartFrames are shapes (rectangles or ellipses) on a sheet that enclose embedded or linked object(s) and have some intelligence about how to deal with the data in that frame. SmartFrames provide control over the way automation objects are displayed and manipulated on a Solid Edge sheet. SmartFrames have intelligence about their contained objects that includes the following features:
When using Solid Edge, you may sometimes find it useful to reference data that exists in a format other than a Solid Edge file. For example, while in the Solid Edge drawing environment, you might want to link to a portion of a Microsoft Excel spreadsheet. Solid Edge supports this cross-referencing through the implementation of SmartFrames. A SmartFrame is a Solid Edge object that contains a view of an embedded or linked object.
Initially, you can create an empty SmartFrame without specifying an object to be linked or embedded. A SmartFrame style must be specified, or you can use the default style for a sheet. A SmartFrame style has properties that affect how the object within the SmartFrame can be manipulated. For example, a SmartFrame that is based on a reference file style can either align the origin of the external file with the Solid Edge file or provide an option to scale the contents.
When you create a SmartFrame, four solid black lines are drawn to represent the frame. Once you have created the SmartFrame, you can select and manipulate the object as you would other Solid Edge objects.
You can create and manipulate SmartFrame objects through the automation interface using the methods that are associated with the SmartFrames2d collection object. In the following example, the AddBy2Points method creates a SmartFrame. The first argument of AddBy2Points specifies a style to be applied to the SmartFrame. In this case, the style is set to a blank string (""), so the default style is applied.
See Handling 'Application is Busy' and 'Call was Rejected By Callee' errors for information regarding the use of OleMessageFilter. |
Linking and Embedding in Visual Basic .NET |
Copy Code
|
---|---|
Imports SolidEdgeDraft Imports System.Runtime.InteropServices Module Program <STAThread()> _ Sub Main() Dim objApplication As SolidEdgeFramework.Application = Nothing Dim objDocuments As SolidEdgeFramework.Documents = Nothing Dim objDraft As SolidEdgeDraft.DraftDocument = Nothing Dim objSheet As SolidEdgeDraft.Sheet = Nothing Dim objSmartFrames2d As SolidEdgeFrameworkSupport.SmartFrames2d = Nothing Dim objSmartFrame2d As SolidEdgeFrameworkSupport.SmartFrame2d = Nothing Try OleMessageFilter.Register() ' Connect to a running instance of Solid Edge objApplication = Marshal.GetActiveObject("SolidEdge.Application") ' Get a reference to the documents collection objDocuments = objApplication.Documents ' Add a Draft document objDraft = objDocuments.Add("SolidEdge.DraftDocument") ' Get a reference to the active sheet objSheet = objDraft.ActiveSheet ' Get a reference to the smart frames 2d collection objSmartFrames2d = objSheet.SmartFrames2d ' Create a SmartFrame2d object by two points. objSmartFrame2d = objSmartFrames2d.AddBy2Points( _ "", 0.05, 0.05, 0.1, 0.1) ' Add a description to the SmartFrame objSmartFrame2d.Description = "My SmartFrame2d" ' Embed document within the SmartFrame objSmartFrame2d.CreateEmbed("C:\MyFile.doc") ' or ' Link document within the SmartFrame 'objSmartFrame2d.CreateLink("C:\MyFile.doc") Catch ex As Exception Console.WriteLine(ex.Message) Finally OleMessageFilter.Revoke() End Try End Sub End Module |
Linking and Embedding in C# |
Copy Code
|
---|---|
using SolidEdgeDraft; using System; using System.Reflection; using System.Runtime.InteropServices; namespace SolidEdge.SDK { class Program { [STAThread] static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeDraft.DraftDocument draft = null; SolidEdgeDraft.Sheet sheet = null; SolidEdgeFrameworkSupport.SmartFrames2d smartFrames2d = null; SolidEdgeFrameworkSupport.SmartFrame2d smartFrame2d = null; try { OleMessageFilter.Register(); // Connect to a running instance of Solid Edge application = (SolidEdgeFramework.Application) Marshal.GetActiveObject("SolidEdge.Application"); // Get a reference to the documents collection documents = application.Documents; // Add a Draft document draft = (SolidEdgeDraft.DraftDocument) documents.Add("SolidEdge.DraftDocument", Missing.Value); // Get a reference to the active sheet sheet = draft.ActiveSheet; // Get a reference to the smart frames 2d collection smartFrames2d = (SolidEdgeFrameworkSupport.SmartFrames2d)sheet.SmartFrames2d; // Create a SmartFrame2d object by two points. smartFrame2d = smartFrames2d.AddBy2Points("", 0.02, 0.02, 0.07, 0.07); // Add a description to the SmartFrame smartFrame2d.Description = "My SmartFrame2d"; // Embed document within the SmartFrame smartFrame2d.CreateEmbed(@"C:\MyFile.doc", Missing.Value); // or // Link document within the SmartFrame //smartFrame2d.CreateLink(@"C:\MyFile.doc", Missing.Value); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { OleMessageFilter.Revoke(); } } } } |