IConfigurationManager Interface

Solidworks学习笔记-链接Solidworks

属性

NameDescription备注
ActiveConfigurationGets the active configuration.  获取活动配置。
DocumentGets the related model document.  获取相关模型文档。
EnableConfigurationTreeGets or sets whether to update the ConfigurationManager tree.  获取或设置是否更新 ConfigurationManager 树。
LinkDisplayStatesToConfigurationsGets or sets whether to link or unlink display states to or from the active configuration.  获取或设置是将显示状态链接到活动配置还是从活动配置取消链接。
ShowConfigurationDescriptionsGets or sets whether to display configuration descriptions in ConfigurationManager.  获取或设置是否在 ConfigurationManager 中显示配置描述。
ShowConfigurationNamesGets or sets whether to display configuration names in ConfigurationManager.  获取或设置是否在 ConfigurationManager 中显示配置名称。
ShowPreviewGets or sets whether to display the preview of a selected configuration.  获取或设置是否显示选定配置的预览。

//This example shows how to traverse an assembly at the component and feature levels //using recursion.

//--------------------------------------------------------------------------
// Preconditions: 
// 1. Open an assembly document containing nested subassemblies.
// 2. Open the Immediate window.
//
// Postconditions: 
// 1. Traverses the assembly.
// 2. Examine the Immediate Window.
//---------------------------------------------------------------------------

using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System;
using System.Diagnostics;
namespace RecursiveTraverseAssemblyCSharp.csproj
{
 
    public partial class SolidWorksMacro
    {
 
        public void TraverseFeatureFeatures(Feature swFeat, long nLevel)
        {
            Feature swSubFeat;
            Feature swSubSubFeat;
            Feature swSubSubSubFeat;
            string sPadStr = " ";
            long i = 0;
 
            for (i = 0; i <= nLevel; i++)
            {
                sPadStr = sPadStr + " ";
            }
            while ((swFeat != null))
            {
                Debug.Print(sPadStr + swFeat.Name + " [" + swFeat.GetTypeName2() + "]");
                swSubFeat = (Feature)swFeat.GetFirstSubFeature();
 
                while ((swSubFeat != null))
                {
                    Debug.Print(sPadStr + "  " + swSubFeat.Name + " [" + swSubFeat.GetTypeName() + "]");
                    swSubSubFeat = (Feature)swSubFeat.GetFirstSubFeature();
 
                    while ((swSubSubFeat != null))
                    {
                        Debug.Print(sPadStr + "    " + swSubSubFeat.Name + " [" + swSubSubFeat.GetTypeName() + "]");
                        swSubSubSubFeat = (Feature)swSubSubFeat.GetFirstSubFeature();
 
                        while ((swSubSubSubFeat != null))
                        {
                            Debug.Print(sPadStr + "      " + swSubSubSubFeat.Name + " [" + swSubSubSubFeat.GetTypeName() + "]");
                            swSubSubSubFeat = (Feature)swSubSubSubFeat.GetNextSubFeature();
 
                        }
 
                        swSubSubFeat = (Feature)swSubSubFeat.GetNextSubFeature();
 
                    }
 
                    swSubFeat = (Feature)swSubFeat.GetNextSubFeature();
 
                }
 
                swFeat = (Feature)swFeat.GetNextFeature();
 
            }
 
        }
 
