예제 #1
0
 /// <summary>
 /// Метод закрытия программы KOMPAS-3D.
 /// </summary>
 public void CloseKompas3D()
 {
     if (KsDocumentObj != null)
     {
         CloseDocument();
     }
     try
     {
         KompasObj.Quit();
     }
     catch
     {
         throw new NullReferenceException();
     }
 }
예제 #2
0
 /// <summary>
 /// Метод, открывающий программу KOMPAS-3D.
 /// </summary>
 public void OpenKompas3D()
 {
     if (KompasObj == null)
     {
         var type = Type.GetTypeFromProgID("KOMPAS.Application.5");
         KompasObj = (KompasObject)Activator.CreateInstance(type);
     }
     if (KompasObj != null)
     {
         try
         {
             KompasObj.Visible = true;
             KompasObj.ActivateControllerAPI();
         }
         catch (Exception)
         {
             throw new Exception();
         }
     }
 }
예제 #3
0
 /// <summary>
 /// Метод создания документа.
 /// </summary>
 public void CreateDocument()
 {
     try
     {
         if (KompasObj != null)
         {
             CloseDocument();
             if (KsDocumentObj == null)
             {
                 KsDocumentObj = (ksDocument3D)KompasObj.Document3D();
                 KsDocumentObj.Create(false, false);
                 KsDocumentObj = (ksDocument3D)KompasObj.ActiveDocument3D();
             }
         }
         else
         {
             throw new Exception();
         }
     }
     catch (Exception)
     {
         throw new NullReferenceException(@"Сначала откройте KOMPAS 3D");
     }
 }