IDesignTable Interface

Solidworks学习笔记-链接Solidworks

NameDescription备注
AutoAddNewConfigsGets or sets whether to automatically add rows or columns to the design table when new configurations are added to the model.  获取或设置在将新配置添加到模型时是否自动向系列零件设计表添加行或列。
AutoAddNewParamsGets or sets whether or not to automatically add rows or columns to the design table when new parameters are added to the model.  获取或设置在将新参数添加到模型时是否自动向系列零件设计表添加行或列。
ColumnHiddenGets the visibility state of the specified column.  获取指定列的可见性状态。
EnableCellDropdownListsGets or sets whether to enable cell drop-down lists in the design table.  获取或设置是否启用系列零件设计表中的单元格下拉列表。
FileNameGets or sets the Microsoft Excel file for this design table.  获取或设置此系列零件设计表的 Microsoft Excel 文件。
LastErrorGets or sets the last error that occurred in this design table.  获取或设置此设计表中发生的最后一个错误。
LinkToFileGets or sets whether to link the design table to the model.  获取或设置是否将系列零件设计表链接到模型。
RowHiddenGets the visibility state of the specified row.  获取指定行的可见性状态。
SourceTypeGets or sets the type of source file for this design table.  获取或设置此系列零件设计表的源文件类型。
UpdatableGets or sets whether edits to the model update the design table.  获取或设置对模型的编辑是否更新系列零件设计表。
WarnGets or sets whether to display a warning when invalid information is encountered in the design table when updating the design table.  获取或设置更新设计表时,在设计表中遇到无效信息时是否显示警告。
WorksheetGets the Microsoft Excel worksheet for this design table.  获取此系列零件设计表的 Microsoft Excel 工作表。
This example shows how to disable drop-down lists for cells in a design table.

//----------------------------------------------------------
// Preconditions:
// 1. Open a part that has a design table.
// 2. In the SolidWorks Visual Studio for Applications Tools 
//    IDE, click Project > Add Reference > .NET > 
//    Microsoft.Office.Interop.Excel > OK.
// 3. Open the Immediate window.
//
// Postconditions:
// 1. Gets and edits the design table.
// 2. Disables drop-down lists for cells in the design table.
// 3. Updates and closes the design table.
// 4. Examine the Immediate window.
//
// NOTE: You can also expand Tables on the ConfigurationManager
// tab, right-click Design Table, and click Edit Feature to
// verify that Enable cell drop-down lists (may be slower)
// is not selected.
//------------------------------------------------------------
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;
using System.Diagnostics;
 
namespace Macro1CSharp.csproj
{
    public partial class SolidWorksMacro
    {
  
        public void Main()
        {
            ModelDoc2 swModel = default(ModelDoc2);
            DesignTable swDesignTable = default(DesignTable);
            bool status = false;
            Microsoft.Office.Interop.Excel.Worksheet myWorksheet = default(Microsoft.Office.Interop.Excel.Worksheet);
 
            swModel = (ModelDoc2)swApp.ActiveDoc;
 
            //Get and edit design table
            swDesignTable = (DesignTable)swModel.GetDesignTable();
            myWorksheet = (Microsoft.Office.Interop.Excel.Worksheet)swDesignTable.EditTable2(false); 
            //Allow changes to characteristics of design table
            swDesignTable.EditFeature();

            //Disable cell drop-down lists
            status = swDesignTable.EnableCellDropdownLists;
            Debug.Print("Current \"Enable cell drop-down lists (may be slower)\" setting: " + status);
            swDesignTable.EnableCellDropdownLists = false;
            status = swDesignTable.EnableCellDropdownLists;
            Debug.Print("Modified \"Enable cell drop-down lists (may be slower)\" setting: " + status);
 
            status = swDesignTable.UpdateFeature();
            Debug.Print("Design table feature updated? " + status);
 
            //Update and close design table
            swDesignTable.UpdateTable((int)swDesignTableUpdateOptions_e.swUpdateDesignTableAll, true);
 
        }
 
        /// <summary>
        ///  The SldWorks swApp variable is pre-assigned for you.
        /// </summary>
        public SldWorks swApp;
    }
}

