Example #1
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        //
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void SelectEvents_OnSelect(
            ObjectsEnumerator JustSelectedEntities,
            SelectionDeviceEnum SelectionDevice,
            Point ModelPosition,
            Point2d ViewPosition,
            View View)
        {
            switch (_mode)
            {
            case SelectModeEnum.kPlaneSelect:
            {
                _plane = AdnInventorUtilities.GetPlane(JustSelectedEntities[1]);

                _interactionManager.MouseEvents.MouseMoveEnabled = true;

                _interactionManager.ClearSelectionFilters();

                _interactionManager.AddSelectionFilter(SelectionFilterEnum.kPartVertexFilter);
                _interactionManager.AddSelectionFilter(SelectionFilterEnum.kWorkPointFilter);

                _interactionManager.InteractionEvents.StatusBarText = "Select center: ";

                _mode = SelectModeEnum.kCenterSelect;

                break;
            }

            case SelectModeEnum.kCenterSelect:
            {
                _center = AdnInventorUtilities.GetPoint(JustSelectedEntities[1]);

                Circle circle = AdnInventorUtilities.InvApplication.TransientGeometry.CreateCircle(
                    _center,
                    _plane.Normal,
                    0.001);

                _curveGraph = _clientGraphicsMng.DrawCurve(circle);

                _curveGraph.LineWeight = 0.5;

                _interactionManager.InteractionEvents.StatusBarText = "Select radius: ";

                _interactionManager.MouseEvents.OnMouseMove +=
                    new MouseEventsSink_OnMouseMoveEventHandler(MouseEvents_OnMouseMove);

                _interactionManager.SelectEvents.OnSelect -=
                    new SelectEventsSink_OnSelectEventHandler(SelectEvents_OnSelect);

                _mode = SelectModeEnum.kRadiusSelect;

                break;
            }

            default:
                break;
            }
        }
        //////////////////////////////////////////////////////////////////////////////////////////////
        // First selection will be a planar face or workplane used as slicing plane
        // Subsequent selections will be graphic node, so we switch nodes visibility
        //   to reverse the normal of slicing plane
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void SelectEvents_OnSelect(
            ObjectsEnumerator JustSelectedEntities,
            SelectionDeviceEnum SelectionDevice,
            Point ModelPosition,
            Point2d ViewPosition,
            View View)
        {
            if (JustSelectedEntities[1] is GraphicsNode)
            {
                SwitchNodesVisibility();
                return;
            }

            _interactionManager.ClearSelectionFilters();

            SetModelVisibility(false);

            switch (AdnInventorUtilities.InvApplication.ActiveDocument.DocumentType)
            {
            case DocumentTypeEnum.kAssemblyDocumentObject:

                foreach (ComponentOccurrence occurrence in _compDef.Occurrences)
                {
                    occurrence.Visible = false;
                }
                break;

            case DocumentTypeEnum.kPartDocumentObject:

                foreach (KeyValuePair <SurfaceBody, SurfaceBody> pair in _surfaceBodies)
                {
                    pair.Key.Visible = false;
                }
                break;

            default:
                return;
            }

            Plane plane1 = AdnInventorUtilities.GetPlane(JustSelectedEntities[1]);

            _nodes1 = CreateSlicedNodes(plane1, false);

            Vector normal2 = plane1.Normal.AsVector();

            normal2.ScaleBy(-1.0);

            Plane plane2 =
                AdnInventorUtilities.InvApplication.TransientGeometry.CreatePlane(
                    plane1.RootPoint,
                    normal2);

            _nodes2 = CreateSlicedNodes(plane2, true);

            _clientGraphicsMng.UpdateView();
        }