        public void TraverseComponentFeatures(Component2 swComp, long nLevel)
        {
            Feature swFeat;
 
            swFeat = (Feature)swComp.FirstFeature();
            TraverseFeatureFeatures(swFeat, nLevel);
        }
        public void TraverseComponent(Component2 swComp, long nLevel)
        {
            object[] vChildComp;
            Component2 swChildComp;
            string sPadStr = " ";
            long i = 0;
 
            for (i = 0; i <= nLevel - 1; i++)
            {
                sPadStr = sPadStr + " ";
            }
 
            vChildComp = (object[])swComp.GetChildren();
            for (i = 0; i < vChildComp.Length; i++)
            {
                swChildComp = (Component2)vChildComp[i];
                Debug.Print(sPadStr + "+" + swChildComp.Name2 + " <" + swChildComp.ReferencedConfiguration + ">");
 
                TraverseComponentFeatures(swChildComp, nLevel);
                TraverseComponent(swChildComp, nLevel + 1);
            }
        }
        public void TraverseModelFeatures(ModelDoc2 swModel, long nLevel)
        {
            Feature swFeat;
 
            swFeat = (Feature)swModel.FirstFeature();
            TraverseFeatureFeatures(swFeat, nLevel);
        }
        public void Main()
        {
 
            ModelDoc2 swModel;
            ConfigurationManager swConfMgr;
            Configuration swConf;
            Component2 swRootComp;
 
            swModel = (ModelDoc2)swApp.ActiveDoc;
            swConfMgr = (ConfigurationManager)swModel.ConfigurationManager;
            swConf = (Configuration)swConfMgr.ActiveConfiguration;
            swRootComp = (Component2)swConf.GetRootComponent();
 
            System.Diagnostics.Stopwatch myStopwatch = new Stopwatch();
            myStopwatch.Start();
 
            Debug.Print("File = " + swModel.GetPathName());
 
            TraverseModelFeatures(swModel, 1);
 
            if (swModel.GetType() == (int)swDocumentTypes_e.swDocASSEMBLY)
            {
                TraverseComponent(swRootComp, 1);
            }
 
            myStopwatch.Stop();
            TimeSpan myTimespan = myStopwatch.Elapsed;
            Debug.Print("Time = " + myTimespan.TotalSeconds + " sec");
 
        }
 
 
        /// <summary> 
        /// The SldWorks swApp variable is pre-assigned for you. 
        /// </summary> 
        public SldWorks swApp;
    }
 
}
This example shows how to link and unlink display states to and from configurations.

// ---------------------------------------------
// Preconditions: 
// 1. Open public_documents\samples\tutorial\pdmworks\speaker.sldasm
// 2. Open the Immediate window.
//
// Postconditions:
// 1. Gets and sets whether display states are linked to the
//    active configuration.
// 2. Closes the assembly document without saving
//    any changes.
//-----------------------------------------------
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 LinkDisplayStatesToConfigurationCSharp.csproj
{
    partial class SolidWorksMacro
    {
        public void Main()
        {
            ModelDoc2 swModel = default(ModelDoc2);
            ConfigurationManager swConfigMgr = default(ConfigurationManager);
            string assemblyName = null;

            swModel = (ModelDoc2)swApp.ActiveDoc;
            Debug.Print("");

            swConfigMgr = (ConfigurationManager)swModel.ConfigurationManager;
            swConfigMgr.LinkDisplayStatesToConfigurations = false;
            Debug.Print("Are display states linked to configurations? " + swConfigMgr.LinkDisplayStatesToConfigurations);
            if (!swConfigMgr.LinkDisplayStatesToConfigurations)
            {
                Debug.Print("All display states are available to the active configuration.");
            }

            swConfigMgr.LinkDisplayStatesToConfigurations = true;
            Debug.Print("Are display states linked configurations? " + swConfigMgr.LinkDisplayStatesToConfigurations);
            if (swConfigMgr.LinkDisplayStatesToConfigurations)
            {
                Debug.Print("All display states are not available to the active configuration.");
            }

            assemblyName = swModel.GetTitle();
            swApp.QuitDoc(assemblyName);
        }

        /// <summary>
        /// The SldWorks swApp variable is pre-assigned for you.
        /// </summary>

        public SldWorks swApp;

    }
}

方法

NameDescription备注
AddConfiguration2Creates a new configuration.  创建新配置。
AddRebuildSaveMarkAdds marks indicating whether the specified configurations need to be rebuilt and their configuration data saved every time the model document is saved.  添加标记,指示每次保存模型文档时是否需要重新构建指定的配置及其配置数据。
AddSpeedPak2Creates a SpeedPak configuration that includes all faces and the specified threshold of parts or bodies for the active assembly configuration.  创建 SpeedPak 配置,其中包括活动装配配置的所有面和零件或实体的指定阈值。
GetConfigurationParamsGets the parameters for this configuration.  获取此配置的参数。
GetConfigurationParamsCountGets the number of parameters for this configuration.  获取此配置的参数数量。
IGetConfigurationParamsGets the parameters for this configuration.  获取此配置的参数。
ISetConfigurationParamsSets the parameters for this configuration.  设置此配置的参数。
RemoveMarkForAllConfigurationsRemove all marks indicating whether configurations need to be rebuilt and their configuration data saved every time the model document is saved.  每次保存模型文档时,删除所有指示是否需要重建配置和保存配置数据的标记。
SetConfigurationParamsSets the parameters for this configuration.  设置此配置的参数。
SetExpandedSets whether to display and expand all of the configuration nodes in the specified pane of the ConfigurationManager.  设置是否在 ConfigurationManager 的指定窗格中显示和展开所有配置节点。
SortConfigurationTreeSpecifies the order in which to list configurations in the ConfigurationManager.  指定在 ConfigurationManager 中列出配置的顺序。
This example shows how to link and unlink display states to and from configurations.