NameDescription备注
AddRowAdds a row to the design table.  在系列零件设计表中添加一行。
AttachActivates the design table within the part or assembly document.  激活零件或装配体文档中的系列零件设计表。
DetachDetaches the design table from the Microsoft Excel sheet.  从 Microsoft Excel 工作表中分离系列零件设计表。
EditFeatureLets you change the characteristics of the design table.  允许您更改系列零件设计表的特征。
EditTable2Lets you edit the design table.  允许您编辑系列零件设计表。
GetColumnCountGets the number of columns in the design table that are currently visible in the model view.  获取设计表中当前在模型视图中可见的列数。
GetEntryTextGets the contents of the specified cell as a string regardless of the cell's data type.  无论单元格的数据类型如何,都以字符串形式获取指定单元格的内容。
GetEntryValueGets the contents of the specified cell.  获取指定单元格的内容。
GetHeaderTextGets the header text for the specified column.  获取指定列的标题文本。
GetRowCountGets the number of rows in the design table that are currently visible in the model view.  获取设计表中当前在模型视图中可见的行数。
GetStartColumnNumberGets the number of the first column in which a dimension is displayed.  获取显示维度的第一列的编号。
GetStartRowNumberGets the number of the first row in which dimensions are displayed.  获取显示维度的第一行的编号。
GetTitleGets the design table title.  获取系列零件设计表标题。
GetTotalColumnCountGets the number of columns in the design table.  获取系列零件设计表中的列数。
GetTotalRowCountGets the number of rows in the design table.  获取系列零件设计表中的行数。
GetVisibleColumnCountGets the number of columns visible in this design table.  获取此系列零件设计表中可见的列数。
GetVisibleLeftColumnNumberGets the number of the leftmost visible column.  获取最左侧可见列的编号。
GetVisibleRowCountGets the number of rows visible in the design table.  获取系列零件设计表中可见的行数。
GetVisibleTopRowNumberGets the number of the topmost visible row.  获取最顶部可见行的编号。
IsActiveGets whether the design table is currently being edited.  获取当前是否正在编辑系列零件设计表。
SaveAsExcelFileSaves the design table to a Microsoft Excel file.  将系列零件设计表保存到 Microsoft Excel 文件。
SetEntryTextSets the text value of the specified entry.  设置指定条目的文本值。
SetEntryValueSets the data type and value in the specified cell.  设置指定单元格中的数据类型和值。
SetRowChangedSets the number of the row that was changed.  设置更改的行号。
UpdateFeatureUpdates the characteristics of the design table.  更新系列零件设计表的特征。
UpdateModelApplies the edits to the design table to the model.  将设计表的编辑应用到模型。
UpdateTableApplies the changes made to the design table to the model.  将对系列零件设计表所做的更改应用于模型。
This example shows how to get a design table and its contents.

//---------------------------------------
// Preconditions:
// 1. Open a part or assembly document that
//    contains a design table.
// 2. Verify that a design table exists by 
//    expanding Tables in the ConfigurationManager.
// 3. Open the Immediate window.
//
// Postconditions:
// 1. Prints the design table contents to the 
//    Immediate window.
// 2. Examine the Immediate window.
//----------------------------------------
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;
using System.Diagnostics;
 
namespace GetTitleDesignTableCSharp.csproj
{
 
    partial class SolidWorksMacro
    {
 
        public void Main()
        {
            ModelDoc2 swModel = default(ModelDoc2);
            DesignTable swDesTable = default(DesignTable);
            int nTotRow = 0;
            int nTotCol = 0;
            string sRowStr = null;
            int i = 0;
            int j = 0;
            bool bRet = false;
 
            swModel = (ModelDoc2)swApp.ActiveDoc;
 
            swDesTable = (DesignTable)swModel.GetDesignTable();
            bRet = swDesTable.Attach();
 
            nTotRow = swDesTable.GetTotalRowCount();
            nTotCol = swDesTable.GetTotalColumnCount();
            Debug.Print("File = " + swModel.GetPathName());
            Debug.Print("  Title        = " + swDesTable.GetTitle());
            Debug.Print("  Row          = " + swDesTable.GetRowCount());
            Debug.Print("  Col          = " + swDesTable.GetColumnCount());
            Debug.Print("  TotRow       = " + nTotRow);
            Debug.Print("  TotCol       = " + nTotCol);
            Debug.Print("  VisRow       = " + swDesTable.GetVisibleRowCount());
            Debug.Print("  VisCol       = " + swDesTable.GetVisibleColumnCount());
            Debug.Print("");
 
            for (i = 0; i <= nTotRow; i++)
            {
                sRowStr = "  |";
                for (j = 0; j <= nTotCol; j++)
                {
                    sRowStr = sRowStr + swDesTable.GetEntryText(i, j) + "|";
                }
                Debug.Print(sRowStr);
            }
            swDesTable.Detach();
        }
 
        /// <summary>
        /// The SldWorks swApp variable is pre-assigned for you.
        /// </summary>
 
        public SldWorks swApp;
 
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值