Page 1 of 1

How to select vertex in v6?

Posted: Tue Sep 24, 2019 6:56 am
by jons882
what is the proper way of selecting a vertex from the view ?
Any ideas?
Thanks

Re: How to select vertex in v6?

Posted: Wed Sep 25, 2019 6:57 am
by Prashant Kande
Hello jons882

Request KernelACDEvent to receive notifications like:

Code: Select all

	    	var iView = DgkControl.GetView() as IView_DG;
            var iContext = iView as IKCContext;
            iContext.SetBoolParam((int)E3DBoolParams.e3DBoolParamWantSelectEvent, true);
Use Advanced > Edit > Select > Vertices in the context menu (right click) and select a rectangle. This raises a KernelACDEvent event as part, which can be handled like:

Code: Select all

	private void OnKernelCADEvent(System.Object sender, _DKernCADnetEvents_KernelCADEventEvent e)
        {
            m_iList = null;   // Type  IList(64). Clear previous selection

            if (e.eventType == (int)EDIEvent.eEventSelection)
            {
                // The user has selected something using direct user access (context menu)
                if ((int)e.param0 == (int)EElemTypeKC.eElTypeVertex)
                    // Case vertices selected. Get the list
                    m_iList = e.param1 as IListT;
            }
        }
To access the elements use something like:

Code: Select all

            IIteratorT iIter = m_iList.GetIterator();
            POSNT pos;
            POSNT n = iIter.GetCount();
            if (n == 0)
                return;
            pos = iIter.GetHeadPosition();

            while (pos != 0)
            {
                var p = m_iList.GetAt(pos);
                IBRepVertex_DG iVtx = Marshal.GetObjectForIUnknown(p) as IBRepVertex_DG;
		// Use iVtx
                iIter.GetNext(ref pos);
            }
This code is from MeshMods sample. MeshMods handles mesh object, but the code is only different by the type of elements in the list. The same code can be used for edges ( IBRepEdge_DG elements in the list) and faces IBRepFace_DG.

For mesh type of geometry the listed types are: IVertex, IEdge_KC(64) and ISimplex depending on e.param0 as EElemTypeKC

To determine the entity, where the elements belong, Query IEntity_DG from the list:

Code: Select all

IEntity_DG iEntity = m_iList  as IEntity_DG;
For completeness: If objects were specified for selection, the list contains ISection elements, from which IEntity_DG can be queried.

Re: How to select vertex in v6?

Posted: Fri Sep 27, 2019 3:36 am
by Prashant Kande
Edges of mesh is a special case. For selection to work the mesh has to be in upgraded state. Otherwise the list will be empty. See http://dynoinsight.com/Help/V6_0/Interf ... IsUpgraded

Re: How to select vertex in v6?

Posted: Mon Sep 30, 2019 4:42 am
by jons882
Thanks, Prashant

Re: How to select vertex in v6?

Posted: Wed Oct 02, 2019 6:55 am
by Prashant Kande
In Yesterdays 5012 update we have also added Selection sample which demoes all that
Cheers