// ---------------------------------------------
// Preconditions: 
// 1. Open public_documents\samples\tutorial\pdmworks\speaker.sldasm
// 2. Open the Immediate window.
//
// Postconditions:
// 1. Gets and sets whether display states are linked to the
//    active configuration.
// 2. Closes the assembly document without saving
//    any changes.
//-----------------------------------------------
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 LinkDisplayStatesToConfigurationCSharp.csproj
{
    partial class SolidWorksMacro
    {
        public void Main()
        {
            ModelDoc2 swModel = default(ModelDoc2);
            ConfigurationManager swConfigMgr = default(ConfigurationManager);
            string assemblyName = null;

            swModel = (ModelDoc2)swApp.ActiveDoc;
            Debug.Print("");

            swConfigMgr = (ConfigurationManager)swModel.ConfigurationManager;
            swConfigMgr.LinkDisplayStatesToConfigurations = false;
            Debug.Print("Are display states linked to configurations? " + swConfigMgr.LinkDisplayStatesToConfigurations);
            if (!swConfigMgr.LinkDisplayStatesToConfigurations)
            {
                Debug.Print("All display states are available to the active configuration.");
            }

            swConfigMgr.LinkDisplayStatesToConfigurations = true;
            Debug.Print("Are display states linked configurations? " + swConfigMgr.LinkDisplayStatesToConfigurations);
            if (swConfigMgr.LinkDisplayStatesToConfigurations)
            {
                Debug.Print("All display states are not available to the active configuration.");
            }

            assemblyName = swModel.GetTitle();
            swApp.QuitDoc(assemblyName);
        }

        /// <summary>
        /// The SldWorks swApp variable is pre-assigned for you.
        /// </summary>

        public SldWorks swApp;

    }
}
This example shows how to specify the order in which to list configurations in the ConfigurationManager.

//-------------------------------------------------------------------------------------
// Preconditions:
// 1. Open public_documents\samples\tutorial\driveworksxpress\mobile gantry.sldasm.
// 2. Click the ConfigurationManager tab and examine the order in which the
//    configurations are listed.
//
// Preconditions:
// 1. Lists the configurations in the specified order.
// 2. Examine the ConfigurationManager tab.
//
// 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;
 
namespace Macro1CSharp.csproj
{
    public partial class SolidWorksMacro
    {
        public void Main()
        {
            ModelDoc2 swModel = default(ModelDoc2);
            ConfigurationManager swConfigMgr = default(ConfigurationManager);
 
            swModel = (ModelDoc2)swApp.ActiveDoc;
            swConfigMgr = (ConfigurationManager)swModel.ConfigurationManager;
            swConfigMgr.SortConfigurationTree((int)swConfigTreeSortType_e.swSortType_Literal);
            swModel.EditRebuild3();
        }
 
        /// <summary>
        ///  The SldWorks swApp variable is pre-assigned for you.
        /// </summary>
        public SldWorks swApp;
    }
}

内容概要:本文档详细介绍了Android开发中内容提供者(ContentProvider)的使用方法及其在应用间数据共享的作用。首先解释了ContentProvider作为四大组件之一,能够为应用程序提供统一的数据访问接口,支持不同应用间的跨进程数据共享。接着阐述了ContentProvider的核心方法如onCreate、insert、delete、update、query和getType的具体功能与应用场景。文档还深入讲解了Uri的结构和作用,它是ContentProvider中用于定位资源的重要标识。此外,文档说明了如何通过ContentResolver在客户端应用中访问其他应用的数据,并介绍了Android 6.0及以上版本的运行时权限管理机制,包括权限检查、申请及处理用户的选择结果。最后,文档提供了具体的实例,如通过ContentProvider读写联系人信息、监听短信变化、使用FileProvider发送彩信和安装应用等。 适合人群:对Android开发有一定了解,尤其是希望深入理解应用间数据交互机制的开发者。 使用场景及目标:①掌握ContentProvider的基本概念和主要方法的应用;②学会使用Uri进行资源定位;③理解并实现ContentResolver访问其他应用的数据;④熟悉Android 6.0以后版本的权限管理流程;⑤掌握FileProvider在发送彩信和安装应用中的应用。 阅读建议:建议读者在学习过程中结合实际项目练习,特别是在理解和实现ContentProvider、ContentResolver以及权限管理相关代码时,多进行代码调试和测试,确保对每个知识点都有深刻的理解。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值