Exemplo n.º 1
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // The public static method to start the demo
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        public static void Demo()
        {
            Inventor.Application InvApp = AdnInventorUtilities.InvApplication;

            object selection = InvApp.CommandManager.Pick(
                SelectionFilterEnum.kPartBodyFilter,
                "Select a SurfaceBody: ");

            if (selection == null)
            {
                return;
            }

            SurfaceBody body = selection as SurfaceBody;

            AdnClientGraphicsManager clientGraphicsMng = new AdnClientGraphicsManager(
                InvApp,
                AdnInventorUtilities.AddInGuid);

            GraphicsNode node = clientGraphicsMng.CreateNewGraphicsNode();

            foreach (Edge edge in body.Edges)
            {
                CurveGraphics graphic = clientGraphicsMng.DrawCurve(edge.Geometry, node);

                graphic.LineWeight         = 5.0;
                graphic.Parent.RenderStyle = InvApp.ActiveDocument.RenderStyles["Red"];
            }

            clientGraphicsMng.UpdateView();
        }
Exemplo n.º 2
0
        void DoDemo()
        {
            Inventor.Application InvApp = AdnInventorUtilities.InvApplication;

            _interactionManager = new AdnInteractionManager(InvApp);

            _interactionManager.Initialize();

            _interactionManager.SelectEvents.SingleSelectEnabled = true;

            _interactionManager.OnTerminateEvent +=
                new AdnInteractionManager.OnTerminateHandler(OnTerminateEvent);

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

            _interactionManager.AddSelectionFilter(SelectionFilterEnum.kPartFacePlanarFilter);
            _interactionManager.AddSelectionFilter(SelectionFilterEnum.kWorkPlaneFilter);

            _interactionManager.Start("Select workplane/planar face: ");

            _clientGraphicsMng = new AdnClientGraphicsManager(
                AdnInventorUtilities.InvApplication,
                AdnInventorUtilities.AddInGuid);

            _clientGraphicsMng.SetGraphicsSource(
                _interactionManager.InteractionEvents);

            _curveGraph = null;

            _mode = SelectModeEnum.kPlaneSelect;
        }
Exemplo n.º 3
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;
            }
        }
        //////////////////////////////////////////////////////////////////////////////////////////////
        // Creates a new GraphicsNode that contains our graphic symbol
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        GraphicsNode DrawSymbol(
            UnitVector normal,
            Point center,
            double radius)
        {
            Circle circle = _Tg.CreateCircle(center, normal, radius);

            double[] up    = new double[] { center.X, center.Y + radius, 0 };
            double[] down  = new double[] { center.X, center.Y - radius, 0 };
            double[] right = new double[] { center.X + radius, center.Y, 0 };
            double[] left  = new double[] { center.X - radius, center.Y, 0 };

            GraphicsNode node = _clientGraphicsMng.CreateNewGraphicsNode();

            node.Selectable = true;

            CurveGraphics curve    = _clientGraphicsMng.DrawCurve(circle, node);
            LineGraphics  lineVert = _clientGraphicsMng.DrawLine(up, down, node);
            LineGraphics  lineHorz = _clientGraphicsMng.DrawLine(left, right, node);

            return(node);
        }
        public CurveGraphics DrawCurve(
            object curve,
            GraphicsNode node)
        {
            try
            {
                AdnGraphics graphicsData = WorkingGraphics;

                if (node == null)
                {
                    node = graphicsData.ClientGraphics.AddNode(
                        graphicsData.GetGraphicNodeFreeId());
                }

                CurveGraphics graphic = node.AddCurveGraphics(curve);

                return(graphic);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 6
0
        void DoDemo()
        {
            Inventor.Application InvApp = AdnInventorUtilities.InvApplication;

            _interactionManager = new AdnInteractionManager(InvApp);

            _interactionManager.Initialize();

            _interactionManager.SelectEvents.SingleSelectEnabled = true;

            _interactionManager.OnTerminateEvent += 
                new AdnInteractionManager.OnTerminateHandler(OnTerminateEvent);

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

            _interactionManager.AddSelectionFilter(SelectionFilterEnum.kPartFacePlanarFilter);
            _interactionManager.AddSelectionFilter(SelectionFilterEnum.kWorkPlaneFilter);

            _interactionManager.Start("Select workplane/planar face: ");

            _clientGraphicsMng = new AdnClientGraphicsManager(
                AdnInventorUtilities.InvApplication,
                AdnInventorUtilities.AddInGuid);

            _clientGraphicsMng.SetGraphicsSource(
                _interactionManager.InteractionEvents);

            _curveGraph = null;

            _mode = SelectModeEnum.kPlaneSelect;
        }
Exemplo n.º 7
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;
            }
        }