其他分享
首页 > 其他分享> > SolidWorks PDM二次开发---登陆

SolidWorks PDM二次开发---登陆

作者:互联网

打开API帮助文件

我们打开SolidWorks PDM Professional API帮助文件,文件名为API_GB.chm
在这里插入图片描述
查找 一下登陆的关键字: Login
就能发现如下几个关键方法:
在这里插入图片描述

登陆操作


下面是API中对这几个登陆的解释:

  1. Login:Logs in to the specified vault using the specified user name and password.

  2. LoginAuto:Logs in to the specified vault.

  3. LoginEx:Allows an application that is not supplied and supported by SOLIDWORKS Corporation to:

    			log into SOLIDWORKS PDM Professional
    			- or - 
    			log into a vault view
    			- or - 
    			directly access the vault database
    			when the same user is not already logged into a local view.
    
  4. LogInWindowsUser:Logs into SOLIDWORKS PDM Professional as the specified user.

接下来看代码:


			var vault = new EdmVault5();  //新建一库实例
            //检查登陆
            
            #region 登陆方式1
	          	if (!vault.IsLoggedIn)  //检查是否已经登陆
	            {
	                vault.Login("Admin", "XXXXXX", "PDMTraining");                
	            }
            #endregion
          
  			#region 登陆方式2
				//调用PDM自己的登陆界面进行登陆。
            	vault.LoginAuto("PDMTraining",0);
          
            #endregion
            
            #region 登陆方式3
            	//后端静默登陆,适合需要进行提权时进行后台处理。
            	(vault as IEdmVault13).LoginEx("Admin","*****","PDMTraining",0);

            #endregion
            
            #region 登陆方式4
            	//使用windows用户登陆
            	(vault as IEdmVault11).LogInWindowsUser("Admin", "*****", "PDMTraining");

            #endregion		
			  
	

上面就是登陆的一些方法,需要根据实际情况选择。

获取库名


下面再讲一个获取库名称列表的方法:

			#region 获取库列表

            EdmViewInfo[] edmViewInfos = null;
            (vault as IEdmVault13).GetVaultViews(out edmViewInfos, false);

            List<string> vaultNames = new List<string>();

            if (edmViewInfos != null)
            {
                foreach (var edmViewInfo in edmViewInfos)
                {

                    vaultNames.Add(edmViewInfo.mbsVaultName);
                }
            }

            Debug.Print(vaultNames.Count().ToString());

            #endregion

标签:edmViewInfos,endregion,region,---,PDM,登陆,二次开发,vault
来源: https://blog.csdn.net/zengqh0314/article/details/120930334