Represents an occurrence of a FOPTable in a Draft document.
Imports System.Runtime.InteropServices Module FOPTable Sub Main() Dim objSEApplication As SolidEdgeFramework.Application = Nothing Dim objDraftDocument As SolidEdgeDraft.DraftDocument = Nothing Dim FOPTable As SolidEdgeDraft.FOPTable = Nothing Dim FOPTables As SolidEdgeDraft.FOPTables = Nothing Dim DrawingView As SolidEdgeDraft.DrawingView = Nothing Dim Titles As SolidEdgeDraft.TableTitles = Nothing Dim Title As SolidEdgeDraft.TableTitle = Nothing Dim Columns As SolidEdgeDraft.TableColumns = Nothing Dim Column As SolidEdgeDraft.TableColumn = Nothing Dim Rows As SolidEdgeDraft.TableRows = Nothing Dim Row As SolidEdgeDraft.TableRow = Nothing Dim Cell As SolidEdgeDraft.TableCell = Nothing Dim Page As SolidEdgeDraft.TablePage = Nothing Dim ListSavedSettings(2) As String Dim initialMarginH As Double Dim ii As Integer Dim X As Double Dim Y As Double Try objSEApplication = Marshal.GetActiveObject("SolidEdge.Application") objDraftDocument = objSEApplication.ActiveDocument FOPTables = objDraftDocument.FOPTables DrawingView = objDraftDocument.ActiveSheet.DrawingViews.Item(1) 'Add FOPTable = FOPTables.Add(DrawingView) 'Update For Each FOPTable In FOPTables FOPTable.Update() Next FOPTable = FOPTables.Add(DrawingView) 'MarginHorizontal 'Taking initial margin for SavedSettings test below. initialMarginH = FOPTable.MarginHorizontal FOPTable.MarginHorizontal = initialMarginH * 2 If FOPTable.MarginHorizontal <> initialMarginH * 2 Then Console.WriteLine("Could not get or set MARGINHORIZONTAL.") End If 'MarginVertical FOPTable.MarginVertical = 0.01 If FOPTable.MarginVertical <> 0.01 Then Console.WriteLine("Could not get or set MARGINVERTICAL.") End If FOPTable.ColumnHeaderPosition = SolidEdgeDraft.TitlePosition.igHeader FOPTable.ShowColumnHeader = True FOPTable.MaximumRows = 100 FOPTable.PageGap = 0.001 FOPTable.ReverseDisplayOrder = False FOPTable.HeaderFixedRowHeight = 0.007 FOPTable.DataFixedRowHeight = 0.007 FOPTable.NumberOfHeaderRows = 2 FOPTable.MaximumRowsFirstPage = 100 FOPTable.MaximumRowsAdditionalPages = 100 FOPTable.MaximumHeightFirstPage = 0.3 FOPTable.MaximumHeightAdditionalPages = 0.3 FOPTable.CreateNewSheetsForTable = True FOPTable.FirstSheetBackgroundName = "A1-Sheet" FOPTable.AdditionalSheetsBackgroundName = "A1-Sheet" FOPTable.ShowSheetBackground = True FOPTable.MaintainSheetsWithTableSize = True FOPTable.WrapDataCellsToNewRow = True FOPTable.FillEndOfTableWithBlankRows = False FOPTable.TitleFixedRowHeight = 0.01 ' titles Titles = FOPTable.Titles Title = Titles.Add Title.value = "1st. title" Title.Position = SolidEdgeDraft.TitlePosition.igHeader Title.Alignment = SolidEdgeFrameworkSupport.TextHorizontalAlignmentConstants.igTextHzAlignRight Title.FitToWidth = True Title.FontName = "Arial" Title.FontStyle = SolidEdgeFrameworkSupport.DimTextFontStyleConstants.igDimStyleFontItalicBold Title.FontSize = 0.005 ' remove existing rows and columns Columns = FOPTable.Columns Rows = FOPTable.Rows ' columns Column = Columns.Add(1, False) Column.Width = 0.035 Column.DataHorizontalAlignment = SolidEdgeFrameworkSupport.TextHorizontalAlignmentConstants.igTextHzAlignRight Column.Show = True Column.SortPrecedence = 0 Column.SortAscending = True Column.DataMergeCellsWithSameValue = True Column.CurrentHeaderRow = 1 Column.HeaderRowValue = "Column 1" Column.HeaderRowHorizontalAlignment = SolidEdgeFrameworkSupport.TextHorizontalAlignmentConstants.igTextHzAlignCenter Column.HeaderRowVerticalAlignment = SolidEdgeFrameworkSupport.TextVerticalAlignmentConstants.igTextVtAlignTop Column.HeaderRowOrientation = SolidEdgeDraft.TableTextOrientation.igHorizontal Column.HeaderRowFitToWidth = True Column.HeaderRowMergeWithNext = True Column.DataVerticalAlignment = SolidEdgeFrameworkSupport.TextVerticalAlignmentConstants.igTextVtAlignTop Column.DataFitToWidth = True Column.CurrentHeaderRow = 2 Column.HeaderRowValue = "Secondary" Column = Columns.Add(2, False) Column.Header = "Column 2" Column.Width = 0.05 Column.SortPrecedence = 0 'rows For ii = Rows.Count To 4 Row = Rows.Add(ii, False) Next ' cell FOPTable.Cell(1, 1).value = "a" FOPTable.Cell(2, 1).value = "b" FOPTable.Cell(3, 1).value = "c" FOPTable.Cell(4, 1).value = "d" FOPTable.Cell(1, 2).value = "1" FOPTable.Cell(2, 2).value = "2" FOPTable.Cell(3, 2).value = "3" FOPTable.Cell(4, 2).value = "4" Cell = FOPTable.Cell(1, 1) Cell.FontName = "Arial" Cell.FontStyle = SolidEdgeFrameworkSupport.DimTextFontStyleConstants.igDimStyleFontBold Cell.Underline = True Cell.HorizontalAlignment = SolidEdgeFrameworkSupport.TextHorizontalAlignmentConstants.igTextHzAlignCenter Cell.VerticalAlignment = SolidEdgeFrameworkSupport.TextVerticalAlignmentConstants.igTextHzAlignVCenter 'update FOPTable.Update() FOPTable.SetOrigin(0.1, 0.1) 'Page Page = FOPTable.Pages.Item(1) Page.SetOrigin(0.2, 0.2) Page.RotationAngle = 1.57 Page.Layer = "Default" ' VALIDATION FOPTable = FOPTables.Item(1) 'Delete For Each FOPTable In FOPTables FOPTable.Delete() Next Catch ex As Exception Console.WriteLine(ex.ToString) End Try End Sub End Module
using System.Runtime.InteropServices; internal static class FOPTable { public static void Main() { SolidEdgeFramework.Application objSEApplication = null; SolidEdgeDraft.DraftDocument objDraftDocument = null; SolidEdgeDraft.FOPTable FOPTable = null; SolidEdgeDraft.FOPTables FOPTables = null; SolidEdgeDraft.DrawingView DrawingView = null; SolidEdgeDraft.TableTitles Titles = null; SolidEdgeDraft.TableTitle Title = null; SolidEdgeDraft.TableColumns Columns = null; SolidEdgeDraft.TableColumn Column = null; SolidEdgeDraft.TableRows Rows = null; SolidEdgeDraft.TableRow Row = null; SolidEdgeDraft.TableCell Cell = null; SolidEdgeDraft.TablePage Page = null; string[] ListSavedSettings = new string[3]; double initialMarginH = 0; int ii = 0; double X = 0; double Y = 0; try { objSEApplication = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application"); objDraftDocument = objSEApplication.ActiveDocument; FOPTables = objDraftDocument.FOPTables; DrawingView = objDraftDocument.ActiveSheet.DrawingViews.Item(1); //Add FOPTable = FOPTables.Add(DrawingView); //Update foreach (SolidEdgeDraft.FOPTable FOPTableWithinLoop in FOPTables) { FOPTable = FOPTableWithinLoop; FOPTableWithinLoop.Update(); } FOPTable = FOPTables.Add(DrawingView); //MarginHorizontal //Taking initial margin for SavedSettings test below. initialMarginH = FOPTable.MarginHorizontal; FOPTable.MarginHorizontal = initialMarginH * 2; if (FOPTable.MarginHorizontal != initialMarginH * 2) { Console.WriteLine("Could not get or set MARGINHORIZONTAL."); } //MarginVertical FOPTable.MarginVertical = 0.01; if (FOPTable.MarginVertical != 0.01) { Console.WriteLine("Could not get or set MARGINVERTICAL."); } FOPTable.ColumnHeaderPosition = SolidEdgeDraft.TitlePosition.igHeader; FOPTable.ShowColumnHeader = true; FOPTable.MaximumRows = 100; FOPTable.PageGap = 0.001; FOPTable.ReverseDisplayOrder = false; FOPTable.HeaderFixedRowHeight = 0.007; FOPTable.DataFixedRowHeight = 0.007; FOPTable.NumberOfHeaderRows = 2; FOPTable.MaximumRowsFirstPage = 100; FOPTable.MaximumRowsAdditionalPages = 100; FOPTable.MaximumHeightFirstPage = 0.3; FOPTable.MaximumHeightAdditionalPages = 0.3; FOPTable.CreateNewSheetsForTable = true; FOPTable.FirstSheetBackgroundName = "A1-Sheet"; FOPTable.AdditionalSheetsBackgroundName = "A1-Sheet"; FOPTable.ShowSheetBackground = true; FOPTable.MaintainSheetsWithTableSize = true; FOPTable.WrapDataCellsToNewRow = true; FOPTable.FillEndOfTableWithBlankRows = false; FOPTable.TitleFixedRowHeight = 0.01; // titles Titles = FOPTable.Titles; Title = Titles.Add; Title.value = "1st. title"; Title.Position = SolidEdgeDraft.TitlePosition.igHeader; Title.Alignment = SolidEdgeFrameworkSupport.TextHorizontalAlignmentConstants.igTextHzAlignRight; Title.FitToWidth = true; Title.FontName = "Arial"; Title.FontStyle = SolidEdgeFrameworkSupport.DimTextFontStyleConstants.igDimStyleFontItalicBold; Title.FontSize = 0.005; // remove existing rows and columns Columns = FOPTable.Columns; Rows = FOPTable.Rows; // columns Column = Columns.Add(1, false); Column.Width = 0.035; Column.DataHorizontalAlignment = SolidEdgeFrameworkSupport.TextHorizontalAlignmentConstants.igTextHzAlignRight; Column.Show = true; Column.SortPrecedence = 0; Column.SortAscending = true; Column.DataMergeCellsWithSameValue = true; Column.CurrentHeaderRow = 1; Column.HeaderRowValue = "Column 1"; Column.HeaderRowHorizontalAlignment = SolidEdgeFrameworkSupport.TextHorizontalAlignmentConstants.igTextHzAlignCenter; Column.HeaderRowVerticalAlignment = SolidEdgeFrameworkSupport.TextVerticalAlignmentConstants.igTextVtAlignTop; Column.HeaderRowOrientation = SolidEdgeDraft.TableTextOrientation.igHorizontal; Column.HeaderRowFitToWidth = true; Column.HeaderRowMergeWithNext = true; Column.DataVerticalAlignment = SolidEdgeFrameworkSupport.TextVerticalAlignmentConstants.igTextVtAlignTop; Column.DataFitToWidth = true; Column.CurrentHeaderRow = 2; Column.HeaderRowValue = "Secondary"; Column = Columns.Add(2, false); Column.Header = "Column 2"; Column.Width = 0.05; Column.SortPrecedence = 0; //rows for (ii = Rows.Count; ii <= 4; ii++) { Row = Rows.Add(ii, false); } // cell FOPTable.Cell(1, 1).value = "a"; FOPTable.Cell(2, 1).value = "b"; FOPTable.Cell(3, 1).value = "c"; FOPTable.Cell(4, 1).value = "d"; FOPTable.Cell(1, 2).value = "1"; FOPTable.Cell(2, 2).value = "2"; FOPTable.Cell(3, 2).value = "3"; FOPTable.Cell(4, 2).value = "4"; Cell = FOPTable.Cell(1, 1); Cell.FontName = "Arial"; Cell.FontStyle = SolidEdgeFrameworkSupport.DimTextFontStyleConstants.igDimStyleFontBold; Cell.Underline = true; Cell.HorizontalAlignment = SolidEdgeFrameworkSupport.TextHorizontalAlignmentConstants.igTextHzAlignCenter; Cell.VerticalAlignment = SolidEdgeFrameworkSupport.TextVerticalAlignmentConstants.igTextHzAlignVCenter; //update FOPTable.Update(); FOPTable.SetOrigin(0.1, 0.1); //Page Page = FOPTable.Pages.Item(1); Page.SetOrigin(0.2, 0.2); Page.RotationAngle = 1.57; Page.Layer = "Default"; // VALIDATION FOPTable = FOPTables.Item(1); //Delete foreach (SolidEdgeDraft.FOPTable FOPTableWithinLoop in FOPTables) { FOPTable = FOPTableWithinLoop; FOPTableWithinLoop.Delete(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } }