Pick an element in .Net program

 
Parents
  • Hey samho_atom, is there any difference if I run this in E3D instead of PDMS?
    Thanks!

    [QUOTE=samho_atom;44121]Hi binford6000
    A PML.NET object is created and added to the EDG packet's action. EDG is then started from .NET by adding the packet. The packet's action can then raise events witch can be handled in .NET.
    First - you must create a "PickAddIn.dll"  , see below code.
    Second - call start() and add event to your code.

    using System;
    using System.Collections.Generic;
    using System.Text;
    using Aveva.PDMS.PMLNet;
    using Aveva.Pdms.Geometry;
    using Aveva.Pdms.Utilities.CommandLine;
    using Aveva.Pdms.Database;

    namespace Aveva.PickAddIn
    {
       ///
       /// Pick point
       ///
       [PMLNetCallable()]
       public class PickPoint
       {
           public delegate void PointSelectedHandler(double x, double y, double z);

           private static event PointSelectedHandler mPointSelected;

           public static event PointSelectedHandler PointSelected
           {
               add
               {
                   if (mPointSelected == null)
                       Start();

                   mPointSelected += value;
               }
               
               remove
               {
                   mPointSelected -= value;

                   if (mPointSelected == null)
                       End();
               }
           }

           ///
           /// Public constructor. Should be called only from PML environment.
           ///
           [PMLNetCallable()]
           public PickPoint()
           {
           }

            ///
           /// PMLNetCallable required method
           ///
           ///
           [PMLNetCallable()]
           public void Assign(PickPoint that)
           {
           }

           ///
           /// Entry point method for selected point. The method is called only from PML environment.
           ///
           /// x coordinate
           /// y coordinate
           /// z coordinate
           [PMLNetCallable()]
           public void PmlPointSelected(double x, double y, double z)
           {
               if (mPointSelected != null)
               {
                   mPointSelected(x, y, z);
               }
           }

           ///
           /// Static initialization method.
           ///
           ///
           private static bool Init()
           {
               Command.CreateCommand("import 'PickAddIn'").RunInPdms();
               return true;
           }


           public static void Start()
           {
               if (mInitialized == false)
                   mInitialized = Init();

               //RefElement = null;

               Command.CreateCommand("!!edgCntrl.remove('CONTOUREDITOR')").RunInPdms();
               Command.CreateCommand("!packet = object EDGPACKET()").RunInPdms();
               Command.CreateCommand("!packet.definePosition('Pick Position') !packet.description = 'CONTOUREDITOR'").RunInPdms();
               Command.CreateCommand("using namespace 'Aveva.PickAddIn'").RunInPdms();
               Command.CreateCommand("!!ContourEditor = object PickPoint()").RunInPdms();
               
               if (RefElement != null && RefElement.IsValid)
               {
                   string name = RefElement.GetString(DbAttributeInstance.NAME);
                   Command.CreateCommand(string.Format("!packet.action = '!!ContourEditor.PmlPointSelected(!this.return[1].position.wrt({0}).east, !this.return[1].position.wrt({0}).north, !this.return[1].position.wrt({0}).up)'", name)).RunInPdms();
               }
               else
                   Command.CreateCommand("!packet.action = '!!ContourEditor.PmlPointSelected(!this.return[1].position.east, !this.return[1].position.north, !this.return[1].position.up)'").RunInPdms();

               Command.CreateCommand("!packet.remove = false").RunInPdms();
               Command.CreateCommand("!!edgCntrl.add(!packet)").RunInPdms();
           }

           public static void End()
           {
               Command.CreateCommand("!!edgCntrl.remove('CONTOUREDITOR')").RunInPdms();
           }

           ///
           /// Flag that indicates if object was initialized
           ///
           private static bool mInitialized = false;


           ///
           /// Reference element for WRT calculation
           ///
           public static DbElement RefElement = null;

         }
    }
Reply
  • Hey samho_atom, is there any difference if I run this in E3D instead of PDMS?
    Thanks!

    [QUOTE=samho_atom;44121]Hi binford6000
    A PML.NET object is created and added to the EDG packet's action. EDG is then started from .NET by adding the packet. The packet's action can then raise events witch can be handled in .NET.
    First - you must create a "PickAddIn.dll"  , see below code.
    Second - call start() and add event to your code.

    using System;
    using System.Collections.Generic;
    using System.Text;
    using Aveva.PDMS.PMLNet;
    using Aveva.Pdms.Geometry;
    using Aveva.Pdms.Utilities.CommandLine;
    using Aveva.Pdms.Database;

    namespace Aveva.PickAddIn
    {
       ///
       /// Pick point
       ///
       [PMLNetCallable()]
       public class PickPoint
       {
           public delegate void PointSelectedHandler(double x, double y, double z);

           private static event PointSelectedHandler mPointSelected;

           public static event PointSelectedHandler PointSelected
           {
               add
               {
                   if (mPointSelected == null)
                       Start();

                   mPointSelected += value;
               }
               
               remove
               {
                   mPointSelected -= value;

                   if (mPointSelected == null)
                       End();
               }
           }

           ///
           /// Public constructor. Should be called only from PML environment.
           ///
           [PMLNetCallable()]
           public PickPoint()
           {
           }

            ///
           /// PMLNetCallable required method
           ///
           ///
           [PMLNetCallable()]
           public void Assign(PickPoint that)
           {
           }

           ///
           /// Entry point method for selected point. The method is called only from PML environment.
           ///
           /// x coordinate
           /// y coordinate
           /// z coordinate
           [PMLNetCallable()]
           public void PmlPointSelected(double x, double y, double z)
           {
               if (mPointSelected != null)
               {
                   mPointSelected(x, y, z);
               }
           }

           ///
           /// Static initialization method.
           ///
           ///
           private static bool Init()
           {
               Command.CreateCommand("import 'PickAddIn'").RunInPdms();
               return true;
           }


           public static void Start()
           {
               if (mInitialized == false)
                   mInitialized = Init();

               //RefElement = null;

               Command.CreateCommand("!!edgCntrl.remove('CONTOUREDITOR')").RunInPdms();
               Command.CreateCommand("!packet = object EDGPACKET()").RunInPdms();
               Command.CreateCommand("!packet.definePosition('Pick Position') !packet.description = 'CONTOUREDITOR'").RunInPdms();
               Command.CreateCommand("using namespace 'Aveva.PickAddIn'").RunInPdms();
               Command.CreateCommand("!!ContourEditor = object PickPoint()").RunInPdms();
               
               if (RefElement != null && RefElement.IsValid)
               {
                   string name = RefElement.GetString(DbAttributeInstance.NAME);
                   Command.CreateCommand(string.Format("!packet.action = '!!ContourEditor.PmlPointSelected(!this.return[1].position.wrt({0}).east, !this.return[1].position.wrt({0}).north, !this.return[1].position.wrt({0}).up)'", name)).RunInPdms();
               }
               else
                   Command.CreateCommand("!packet.action = '!!ContourEditor.PmlPointSelected(!this.return[1].position.east, !this.return[1].position.north, !this.return[1].position.up)'").RunInPdms();

               Command.CreateCommand("!packet.remove = false").RunInPdms();
               Command.CreateCommand("!!edgCntrl.add(!packet)").RunInPdms();
           }

           public static void End()
           {
               Command.CreateCommand("!!edgCntrl.remove('CONTOUREDITOR')").RunInPdms();
           }

           ///
           /// Flag that indicates if object was initialized
           ///
           private static bool mInitialized = false;


           ///
           /// Reference element for WRT calculation
           ///
           public static DbElement RefElement = null;

         }
    }
Children
No Data