IConfiguration Interface
Solidworks学习笔记-链接Solidworks
属性
Name | Description | 备注 |
AddRebuildSaveMark | Adds or removes the mark indicating whether the configuration needs to be rebuilt and its configuration data saved every time you save the model document. | 添加或删除指示是否需要重建配置以及每次保存模型文档时保存其配置数据的标记。 |
AlternateName | Gets or sets the configuration's alternate name (i.e., user-specified name). | 获取或设置配置的备用名称(即用户指定的名称)。 |
BOMPartNoSource | Gets the source of the part number used in the BOM table. | 获取 BOM 表中使用的零件编号的来源。 |
ChildComponentDisplayInBOM | Gets or sets the child component display option of a configuration in a Bill of Materials (BOM) for an assembly document. | 获取或设置装配体文档的材料明细表 (BOM) 中配置的子零部件显示选项。 |
Comment | Gets or sets the configuration comment. | 获取或设置配置注释。 |
CustomPropertyManager | Gets the custom property information for this configuration. | 获取此配置的自定义属性信息。 |
Description | Gets or sets the description of the configuration. | 获取或设置配置的描述。 |
DimXpertManager | Gets the DimXpert schema for this configuration. | 获取此配置的 DimXpert 架构。 |
HideNewComponentModels | Gets or sets whether new components are hidden in this inactive configuration. | 获取或设置新组件是否隐藏在此非活动配置中。 |
LargeDesignReviewMark | Gets or sets whether to generate a display list for this configuration when the document is saved. | 获取或设置是否在保存文档时为此配置生成显示列表。 |
Lock | Gets or sets whether the configuration is locked. | 获取或设置配置是否被锁定。 |
Name | Gets or sets the configuration name. | 获取或设置配置名称。 |
NeedsRebuild | Gets whether the configuration needs to be rebuilt. | 获取配置是否需要重建。 |
SuppressNewComponentModels | Gets or sets whether new components are suppressed in this configuration. | 获取或设置是否在此配置中压缩新组件。 |
SuppressNewFeatures | Gets or sets whether to suppress new features in this configuration. | 获取或设置是否取消此配置中的新功能。 |
Type | Gets the type of configuration. | 获取配置类型。 |
UseAlternateNameInBOM | Gets or sets whether the alternate name (i.e., user-specified name) is displayed in the bill of materials for this configuration. | 获取或设置替代名称(即用户指定的名称)是否显示在此配置的物料清单中。 |
UseDescriptionInBOM | Gets or sets whether the description of the configuration is displayed in the bill of materials. | 获取或设置配置说明是否显示在物料清单中。 |
//This example shows how to mark each configuration in a multi-configuration model as //needing to be rebuilt and how to save its configuration data, including preview //bitmaps, every time you save the model document.//------------------------------------------------------------
// Preconditions:
// 1. Verify that the specified file to open exists.
// 2. Open the Immediate window.
//
// Postconditions:
// 1. Activates each configuration in the model.
// 2. Sets each configuration's Rebuild/Save Mark to true, if it is false.
// 3. Saves each configuration's preview bitmap to disk.
// 4. Examine the Immediate window.
//
// NOTES:
// * In SOLIDWORKS 2013 and later, to mark each configuration
// as needing to be rebuilt and to save its configuration data
// every time you save the model:
// 1. Activate each configuration and set
// IConfiguration::AddRebuildSaveMark to true.
// 2. Save the model.
// * Because this model is used elsewhere, do not
// save changes.
//------------------------------------------------------------
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;
using System.Diagnostics;namespace AddRebuildSaveMarkCSharp.csproj
{public partial class SolidWorksMacro{ public void Main(){ModelDoc2 swModel = default(ModelDoc2);Configuration swConfig = default(Configuration);ConfigurationManager swConfMgr = default(ConfigurationManager);object[] configNameArr = null;string configName = null;string fileName = null;string bitmapName = null;string bitmapPathName = null;bool status = false;int errors = 0;int warnings = 0;int i = 0; fileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\api\\multiconfig-part-2.sldprt";swModel = (ModelDoc2)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);swConfMgr = (ConfigurationManager)swModel.ConfigurationManager;configNameArr = (object[])swModel.GetConfigurationNames();Debug.Print("Checking each configuration's Add Rebuild/Save Mark setting after opening the model document:");for (i = 0; i <= configNameArr.GetUpperBound(0); i++){configName = (string)configNameArr[i];swConfig = (Configuration)swModel.GetConfigurationByName(configName);status = swModel.ShowConfiguration2(configName);Debug.Print(" " + configName + "'s" + " Add Rebuild/Save Mark = " + swConfig.AddRebuildSaveMark);if (swConfig.AddRebuildSaveMark == false){swConfig.AddRebuildSaveMark = true;bitmapName = configName + ".bmp";Debug.Print(" Resetting " + configName + "'s" + " Add Rebuild/Save Mark = " + swConfig.AddRebuildSaveMark);bitmapPathName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\api\\" + bitmapName;status = swApp.GetPreviewBitmapFile(fileName, configName, bitmapPathName);if (status){Debug.Print(" " + configName + "'s " + "preview bitmap written to disk: " + bitmapPathName);}}}//Save the model to save each configuration's data with the model//status = swModel.Save3(swSaveAsOptions_e.swSaveAsOptions_Silent, errors, warnings)}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp; }
}
//This example shows how to get a list of configuration names for the active document.//------------------------------------------------------------------
// Preconditions:
// 1. Verify that the specified assembly document exists.
// 2. Open the Immediate window.
//
// Postconditions:
// 1. Opens the specified assembly document.
// 2. Gets the name of the file, name of the active configuration,
// and the names of all configurations.
// 3. Examine the Immediate window.
//
// NOTE: Because the assembly is used elsewhere, do not save changes.
//-------------------------------------------------------------------using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;
using System.Diagnostics;namespace Macro1.csproj
{public partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel = default(ModelDoc2);string[] configNames = null;string configName = null;Configuration swConfig = default(Configuration);int i = 0;int errors = 0;int warnings = 0;string fileName = null;fileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\smartcomponents\\pillow_block.sldasm";swModel = (ModelDoc2)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocASSEMBLY, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);//Get and print active model path and nameDebug.Print("File = " + swModel.GetPathName());Debug.Print("");//Get and print name of active configurationswConfig = (Configuration)swModel.GetActiveConfiguration();Debug.Print(" Name of active configuration = " + swConfig.Name);Debug.Print("");//Get and print names of all configurationsconfigNames = (string[])swModel.GetConfigurationNames();for (i = 0; i < configNames.Length; i++){configName = (string)configNames[i];swConfig = (Configuration)swModel.GetConfigurationByName(configName);Debug.Print(" Name of configuration(" + i + ") = " + configName);Debug.Print(" Use alternate name in BOM = " + swConfig.UseAlternateNameInBOM);Debug.Print(" Alternate name = " + swConfig.AlternateName);Debug.Print(" Comment = " + swConfig.Comment);Debug.Print("");}}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;}
}
//This example shows how to add a configuration to an assembly and promote its child //components one level in a BOM.//----------------------------------------
// Preconditions:
// 1. Specified assembly document exists.
// 2. Open the Immediate window.
//
// Postconditions:
// 1. Opens the specified assembly document.
// 2. Adds a new configuration named Config2.
// 3. Sets the option to dissolve the assembly's
// configuration when it appears in a BOM and
// promote all of its child components one level.
// 4. To verify, examine the option value printed to
// the Immediate window.
//
// NOTE: Because this assembly document is used
// elsewhere, do not save changes when closing it.
//----------------------------------------
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;
using System.Diagnostics;namespace ChildComponentDisplayInBOMCSharp.csproj
{public partial class SolidWorksMacro{AssemblyDoc swAssembly;ModelDoc2 swModel;ModelDocExtension swModelDocExt;Configuration swConfig;string fileName;bool status;int errors;int warnings;public void Main(){//Open assembly document fileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\advdrawings\\bowl and chute.sldasm";swAssembly = (AssemblyDoc)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocASSEMBLY, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);swModel = (ModelDoc2)swAssembly;//Add configuration named Config2swModelDocExt = (ModelDocExtension)swModel.Extension;status = swModelDocExt.SelectByID2("bowl and chute.SLDASM", "COMPONENT", 0, 0, 0, false, 0, null, 0);swModel.ClearSelection2(true);swConfig = (Configuration)swModel.AddConfiguration3("Config2", "", "", (int)swConfigurationOptions2_e.swConfigOption_DoDisolveInBOM + (int)swConfigurationOptions2_e.swConfigOption_DontShowPartsInBOM);//Dissolve the assembly's configuration//when it appears in a BOM and promote all of//its child components one levelswConfig.ChildComponentDisplayInBOM = (int)swChildComponentInBOMOption_e.swChildComponent_Promote;Debug.Print("Child component display option in BOM: " + swConfig.ChildComponentDisplayInBOM);}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;}
}
//This example shows how to traverse an assembly and display the description of each //configuration in the bill of materials.//--------------------------------------------------------------------------
// Preconditions:
// 1. Open public_documents\samples\tutorial\smartcomponents\pillow_block.sldasm.
// 2. Open the Immediate window.
//
// Postconditions:
// 1. Traverses the configurations.
// 2. Gets the name of each configuration and its description.
// 3. Sets and gets whether to display the description of each configuration
// in the bill of materials.
// 4. Examine the Immediate window.
//
// NOTE: Because the assembly is used elsewhere, do not save changes.
//--------------------------------------------------------------------------
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);string[] vConfigNameArr = null;Configuration swConfig = default(Configuration);Configuration swParentConfig = default(Configuration);ConfigurationManager swConfMgr = default(ConfigurationManager);object[] vChildConfigArr = null;Configuration swChildConfig = default(Configuration);swModel = (ModelDoc2)swApp.ActiveDoc;swConfMgr = (ConfigurationManager)swModel.ConfigurationManager;Debug.Print("File = " + swModel.GetPathName());Debug.Print("");// Traverse configurations; always at least one configuration existsvConfigNameArr = (string[])swModel.GetConfigurationNames();foreach (string vConfigName in vConfigNameArr){swConfig = (Configuration)swModel.GetConfigurationByName(vConfigName);Debug.Print(" Configuration name = " + swConfig.Name);Debug.Print(" Description = " + swConfig.Description);swConfig.UseDescriptionInBOM = true;Debug.Print(" Display description in bill of materials? " + swConfig.UseDescriptionInBOM);// Process parentswParentConfig = (Configuration)swConfig.GetParent();if ((swParentConfig != null)){Debug.Print(" Parent = " + swParentConfig.Name);}// Process childrenvChildConfigArr = (object[])swConfig.GetChildren();if ((vChildConfigArr != null)){foreach (object vChildConfig in vChildConfigArr){swChildConfig = (Configuration)vChildConfig;Debug.Print(" Child = " + swChildConfig.Name);}}Debug.Print("");}}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;}
}
This example shows how to get and set the Large Design Review marks for all of the configurations in an assembly.//---------------------------------------------------------------------------
// Preconditions:
// 1. Open public_documents\samples\tutorial\driveworksxpress\mobile gantry.sldasm.
// 2. Open the Immediate window.
//
// Postconditions:
// 1. Gets the current Large Design Review marks for all configurations.
// 2. Sets the Large Design Review marks for all configurations to true.
// 3. Gets the modified Large Design Review marks for all configurations.
// 4. Examine the Immediate window.
//
// NOTE: Because the assembly is used elsewhere, do not save changes.
//---------------------------------------------------------------------------
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);Configuration swConf = default(Configuration);ConfigurationManager swConfMgr = default(ConfigurationManager);string[] configNameArr = null;swModel = (ModelDoc2)swApp.ActiveDoc;swConfMgr = (ConfigurationManager)swModel.ConfigurationManager;configNameArr = (string[])swModel.GetConfigurationNames();//Get current Large Design Review marks for all configurationsDebug.Print("Current Large Design Review marks for configurations:");foreach (string configName in configNameArr){swConf = (Configuration)swModel.GetConfigurationByName(configName);Debug.Print(" " + configName + ": " + swConf.LargeDesignReviewMark);}//Set Large Design Review marks for all configurations to trueforeach (string configName in configNameArr){swConf = (Configuration)swModel.GetConfigurationByName(configName);swConf.LargeDesignReviewMark = true;}//Get modified Large Design Review marks for all configurationsDebug.Print("Modified Large Design Review marks for configurations:");foreach (string configName in configNameArr){swConf = (Configuration)swModel.GetConfigurationByName(configName);Debug.Print(" " + configName + ": " + swConf.LargeDesignReviewMark);}}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;}
}
This example shows how to get the name and ID of the active configuration of a part or assembly or the current sheet of a drawing.NOTE: A unique ID is assigned to each configuration and drawing. This ID does not change when the name of the configuration or drawing sheet is changed.//-------------------------------------------------------
// Preconditions:
// 1. Open a part, assembly, or drawing document.
// 2. Open the Immediate window.
//
// Postconditions:
// 1. Changes either the active configuration's name or
// the current sheet's name to Test. However, the
// document's ID is unchanged.
// 2. Examine the Immediate window.
//------------------------------------------------------
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System;
using System.Diagnostics;namespace Macro1CSharp.csproj
{partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel = default(ModelDoc2);Configuration swConfig = default(Configuration);DrawingDoc swDrawingDoc = default(DrawingDoc);Sheet swSheet = default(Sheet);int nDocType = 0;swModel = (ModelDoc2)swApp.ActiveDoc;// Get type of model document if (swModel.GetType() == 1){ nDocType = (int)swDocumentTypes_e.swDocPART;}else if (swModel.GetType() == 2){nDocType = (int)swDocumentTypes_e.swDocASSEMBLY;}else if (swModel.GetType() == 3){ nDocType = (int)swDocumentTypes_e.swDocDRAWING;}else{// Not a SOLIDWORKS model document, // so exit macro return;}// If a part or assembly document, // then get the name of it and its ID if (nDocType != (int)swDocumentTypes_e.swDocDRAWING){swConfig = (Configuration)swModel.GetActiveConfiguration();if ((swConfig != null)){Debug.Print("Active configuration's name = " + swConfig.Name + ", ID = " + swConfig.GetID());// Change the active configuration's name swConfig.Name = "Test";// Test to see if the ID remains the same // after changing the name of the configuration Debug.Print("Active configuration's new name = " + swConfig.Name + ", ID = " + swConfig.GetID());}return;}// A drawing sheet must be active, // so get its name and ID swDrawingDoc = (DrawingDoc)swModel;swSheet = (Sheet)swDrawingDoc.GetCurrentSheet();if ((swSheet != null)){Debug.Print("Current sheet's name = " + swSheet.GetName() + ", ID = " + swSheet.GetID());// Change current sheet's name swSheet.SetName("Test");// Test to see if the ID remains the same // after changing the name of the sheet Debug.Print("Current sheet's new name = " + swSheet.GetName() + ", ID = " + swSheet.GetID());}}public SldWorks swApp;}}
This example shows how to find out if the configurations in an assembly are loaded, whether the configurations need to be updated and rebuilt, and the configuration types.//-----------------------------------------------------------------------
// Preconditions:
// 1. Verify that the assembly document to open exists.
// 2. Open the Immediate window.
//
// Postconditions:
// 1. Loads all configurations.
// 2. Examine the Immediate window to see the states of the
// configurations.
//
// NOTE: Because the specified assembly document is used elsewhere,
// do not save the document when you close it.
// ---------------------------------------------------------------
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System;
using System.Diagnostics;
namespace IsLoadedConfigurationCSharp.csproj
{public partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel = default(ModelDoc2);Configuration swConfiguration = default(Configuration);ConfigurationManager swConfigurationMgr = default(ConfigurationManager);object[] ConfNameArr = null;string ConfName = null;const string DocFilename = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\pdmworks\\speaker.sldasm";bool boolstatus = false;int Errors = 0;int Warnings = 0;int i;swModel = (ModelDoc2)swApp.OpenDoc6(DocFilename, (int)swDocumentTypes_e.swDocASSEMBLY, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref Errors, ref Warnings);if (swModel == null){return;}else{Debug.Print("File = " + swModel.GetPathName());Debug.Print("");}swConfigurationMgr = (ConfigurationManager)swModel.ConfigurationManager;swConfiguration = (Configuration)swConfigurationMgr.ActiveConfiguration;ConfNameArr = (object[])swModel.GetConfigurationNames();Debug.Print("Traverse assembly without activating other configurations...");for (i = 0; i < ConfNameArr.Length; i++){ConfName = (string)ConfNameArr[i];swConfiguration = (Configuration)swModel.GetConfigurationByName(ConfName);Debug.Print(" Name of the configuration: " + swConfiguration.Name);Debug.Print(" Is the configuration loaded? " + swConfiguration.IsLoaded());Debug.Print(" Does the configuration need to be updated? " + swConfiguration.IsDirty());Debug.Print(" Does the configuration need to be rebuilt? " + swConfiguration.NeedsRebuild);Debug.Print(" What is the configuration type? ? " + swConfiguration.Type);}Debug.Print("");// Traverse the assembly again, but this time activate all // configurations, which loads them Debug.Print("Traverse assembly and activate all configurations...");for (i = 0; i < ConfNameArr.Length; i++){ConfName = (string)ConfNameArr[i];swConfiguration = (Configuration)swModel.GetConfigurationByName(ConfName);boolstatus = swModel.ShowConfiguration2(ConfName);swConfiguration = (Configuration)swConfigurationMgr.ActiveConfiguration;Debug.Print(" Name of the configuration: " + swConfiguration.Name);Debug.Print(" Is the configuration loaded? " + swConfiguration.IsLoaded());Debug.Print(" Does the configuration need to be updated? " + swConfiguration.IsDirty());Debug.Print(" Does the configuration need to be rebuilt? " + swConfiguration.NeedsRebuild);Debug.Print(" What is the configuration type? ? " + swConfiguration.Type);}}/// <summary> /// The SldWorks swApp variable is pre-assigned for you. /// </summary> public SldWorks swApp;}
}
方法
Name | Description | 备注 |
AddExplodeStep2 | Adds a regular (translate and rotate) explode step to the explode view of the active configuration. | 向活动配置的爆炸视图添加常规(平移和旋转)爆炸步骤。 |
AddRadialExplodeStep | Adds a radial explode step to the explode view of the active configuration. | 向活动配置的爆炸视图添加径向爆炸步骤。 |
ApplyDisplayState | Applies the specified display state to this configuration. | 将指定的显示状态应用于此配置。 |
CopyDisplayStateFromConfiguration | Copies the specified display state from the specified configuration to this configuration. | 将指定的显示状态从指定的配置复制到此配置。 |
CreateDisplayState | Creates a display state for this configuration. | 为该配置创建一个显示状态。 |
DeleteDisplayState | Deletes the specified display state from this configuration. | 从此配置中删除指定的显示状态。 |
DeleteExplodeStep | Deletes the specified explode step in the configuration explode step sequence. | 删除配置爆炸步骤序列中的指定爆炸步骤。 |
GetChildren | Gets all of the children configurations of this derived configuration. | 获取此派生配置的所有子配置。 |
GetChildrenCount | Gets the number of children for this configuration. | 获取此配置的子项数。 |
GetComponentConfigName | Gets the referenced configuration name of the specified component in this configuration. | 获取此配置中指定组件的引用配置名称。 |
GetComponentSuppressionState | Gets the suppression state of the specified component in this configuration. | 获取此配置中指定组件的压缩状态。 |
GetDisplayStateBodyProperties | Gets the bodies and their material properties in the specified display state. | 获取指定显示状态下的实体及其材料属性。 |
GetDisplayStateComponentProperties | Gets the components and their material properties in the specified display state. | 获取指定显示状态下的组件及其材料属性。 |
GetDisplayStateComponentVisibility | Gets the components and their visibilities in the specified display state. | 获取指定显示状态下的组件及其可见性。 |
GetDisplayStateFaceProperties | Gets the faces and their material properties in the specified display state. | 获取指定显示状态下的面及其材料属性。 |
GetDisplayStateFeatureProperties | Gets the features and their material properties in the specified display state. | 获取指定显示状态下的特征及其材料属性。 |
GetDisplayStateProperties | Gets the material properties of the specified display state. | 获取指定显示状态的材料属性。 |
GetDisplayStates | Gets the names of the display states for this configuration. | 获取此配置的显示状态名称。 |
GetDisplayStatesCount | Gets the number of display states for this configuration. | 获取此配置的显示状态数。 |
GetExpanded | Gets whether this configuration's node is expanded in the specified pane of the ConfigurationManager. | 获取此配置的节点是否在 ConfigurationManager 的指定窗格中展开。 |
GetExplodeStep | Gets the specified explode step in this configuration's explode step sequence. | 获取此配置的爆炸步骤序列中指定的爆炸步骤。 |
GetID | Gets the configuration ID of this configuration. | 获取此配置的配置 ID。 |
GetNumberOfExplodeSteps | Gets the number of explode steps for this configuration. | 获取此配置的爆炸步骤数。 |
GetParameterCount | Gets the number of parameters for this configuration. | 获取此配置的参数数量。 |
GetParameters | Gets the parameters (suppression state of features, suppression state or visibility of components, dimensions, and so on) for this configuration. | 获取此配置的参数(特征的压缩状态、组件的压缩状态或可见性、尺寸等)。 |
GetParent | Gets the parent configuration of this derived configuration. | 获取此派生配置的父配置。 |
GetRootComponent3 | Gets the root component for this assembly configuration. | 获取此程序集配置的根组件。 |
GetScene | Gets the ISwScene object for this configuration. | 获取此配置的 ISwScene 对象。 |
GetStreamName | Gets the name of the stream for the current configuration. | 获取当前配置的流的名称。 |
IAddExplodeStep | Adds a new explode step to the configuration. | 向配置添加新的爆炸步骤。 |
IGetChildren | Gets all of the children configurations of this derived configuration. | 获取此派生配置的所有子配置。 |
IGetDisplayStates | Gets the names of the display states for this configuration. | 获取此配置的显示状态名称。 |
IGetExplodeStep | Gets a pointer to the specified explode step in the configuration explode step sequence. | 获取指向配置爆炸步骤序列中指定爆炸步骤的指针。 |
IGetParameters | Gets the parameters (suppression state of features, suppression state or visibility of components, dimensions, and so on) for this configuration. | 获取此配置的参数(特征的压缩状态、组件的压缩状态或可见性、尺寸等)。 |
IsDerived | Gets whether this configuration is a derived configuration. | 获取此配置是否为派生配置。 |
IsDirty | Gets whether this configuration is dirty (i.e., needs to be updated). | 获取此配置是否脏(即需要更新)。 |
ISetParameters | Sets the parameters (suppression state of features, suppression state or visibility of components, dimensions, and so on) for this configuration. | 设置此配置的参数(特征的抑制状态、抑制状态或组件的可见性、尺寸等)。 |
IsLoaded | Gets whether a configuration is loaded. | 获取是否加载了配置。 |
IsSpeedPak | Gets whether the configuration is a SpeedPak. | 获取配置是否为 SpeedPak。 |
RenameDisplayState | Renames a display state of this configuration. | 重命名此配置的显示状态。 |
Select2 | Selects the configuration. | 选择配置。 |
SetColor | Sets the color for this configuration. | 设置此配置的颜色。 |
SetExpanded | Sets whether to expand this configuration's node in the specified pane of the ConfigurationManager. | 设置是否在 ConfigurationManager 的指定窗格中展开此配置的节点。 |
SetParameters | Sets the parameters (suppression state of features, suppression state or visibility of components, dimensions, and so on) for this configuration. | 设置此配置的参数(特征的抑制状态、压缩状态或组件的可见性、尺寸等)。 |
UpdateSpeedPak | Updates the SpeedPak configuration for this configuration. | 更新此配置的 SpeedPak 配置。 |
This example shows how to create, unlink, and purge display states in a part document. //---------------------------------------------
// Preconditions:
// 1. Open public_documents\samples\tutorial\multibody\multi-inter.sldprt,
// whose Default configuration has two display states:
// * PhotoWorks Display
// * Display State 1
// 2. Open the Immediate window.
//
// Postconditions:
// 1. Creates and unlinks Display State 2.
// 2. Attempts to purge any display states identical to
// Display State 2.
// 3. Closes the part document without saving any changes.
// 4. Examine the Immediate window.
//-----------------------------------------------
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System;
using System.Diagnostics;
namespace AddAndPurgeDisplayStates_CSharp.csproj
{partial class SolidWorksMacro{public PartDoc swPart;public void Main(){ModelDoc2 swModel = default(ModelDoc2);Configuration swConfig = default(Configuration);ModelDocExtension swModelDocExt = default(ModelDocExtension);bool boolstatus = false;string modelName = null;swModel = (ModelDoc2)swApp.ActiveDoc;// Get Default configuration and create a display state swConfig = (Configuration)swModel.GetConfigurationByName("Default");boolstatus = swConfig.CreateDisplayState("Display State 2");if (boolstatus) Debug.Print("Display State 2 created.");swModel.ForceRebuild3(true);// If display is linked, unlink it swModelDocExt = swModel.Extension;Debug.Print("Is Display State 2 linked? " + swModelDocExt.LinkedDisplayState);swModelDocExt.LinkedDisplayState = false;Debug.Print("Is Display State 2 still linked? " + swModelDocExt.LinkedDisplayState);// Purge any display states identical to Display State 2boolstatus = swModelDocExt.PurgeDisplayState();Debug.Print("Identical display states to Display State 2 purged? " + boolstatus);swModel.ForceRebuild3(true);// Close the part without saving changes modelName = swModel.GetTitle();swApp.QuitDoc(modelName);}public SldWorks swApp;}}
This example shows how to add an appearance to and delete an appearance from specific display states.//--------------------------------------------------------------------------
// Preconditions:
// 1. Specified model exists.
// 2. Specified appearance exists.
// 3. Open an Immediate window.
//
// Postconditions:
// 1. Creates Display State 2 and Display State 3 for the active
// configuration.
// 2. Applies specified appearance to all display states of the active
// configuration.
// 3. Press F5.
// 4. Deletes specified appearance from all display states of the active
// configuration.
// 5. Press F5.
// 6. Closes document.
//---------------------------------------------------------------------------using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
namespace RenderMaterials_CSharp.csproj
{partial class SolidWorksMacro{
ModelDoc2 swModel;
Configuration swConfig;
ModelDocExtension swModelDocExt;
Entity swEntity;
SelectionMgr swSelMgr;
RenderMaterial swRenderMaterial;
object[] displayStateNames;
bool status;
string modelName;
string materialName;
int errors;
int warnings;
int nbrDisplayStates;
int i;
int k;
int nbrMaterials;
int materialID1;
int materialID2;
int[] materialID1_ToDelete = new int[1];
int[] materialID2_ToDelete = new int[1];public void Main()
{
modelName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\dimxpert\\bracket_auto_manual.sldprt";swModel = swApp.OpenDoc6(modelName, (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);swModelDocExt = swModel.Extension;
// Get active configuration and create a new display
// state for this configuration
swConfig = (Configuration)swModel.GetActiveConfiguration();
status = swConfig.CreateDisplayState("Display State 2");
swModel.ForceRebuild3(true);// Get active configuration and create another new
// display state for this configuration
swConfig = (Configuration)swModel.GetActiveConfiguration();
status = swConfig.CreateDisplayState("Display State 3");
swModel.ForceRebuild3(true);// Create appearance
materialName = "C:\\Program Files\\SolidWorks Corp\\SolidWorks\\data\\graphics\\materials\\metal\\steel\\stainless steel treadplate.p2m";
swRenderMaterial = swModelDocExt.CreateRenderMaterial(materialName);// Select a face and add the appearance to that face
status = swModelDocExt.SelectByID2("", "FACE", 0.07151920610502, 0.0952597996959, 0.009524999999996, false, 0, null, 0);
swSelMgr = (SelectionMgr)swModel.SelectionManager;
swEntity = (Entity)swSelMgr.GetSelectedObject6(1, -1);
status = swRenderMaterial.AddEntity(swEntity);// Get the names of display states
displayStateNames = (object[])swConfig.GetDisplayStates();
nbrDisplayStates = swConfig.GetDisplayStatesCount();
Debug.Print("This configuration's display states =");
for (i = 0; i <= (nbrDisplayStates - 1); i++)
{
Debug.Print(" Display state name = " + displayStateNames[i]);
}// Add appearance to all of the display states
status = swModelDocExt.AddDisplayStateSpecificRenderMaterial(swRenderMaterial, (int)swDisplayStateOpts_e.swAllDisplayState, displayStateNames, out materialID1, out materialID2);// Get the appearance IDs and names
swRenderMaterial.GetMaterialIds(out materialID1, out materialID2);
Debug.Print(" Appearance IDs:");
Debug.Print(" ID1 = " + materialID1);
Debug.Print(" ID2 = " + materialID2);nbrMaterials = swModelDocExt.GetRenderMaterialsCount2((int)swDisplayStateOpts_e.swAllDisplayState, null);
Debug.Print(" Number of materials: " + nbrMaterials);
for (k = 0; k <= (nbrMaterials - 1); k++)
{
Debug.Print(" Name of appearance " + (k + 1) + ": " + swModel.MaterialIdName);
}double xcoord = 0;
double ycoord = 0;
double zcoord = 0;swRenderMaterial.GetCenterPoint2(out xcoord, out ycoord, out zcoord);
Debug.Print("");
Debug.Print("Texture-based appearance data:");
Debug.Print("X coordinate of center point: " + xcoord);
Debug.Print("Y coordinate of center point: " + ycoord);
Debug.Print("Z coordinate of center point: " + zcoord);
swRenderMaterial.GetUDirection2(out xcoord, out ycoord, out zcoord);
Debug.Print("X coordinate of U direction: " + xcoord);
Debug.Print("Y coordinate of U direction: " + ycoord);
Debug.Print("Z coordinate of U direction: " + zcoord);
swRenderMaterial.GetVDirection2(out xcoord, out ycoord, out zcoord);
Debug.Print("X coordinate of V direction: " + xcoord);
Debug.Print("Y coordinate of V direction: " + ycoord);
Debug.Print("Z coordinate of V direction: " + zcoord);
Debug.Print("");
swModel.ClearSelection2(true);
swModel.ForceRebuild3(true);
Debug.Print("Model has an appearance: " + swModelDocExt.HasMaterialPropertyValues());
object dispStates = null;
status = swRenderMaterial.SetLinkedDisplayStates((int)swDisplayStateOpts_e.swAllDisplayState, displayStateNames);
dispStates = swRenderMaterial.GetLinkedDisplayStates();
object renderMaterials = null;
renderMaterials = swModelDocExt.GetRenderMaterials2((int)swDisplayStateOpts_e.swAllDisplayState, null);
// Examine the display states of the active configuration
// to ensure that the specified appearance was applied to all
// display states
// Continue running the macro after your examinationSystem.Diagnostics.Debugger.Break();
// Delete the appearance from the part
materialID1_ToDelete[0] = materialID1;
materialID2_ToDelete[0] = materialID2;
swModelDocExt.DeleteDisplayStateSpecificRenderMaterial((materialID1_ToDelete), (materialID2_ToDelete));
swModel.ForceRebuild3(true);
// Examine the display states of the active configuration
// to ensure that the specified appearance was deleted from all
// display states
// Continue running the macro after your examination
System.Diagnostics.Debugger.Break();
// Close the part without saving changes
modelName = swModel.GetTitle();
swApp.QuitDoc(modelName);}public SldWorks swApp;}}
//This example shows how to get the names of the display states in an assembly and the //visibilities of the assembly components in each display state.//------------------------------------------------------------------------------
// Preconditions:
// 1. Open an assembly that contains multiple components
// and display states.
// 2. Open the Immediate window.
//
// Postconditions: Examine the Immediate window.
//-----------------------------------------------------------------------------
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;
using System.Diagnostics;namespace DisplayStateComponentsCSharp.csproj
{public partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel = default(ModelDoc2);ModelDocExtension swModelDocExt = default(ModelDocExtension);ConfigurationManager swConfigMgr = default(ConfigurationManager);Configuration swConfig = default(Configuration);object oComponents = null;object[] components = null;Component2 comp = null;int docType = 0;int i = 0;int j = 0;string[] displayStateNames = null;string displayStateName = null;int[] displayStateVisibilities = null;int displayStateVisibility = 0;string visibility = "";swModel = (ModelDoc2)swApp.ActiveDoc;swModelDocExt = (ModelDocExtension)swModel.Extension;docType = swModel.GetType();if (docType == (int)swDocumentTypes_e.swDocASSEMBLY){swConfigMgr = (ConfigurationManager)swModel.ConfigurationManager;swConfig = (Configuration)swConfigMgr.ActiveConfiguration;displayStateNames = (string[])swConfig.GetDisplayStates();for (i = 0; i < displayStateNames.Length; i++){displayStateName = (string)displayStateNames[i];Debug.Print("Display state name: " + displayStateName);displayStateVisibilities = (int[])swConfig.GetDisplayStateComponentVisibility(displayStateName, false, false, out oComponents);components = (object[])oComponents;Debug.Print(" Display state visibility: ");for (j = 0; j < displayStateVisibilities.Length; j++){displayStateVisibility = (int)displayStateVisibilities[j];switch (displayStateVisibility){case 0:visibility = "Hidden";break;case 1:visibility = "Shown";break;}comp = (Component2)components[j];Debug.Print(" " + comp.Name2 + ": " + visibility);}}}else{Debug.Print("Open an assembly document with multiple display states.");return;}}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;}
}
This example shows how to get an explode step and its properties.//---------------------------------------------------------------
// Preconditions:
// 1. Open an assembly document with an explode view.
// 2. Open an Immediate window.
//
// Postconditions:
// 1. Gets the first explode step.
// 2. Examine the Immediate window.
//---------------------------------------------------------------using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;
using System.Diagnostics;namespace ExplodeStepCSharp.csproj
{public partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel = default(ModelDoc2);ConfigurationManager swConfigurationMgr = default(ConfigurationManager);Configuration swConfiguration = default(Configuration);ExplodeStep swExplodeStep = default(ExplodeStep);swModel = (ModelDoc2)swApp.ActiveDoc;//Get explode stepswConfigurationMgr = (ConfigurationManager)swModel.ConfigurationManager;swConfiguration = (Configuration)swConfigurationMgr.ActiveConfiguration;swExplodeStep = (ExplodeStep)swConfiguration.GetExplodeStep(0);Debug.Print("Name of explode step: " + swExplodeStep.Name);Debug.Print("Number of components that move in this explode step: " + swExplodeStep.GetNumOfComponents());Debug.Print("Is the sub-assembly rigid? " + swExplodeStep.IsSubAssemblyRigid()); }/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;}
}
//This example shows how to change the color of a://selected component in a specific display state at the assembly and part levels.
//component in its part document.
//----------------------------------------------
// Preconditions: Verify that the specified assembly and part exist.
//
// Postconditions:
// 1. Opens the specified assembly document.
// 2. Examine the graphics area, then press F5.
// 3. Changes the selected component's, USB_cover1,
// assembly-level color from the default red
// to gray in the specified display state. This
// is the overriding color level.
// 4. Examine the component in the graphics area, then press F5.
// 5. Changes the selected component's, USB_cover1, part-level
// color from red to green in the specified display state of
// the component part. This is not the overriding color level.
// 6. Closes, but does not save, the assembly document.
// 7. Opens the component's part document, USB_cover1.sldprt.
// 8. Examine the graphics area, then press F5.
// 9. Changes part's color from red to green in the specified
// display state of the part. This is the overriding color
// level.
// 10. Examine the graphics area, then press F5.
// 11. Closes, but does not save, the part document.
//-----------------------------------------------
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;namespace AppearancesCSharp.csproj
{partial class SolidWorksMacro{public void Main(){ModelDoc2 swModelDoc = null;ModelDocExtension swModelDocExt = null;SelectionMgr swSelMgr = null;DisplayStateSetting swDisplayStateSetting = null;Component2 swComponent = null;Component2[] swComponents = new Component2[1];string[] displayStateNames = new string[1];object appearances = null;object[] appearancesArray = null;AppearanceSetting swAppearanceSetting = default(AppearanceSetting);AppearanceSetting[] newAppearanceSetting = new AppearanceSetting[1];ConfigurationManager swConfigMgr = default(ConfigurationManager);Configuration swConfig = default(Configuration);bool status = false;int errors = 0;int warnings = 0;string fileName = "";int red_rgb = 0;int green_rgb = 0;int blue_rgb = 0;int newColor = 0;//Open assembly documentfileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\appearances\\usb_flash_drive1.sldasm";swModelDoc = (ModelDoc2)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocASSEMBLY, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);System.Diagnostics.Debugger.Break();//Examine the graphics area//Press F5 to continue//Select component, USB_cover1swModelDocExt = (ModelDocExtension)swModelDoc.Extension;swSelMgr = (SelectionMgr)swModelDoc.SelectionManager;status = swModelDocExt.SelectByID2("USB_cover1-1@usb_flash_drive1", "COMPONENT", 0, 0, 0, false, 0, null, 0);swComponent = (Component2)swSelMgr.GetSelectedObject6(1, -1);swComponents[0] = swComponent;swModelDoc.ClearSelection2(true);//Get display state swDisplayStateSetting = (DisplayStateSetting)swModelDocExt.GetDisplayStateSetting((int)swDisplayStateOpts_e.swAllDisplayState);swDisplayStateSetting.Entities = swComponents;swDisplayStateSetting.Option = (int)swDisplayStateOpts_e.swSpecifyDisplayState;displayStateNames[0] = "Display State-1";swDisplayStateSetting.Names = displayStateNames;//Assembly level is defaultswDisplayStateSetting.PartLevel = false;//Change the selected component's, USB_cover1, //assembly-level color from the default red//to gray in the specified display state; this//is the overriding color levelappearances = (object)swModelDocExt.get_DisplayStateSpecMaterialPropertyValues(swDisplayStateSetting);appearancesArray = (object[])appearances;swAppearanceSetting = (AppearanceSetting)appearancesArray[0];red_rgb = 50;green_rgb = 50;blue_rgb = 50;newColor = Math.Max(Math.Min(red_rgb, 255), 0) + Math.Max(Math.Min(green_rgb, 255), 0) * 16 * 16 + Math.Max(Math.Min(blue_rgb, 255), 0) * 16 * 16 * 16 * 16;swAppearanceSetting.Color = newColor;newAppearanceSetting[0] = (AppearanceSetting)swAppearanceSetting;swModelDocExt.set_DisplayStateSpecMaterialPropertyValues(swDisplayStateSetting, newAppearanceSetting);System.Diagnostics.Debugger.Break();//Examine the component in the graphics area//Press F5 to continueswModelDoc.ClearSelection2(true);status = swModelDocExt.SelectByID2("USB_cover1-1@usb_flash_drive1", "COMPONENT", 0, 0, 0, false, 0, null, 0);swComponent = (Component2)swSelMgr.GetSelectedObject6(1, -1);swComponents[0] = (Component2)swComponent;swModelDoc.ClearSelection2(true);//Get display stateswDisplayStateSetting = swModelDocExt.GetDisplayStateSetting((int)swDisplayStateOpts_e.swAllDisplayState);swDisplayStateSetting.Entities = swComponents;swDisplayStateSetting.Option = (int)swDisplayStateOpts_e.swSpecifyDisplayState;displayStateNames[0] = "<Default>_Display State 1";swDisplayStateSetting.Names = displayStateNames;//Set to part levelswDisplayStateSetting.PartLevel = true;//Change the selected component's, USB_cover1, part-level//color from red to green in the specified display state of//the component part; this is not the overriding color levelappearances = (object)swModelDocExt.get_DisplayStateSpecMaterialPropertyValues(swDisplayStateSetting);appearancesArray = (object[])appearances;swAppearanceSetting = (AppearanceSetting)appearancesArray[0];red_rgb = 0;green_rgb = 255;blue_rgb = 0;newColor = Math.Max(Math.Min(red_rgb, 255), 0) + Math.Max(Math.Min(green_rgb, 255), 0) * 16 * 16 + Math.Max(Math.Min(blue_rgb, 255), 0) * 16 * 16 * 16 * 16;swAppearanceSetting.Color = newColor;newAppearanceSetting[0] = swAppearanceSetting;swModelDocExt.set_DisplayStateSpecMaterialPropertyValues(swDisplayStateSetting, newAppearanceSetting);//Close the assembly document without saving//changesswApp.CloseDoc("usb_flash_drive1");//Open the assembly component USB_cover1 as a part documentfileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\appearances\\usb_cover1.sldprt";swModelDoc = (ModelDoc2)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);swModelDocExt = (ModelDocExtension)swModelDoc.Extension;swConfigMgr = (ConfigurationManager)swModelDoc.ConfigurationManager;swConfig = (Configuration)swConfigMgr.ActiveConfiguration;swComponents[0] = null;swComponents[0] = swConfig.GetRootComponent3(true);swModelDoc.ClearSelection2(true);//Get display stateswDisplayStateSetting = null;swDisplayStateSetting = (DisplayStateSetting)swModelDocExt.GetDisplayStateSetting((int)swDisplayStateOpts_e.swAllDisplayState);swDisplayStateSetting.Entities = swComponents;swDisplayStateSetting.Option = (int)swDisplayStateOpts_e.swSpecifyDisplayState;displayStateNames[0] = "<Default>_Display State 1";swDisplayStateSetting.Names = displayStateNames;System.Diagnostics.Debugger.Break();//Examine the graphics area//Press F5 to continue//Change color of selected component in specified display state//from default red to green; this is the overriding colorappearances = (object)swModelDocExt.get_DisplayStateSpecMaterialPropertyValues(swDisplayStateSetting);appearancesArray = (object[])appearances;swAppearanceSetting = (AppearanceSetting)appearancesArray[0];red_rgb = 0;green_rgb = 255;blue_rgb = 0;newColor = Math.Max(Math.Min(red_rgb, 255), 0) + Math.Max(Math.Min(green_rgb, 255), 0) * 16 * 16 + Math.Max(Math.Min(blue_rgb, 255), 0) * 16 * 16 * 16 * 16;swAppearanceSetting.Color = newColor;newAppearanceSetting[0] = swAppearanceSetting;swModelDocExt.set_DisplayStateSpecMaterialPropertyValues(swDisplayStateSetting, newAppearanceSetting);System.Diagnostics.Debugger.Break();//Examine the graphics area//Press F5 to continue//Close the part document without saving//changesswApp.CloseDoc("usb_cover1");}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;}
}
//This example shows how to get a model's scene and get and set some scene properties.//----------------------------------------------------------------------------
// Preconditions:
// 1. Open a model document.
// 2. Open an Immediate window.
//
// Postconditions: Inspect the Immediate window.
// ---------------------------------------------------------------------------
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
namespace Scene_CSharp.csproj
{partial class SolidWorksMacro{SWScene Scene;ModelDoc2 swModel;Configuration swConfig;MathPoint swPoint;MathVector swVector;double[] point;double[] vect;public void Main(){swModel = (ModelDoc2)swApp.ActiveDoc;swConfig = (Configuration)swModel.GetActiveConfiguration();Debug.Print("Configuration: " + swConfig.Name);Scene = swConfig.GetScene();string P2SFilename = null;Scene.GetP2SFileName(ref P2SFilename);Debug.Print("Scene file: " + P2SFilename);Debug.Print("Scene background top gradient color: " + Scene.BackgroundTopGradientColor);Debug.Print("Scene background bottom gradient color: " + Scene.BackgroundBottomGradientColor);Scene.GetFloorNormal(ref swPoint, ref swVector);point = (double[])swPoint.ArrayData;Debug.Print("Scene floor normal point: " + point[0] + ", " + point[1] + ", " + point[2]);vect = (double[])swVector.ArrayData;Debug.Print("Scene floor normal vector: " + vect[0] + ", " + vect[1] + ", " + vect[2]);Scene.BackgroundType = (int)swSceneBackgroundType_e.swBackgroundType_UseEnvironment;Debug.Print("Type of scene background as defined in swSceneBackgroundType_e: " + Scene.BackgroundType);Debug.Print("Scene background environment image file: " + Scene.BackgroundEnvImage);Debug.Print("Scene background image file: " + Scene.BackgroundImage);Debug.Print("Scene environment rotation: " + Scene.EnvironmentRotation);Scene.FitToSWWindow = true;Debug.Print("Stretch to fit in SOLIDWORKS window? " + Scene.FitToSWWindow);Debug.Print("Scale the scene floor uniformly? " + Scene.FixedAspectRatio);Debug.Print("Flip the scene floor direction? " + Scene.FloorDirection);Debug.Print("Automatically resize the scene floor based on the model bounding box? " + Scene.FloorAutoSize);Debug.Print("Distance between scene floor and model: " + Scene.FloorOffset);Debug.Print("Flip the scene floor offset direction? " + Scene.FloorOffsetDirection);Scene.FloorReflections = true;Debug.Print("Show model reflections on the scene floor? " + Scene.FloorReflections);Debug.Print("Scene floor rotation: " + Scene.FloorRotation);Debug.Print("Show model shadows on the scene floor? " + Scene.FloorShadows);Debug.Print("Keep the scene background when changing the scene? " + Scene.KeepBackground);Scene.FlattenFloor = true;Debug.Print("Flatten the scene floor of the spherical environment? " + Scene.FlattenFloor);Debug.Print("Horizon height: " + Scene.HorizonHeight);Debug.Print("Environment size: " + Scene.EnvironmentSize);}public SldWorks swApp;}
}
//This example shows how to add a derived configuration for each existing configuration.//---------------------------------------------------------------------------
// Preconditions: Open a part or assembly.
//
// Postconditions: For each configuration, adds and selects a derived
// configuration.
//
// NOTE: IConfigurationManager::AddConfiguration returns
// Nohting or null if the new configuration already exists.
//---------------------------------------------------------------------------
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;
namespace SelectConfiguration_CSharp.csproj
{partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel = default(ModelDoc2);string[] vConfigNameArr = null;Configuration swConf = default(Configuration);ConfigurationManager swConfMgr = default(ConfigurationManager);Configuration swDerivConf = default(Configuration);bool bRet = false;int i;swModel = (ModelDoc2)swApp.ActiveDoc;swConfMgr = swModel.ConfigurationManager;swConf = swConfMgr.ActiveConfiguration;vConfigNameArr = (string[])swModel.GetConfigurationNames();for (i = 0; i <= vConfigNameArr.GetUpperBound(0); i++) {swConf = (Configuration)swModel.GetConfigurationByName(vConfigNameArr[i]);// Nothing or null if (derived) configuration already existsswDerivConf = swConfMgr.AddConfiguration(swConf.Name + " Derived", "Derived comment", "Derived alternate name", 1, swConf.Name, "Derived description");bRet = swDerivConf.Select2(true, null);}}public SldWorks swApp;}}
IConfiguration Interface相关推荐
- 实现一个基于 IConfiguration 的低配版 FeatureFlag
实现一个基于 IConfiguration 的低配版 FeatureFlag Intro 在我们的应用中,可能有一些配置开关的需求,某些功能是否启用使用一个配置开关,用的时候就打开,不用的时候就关掉, ...
- 【USB笔记】接口描述符Interface Descriptor
USB笔记 接口描述符 (Interface Descriptor) 接口描述符(Interface Descriptor)描述了配置中一个特定的接口.配置提供了一个或多个接口,每个接口都含有类(Cl ...
- Go 学习笔记(71)— Go 接口 interface (接口定义、接口实现、接口调用、值接收者、指针接收者)
1. 接口的定义 接口是和调用方的一种约定,它是一个高度抽象的类型,不用和具体的实现细节绑定在一起.接口要做的是定义好约定,告诉调用方自己可以做什么,但不用知道它的内部实现,这和我们见到的具体的类型如 ...
- Static interface methods are only supported starting with Android N (--min-api 24): void okhttp3.log
错误内容如下 Error: Static interface methods are only supported starting with Android N (--min-api 24): vo ...
- Go 学习笔记(35)— Go 接口 interface (接口声明、接口初始化、接口方法调用、接口运算、类型断言、类型查询、空接口)
1. 接口概念 接口是双方约定的一种合作协议.接口实现者不需要关心接口会被怎样使用,调用者也不需要关心接口的实现细节.接口是一种类型,也是一种抽象结构,不会暴露所含数据的格式.类型及结构. 接口内部存 ...
- Go 学习笔记(4)— Go 标识符、数据类型之间转换、布尔型、整型、浮点型、interface 类型
1. 标识符整体分类 Go 标识符整体分类如下图所示: 2. 数据类型分类 Go 语言按类别有以下几种数据类型: 类型 描述 布尔型 布尔型的值只可以是常量 true 或者 false 数字类型 整型 ...
- php 类 接口的区别吗,PHP的接口类(interface)和抽象类(abstract)的区别
/** * 接口类:interface * 其实他们的作用很简单,当有很多人一起开发一个项目时,可能都会去调用别人写的一些类, * 那你就会问,我怎么知道他的某个功能的实现方法是怎么命名的呢,这个时候 ...
- java interface list_你了解注解内的@interface List么
Annotation, Multi-valued annotation, nested annotation, 多值注解, 嵌套注解 今天在研究Spring MVC的Validation机制时(这里 ...
- TypeScript学习笔记之 接口(Interface)
在java中,接口是用来定义一些规范,使用这些接口,就必须实现接口中的方法,而且接口中的属性必须是常量. javascript中是没有接口的概念的.所以TypeScript在编译成 JavaScrip ...
最新文章
- JQUERY打造隐藏在左侧的弹性弹出菜单
- 深度学习目标检测法进化史,看这一篇就够了
- 病毒导致win2003服务器共享丢失业务中断
- amazon mws api 获取所有产品_Amazon’s Choice是什么?Amazon's Choice标签全解读
- 合并分支到master上
- Zookeeper分布式一致性原理(九):Zookeeper分布式应用
- 安卓开发必须会的技能!浅谈Android消息机制原理,威力加强版
- 设置DIV半透明CSS代码:
- Java并发编程之并发容器ConcurrentHashMap(JDK1.8)解析
- 鞍山楷邦计算机学院,计算机专业和平面设计专业是一个专业不?
- ARP (地址解析协议)
- 大篆汉字对照表_篆书汉字对照表.pdf
- db2查看数据库端口
- TwinCAT 3 安全门程序
- 换脸算法 X2Face 详解
- tm影像辐射定标_ENVI中TM的辐射定标和大气校正
- 2023年湖北黄石初级工程师职称在哪里报名?评审条件是什么启程别
- 关于找工作---职业规划[转]
- 如何在上传的图片上写字
- 南方科技大学计算机科学研究生,招生 - 计算机科学与工程系 - 南方科技大学
热门文章
- “大学生职业发展与就业指导”心得体会
- 2021最新版的成语小程序源码 内附教程
- flashcharge充电协议_10V2.25A FlashCharge闪充,vivo 22.5W移动电源评测(PB1950)
- 微信发送视频不能大于25m怎么办?
- Java 基础面试题——运算符
- 关于时间格式 GMT,UTC,CST,ISO
- matlab wchar_t,C++中wchar_t与wstring理解及中文编码的处理
- 认识系统函数$test$plusargs与$value$plusargs
- 加解密算法的概述和总结
- ppt转换成html 2010,如何把PowerPoint 2010另存为htm或mht等网页格式