Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Diagrams

Example 1

  • Last UpdatedDec 01, 2022
  • 1 minute read

using System;

using Visio=Microsoft.Office.Interop.Visio;

using Aveva.Diagrams;

namespace UserAddin

{

  /// <summary>

  /// Summary description for AccessVisio.

  /// </summary>

  internal class AccessVisio

  {

     internal AccessVisio()

      {

         //

         // TODO: Add constructor logic here

         //

      }

  internal static bool IsDrawingActive()

  {

     System.Reflection.Assembly _assembly =         System.Reflection.Assembly.Load( "diagrams" );

     System.Type _type = _assembly.GetType(        "Aveva.Diagrams.diagApp",

                    true,

                    false );

     System.Reflection.MethodInfo _info = _type.GetMethod(                                   "GetCurrentVisio",

                                  System.Reflection.BindingFlags.Static |

                                  System.Reflection.BindingFlags.Public );

     Visio.Application visApp = (Visio.Application)_info.Invoke
                                 ( null, null );

     if(visApp == null)

         return false;

    return true;

  }

  internal static void AddDescription(string ElemType, string Description)

  {

     System.Reflection.Assembly _assembly =      System.Reflection.Assembly.Load( "diagrams" );

     System.Type _type = _assembly.GetType(     

"AvevaDiagrams.diagApp",

                  true,

                  false );

     System.Reflection.MethodInfo _info = _type.GetMethod(                                   "GetCurrentVisio",

                                  System.Reflection.BindingFlags.Static |

                                  System.Reflection.BindingFlags.Public );

     Visio.Application visApp = (Visio.Application)_info.Invoke( null, null );

     if(visApp == null)

          return;

   //Find all shapes of type ElemType and add Description

   foreach(Visio.Shape shape in visApp.ActivePage.Shapes)

   {

      try

     {

                     if(shape.get_CellsU("User.ElementType").get_ResultStr
       (Visio.VisUnitCodes.visNoCast) == ElemType)

         {

            try

             {

                     shape.get_CellsU("Prop.VMD_SCEQUI_DESC").FormulaU =

               string.Format("\"{0}\"", Description);

             }

             catch(Exception){};

         }

       }

       catch(Exception){};

     }

    }

  }

}

Another approach is to use the AVEVA.ApplicationFramework.Presentation.WindowManager and iterate through the windows looking for an active Drawing Control.

TitleResults for “How to create a CRG?”Also Available in