//////////////////////////////////////////////////////////////////////////////////////////////
        // Create a list of GraphicsNode, sliced by the plane argument and set their visibility.
        // A list of nodes is used here, so we can attribute each node a different render style
        // if needed.
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        List <GraphicsNode> CreateSlicedNodes(Plane plane, bool visibility)
        {
            List <GraphicsNode> nodes = new List <GraphicsNode>();

            foreach (KeyValuePair <SurfaceBody, SurfaceBody> pair in _surfaceBodies)
            {
                SurfaceGraphics surfGraph = _clientGraphicsMng.DrawSurface(pair.Value);

                GraphicsNode node = surfGraph.Parent;

                StyleSourceTypeEnum styleSourceType;
                node.RenderStyle = pair.Key.GetRenderStyle(out styleSourceType);

                nodes.Add(node);
            }

            ObjectCollection slicingPlanes =
                AdnInventorUtilities.InvApplication.TransientObjects.CreateObjectCollection(null);

            slicingPlanes.Add(plane);

            foreach (GraphicsNode node in nodes)
            {
                node.SliceGraphics(true, slicingPlanes, false, null);

                node.Visible = visibility;

                node.Selectable = true;
            }

            return(nodes);
        }
        public TextGraphics DrawText(
            string text,
            bool scalable,
            GraphicsNode node)
        {
            try
            {
                AdnGraphics graphicsData = WorkingGraphics;

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

                TextGraphics graphic = (scalable ? node.AddScalableTextGraphics() : node.AddTextGraphics());

                graphic.Text = text;

                return(graphic);
            }
            catch
            {
                return(null);
            }
        }
        public PointGraphics DrawPoint(
            double[] position,
            GraphicsNode node)
        {
            try
            {
                AdnGraphics graphicsData = WorkingGraphics;

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

                PointGraphics graphic = node.AddPointGraphics();

                if (position != null)
                {
                    GraphicsCoordinateSet coordSet =
                        graphicsData.GraphicsDataSets.CreateCoordinateSet(
                            graphicsData.GetDataSetFreeId());

                    coordSet.PutCoordinates(ref position);

                    graphic.CoordinateSet = coordSet;
                }

                return(graphic);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        public void InitializePreviewGraphics()
        {
            m_interactionEvents = m_inventorApplication.CommandManager.CreateInteractionEvents();

            InteractionGraphics interactionGraphics = m_interactionEvents.InteractionGraphics;

            ClientGraphics previewClientGraphics = interactionGraphics.PreviewClientGraphics;

            m_previewClientGraphicsNode = previewClientGraphics.AddNode(1);

            m_triangleStripGraphics = m_previewClientGraphicsNode.AddTriangleStripGraphics();

            GraphicsDataSets graphicsDataSets = interactionGraphics.GraphicsDataSets;

            m_graphicsCoordinateSet = graphicsDataSets.CreateCoordinateSet(1);

            m_graphicsColorSet = graphicsDataSets.CreateColorSet(1);

            m_graphicsColorSet.Add(1, 100, 100, 200);
            m_graphicsColorSet.Add(2, 150, 150, 250);

            m_graphicsColorIndexSet = graphicsDataSets.CreateIndexSet(1);

            m_triangleStripGraphics.CoordinateSet = m_graphicsCoordinateSet;
            m_triangleStripGraphics.ColorSet      = m_graphicsColorSet;
            m_triangleStripGraphics.ColorIndexSet = m_graphicsColorIndexSet;

            m_triangleStripGraphics.ColorBinding = ColorBindingEnum.kPerItemColors;
            m_triangleStripGraphics.BurnThrough  = true;
        }
        public TriangleStripGraphics DrawTriangleStrip(
            double[] coordinates,
            GraphicsNode node)
        {
            try
            {
                AdnGraphics graphicsData = WorkingGraphics;

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

                TriangleStripGraphics graphic = node.AddTriangleStripGraphics();

                if (coordinates != null)
                {
                    GraphicsCoordinateSet coordSet =
                        graphicsData.GraphicsDataSets.CreateCoordinateSet(
                            graphicsData.GetDataSetFreeId());

                    coordSet.PutCoordinates(ref coordinates);

                    graphic.CoordinateSet = coordSet;
                }

                return(graphic);
            }
            catch
            {
                return(null);
            }
        }
        //////////////////////////////////////////////////////////////////////////////////////////////
        // OnMouseDown Event: we create symbol in the sheet graphics by using SetGraphicsSource(sheet)
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void MouseEvents_OnMouseDown(
            MouseButtonEnum Button,
            ShiftStateEnum ShiftKeys,
            Inventor.Point ModelPosition,
            Point2d ViewPosition,
            Inventor.View View)
        {
            if (Button != MouseButtonEnum.kLeftMouseButton)
            {
                return;
            }

            // Define symbol inputs: center, normal, radius

            Point center = ModelPosition;

            UnitVector normal = _Tg.CreateUnitVector(0, 0, 1);

            double radius = _sheet.Width / 30;

            // Add new symbol to the sheet graphics...
            _clientGraphicsMng.SetGraphicsSource(_sheet);

            DrawSymbol(normal, center, radius);

            _clientGraphicsMng.UpdateView();

            _clientGraphicsMng.SetGraphicsSource(
                _interactionManager.InteractionEvents);

            _symbolNode = null;
        }
Exemplo n.º 7
0
        //-----------------------------------------------------------------------------
        //----------------- MoveCmd implement ----------------------------------------
        //-----------------------------------------------------------------------------
        public void InitializePreviewGraphics()
        {
            m_interactionEvents = m_inventorApplication.CommandManager.CreateInteractionEvents();

            InteractionGraphics interactionGraphics = m_interactionEvents.InteractionGraphics;

            ClientGraphics previewClientGraphics = interactionGraphics.PreviewClientGraphics;

            m_previewClientGraphicsNode = previewClientGraphics.AddNode(1);

            m_pointGraphics = m_previewClientGraphicsNode.AddPointGraphics();

            GraphicsDataSets graphicsDateSets = interactionGraphics.GraphicsDataSets;

            m_graphicsCoordinateSet = graphicsDateSets.CreateCoordinateSet(1);

            m_graphicsColorSet = graphicsDateSets.CreateColorSet(1);

            m_graphicsColorSet.Add(1, 255, 0, 0);

            m_graphicsColorIndexSet = graphicsDateSets.CreateIndexSet(1);

            m_pointGraphics.CoordinateSet = m_graphicsCoordinateSet;
            m_pointGraphics.BurnThrough   = true;
        }
Exemplo n.º 8
0
 public override void GraphicsNodeInitialize()
 {
     base.GraphicsNodeInitialize();
     GraphicsNode.txtPropety_AddLine("rate = " + this.rate);
     GraphicsNode.txtPropety_AddLine("noise_shape = " + this.noise_shape);
     GraphicsNode.txtPropety_AddLine("seed = " + this.seed);
 }
Exemplo n.º 9
0
        /// <summary>
        /// When the appropriate rectangle button is clicked the button's OnExecute event handler
        /// calls this method to hook up the mouse click event which will wait for the user to select
        /// a point from which to start the drawing of the rectangle
        /// </summary>
        public virtual void StartRectangleInteraction()
        {
            _interactionEvents = _inventorApplication.CommandManager.CreateInteractionEvents();

            _rectangleInteractionGraphics = _interactionEvents.InteractionGraphics;
            _rectangleClientGraphics      = _rectangleInteractionGraphics.OverlayClientGraphics;
            _rectangleLineNode            = _rectangleClientGraphics.AddNode(1);
            _rectangleGraphicsDataSets    = _rectangleInteractionGraphics.GraphicsDataSets;
            _rectangleCoordSet            = _rectangleGraphicsDataSets.CreateCoordinateSet(1);
            _rectangleIndexSet            = _rectangleGraphicsDataSets.CreateIndexSet(1);

            _onTerminate_Delegate           = new InteractionEventsSink_OnTerminateEventHandler(StopInteraction);
            _interactionEvents.OnTerminate += _onTerminate_Delegate;

            _userInputEvents = _inventorApplication.CommandManager.UserInputEvents;
            _userInputEvents_OnContextMenuDelegate = new UserInputEventsSink_OnContextMenuEventHandler(UserInputEvents_OnContextMenu);
            _userInputEvents.OnContextMenu        += _userInputEvents_OnContextMenuDelegate;

            _mouseEvents = _interactionEvents.MouseEvents;
            _mouseEvents.PointInferenceEnabled = true;
            _onMouseClick_Delegate             = new MouseEventsSink_OnMouseClickEventHandler(OnMouseClick_CreateRectangle);
            _mouseEvents.OnMouseClick         += _onMouseClick_Delegate;

            _interactionEvents.StatusBarText = "Select a Point from which to start the rectangle";

            _interactionEvents.AllowCommandAliases = true;

            _interactionEvents.Start();
        }
Exemplo n.º 10
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        //
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void InsertAsSurfaceGraphics(Matrix transfo)
        {
            Inventor.Application InvApp = AdnInventorUtilities.InvApplication;

            Document document = InvApp.ActiveDocument;

            ComponentDefinition compDef =
                AdnInventorUtilities.GetCompDefinition(document);

            _clientGraphicsMng.SetGraphicsSource(InvApp.ActiveDocument);

            Dictionary <SurfaceBody, SurfaceBody> surfaceBodies =
                AdnInventorUtilities.GetTransientBodies(
                    AdnInventorUtilities.GetCompDefinition(_componentDocument));

            foreach (KeyValuePair <SurfaceBody, SurfaceBody> pair in surfaceBodies)
            {
                SurfaceGraphics surfGraph = _clientGraphicsMng.DrawSurface(pair.Value);

                GraphicsNode node = surfGraph.Parent;

                node.Transformation = transfo;
                node.Selectable     = true;

                StyleSourceTypeEnum styleSourceType;
                node.RenderStyle = pair.Key.GetRenderStyle(out styleSourceType);
            }
        }
Exemplo n.º 11
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();
        }
 public override void GraphicsNodeInitialize()
 {
     base.GraphicsNodeInitialize();
     this.GraphicsNode.NodeByType(Enum.GetName(typeof(LayerTypes), this.Type));
     GraphicsNode.txtPropety_AddLine("p = " + this.p);
     GraphicsNode.txtPropety_AddLine("inplace = " + this.inplace);
 }
Exemplo n.º 13
0
 public override void GraphicsNodeInitialize()
 {
     base.GraphicsNodeInitialize();
     this.GraphicsNode.NodeByType(Enum.GetName(typeof(LayerTypes), this.Type));
     GraphicsNode.txtPropety_AddLine("units = " + this.units);
     GraphicsNode.txtPropety_AddLine("activation = " + this.activation);
 }
        //////////////////////////////////////////////////////////////////////////////////////
        // Use: Returns a new GraphicsNode
        //
        //////////////////////////////////////////////////////////////////////////////////////
        public GraphicsNode CreateNewGraphicsNode()
        {
            AdnGraphics graphicsData = WorkingGraphics;

            GraphicsNode node = graphicsData.ClientGraphics.AddNode(
                graphicsData.GetGraphicNodeFreeId());

            return(node);
        }
        public override void GraphicsNodeInitialize()
        {
            base.GraphicsNodeInitialize();

            GraphicsNode.txtPropety_AddLine("kernel_size = " + kernel_size);
            GraphicsNode.txtPropety_AddLine("strides = " + strides);

            GraphicsNode.txtPropety_AddLine("padding = " + padding);
            GraphicsNode.txtPropety_AddLine("dilation = " + dilation);
        }
        public override void GraphicsNodeInitialize()
        {
            base.GraphicsNodeInitialize();
            GraphicsNode.txtPropety_AddLine("in_channels = " + in_channels);

            GraphicsNode.txtPropety_AddLine("out_channels = " + out_channels);


            GraphicsNode.txtPropety_AddLine("kernel_size = " + kernel_size);
        }
Exemplo n.º 17
0
        //--------------------------------------------------------

        public BlockFormCmd()
        {
            m_blockForm = null;

            m_previewClientGraphicsNode = null;
            m_triangleStripGraphics     = null;
            m_graphicsCoordinateSet     = null;
            m_graphicsColorSet          = null;
            m_graphicsColorIndexSet     = null;
        }
Exemplo n.º 18
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // Set position of a GraphicsNode
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void SetNodePosition(GraphicsNode node, Point position)
        {
            Matrix transfo = node.Transformation;

            Vector Tx = _Tg.CreateVector(
                position.X, position.Y, position.Z);

            transfo.SetTranslation(Tx, false);

            node.Transformation = transfo;
        }
Exemplo n.º 19
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // Set position of a GraphicsNode
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void SetNodePosition(GraphicsNode node, Point position)
        {
            Matrix transfo = node.Transformation;

            Vector Tx = _Tg.CreateVector(
                position.X, position.Y, position.Z);

            transfo.SetTranslation(Tx, false);

            node.Transformation = transfo;
        }
        //////////////////////////////////////////////////////////////////////////////////////////////
        // Description: Displays PointGraphics with various RenderStyles
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        static public void PointGraphicsRenderDemo()
        {
            PartDocument doc =
                AdnInventorUtilities.InvApplication.ActiveDocument
                as PartDocument;

            string clientId = "{Add-in Guid}";

            ClientGraphics   graphics = null;
            GraphicsDataSets dataSets = null;

            try
            {
                graphics = doc.ComponentDefinition.ClientGraphicsCollection[clientId];
                dataSets = doc.GraphicsDataSetsCollection[clientId];
            }
            catch
            {
                graphics = doc.ComponentDefinition.ClientGraphicsCollection.Add(clientId);
                dataSets = doc.GraphicsDataSetsCollection.Add(clientId);
            }

            TransientGeometry Tg = AdnInventorUtilities.InvApplication.TransientGeometry;


            GraphicsNode node = graphics.AddNode(graphics.Count + 1);

            PointGraphics[] pointGraphics = new PointGraphics[4];

            pointGraphics[0] = node.AddPointGraphics();
            pointGraphics[1] = node.AddPointGraphics();
            pointGraphics[2] = node.AddPointGraphics();
            pointGraphics[3] = node.AddPointGraphics();

            pointGraphics[0].PointRenderStyle = PointRenderStyleEnum.kCirclePointStyle;
            pointGraphics[0].CoordinateSet    = dataSets.CreateCoordinateSet(dataSets.Count + 1);
            pointGraphics[0].CoordinateSet.Add(1, Tg.CreatePoint(5, 5, 0));

            pointGraphics[1].PointRenderStyle = PointRenderStyleEnum.kCrossPointStyle;
            pointGraphics[1].CoordinateSet    = dataSets.CreateCoordinateSet(dataSets.Count + 1);
            pointGraphics[1].CoordinateSet.Add(1, Tg.CreatePoint(10, 0, 0));

            pointGraphics[2].PointRenderStyle = PointRenderStyleEnum.kXPointStyle;
            pointGraphics[2].CoordinateSet    = dataSets.CreateCoordinateSet(dataSets.Count + 1);
            pointGraphics[2].CoordinateSet.Add(1, Tg.CreatePoint(5, -5, 0));

            pointGraphics[3].PointRenderStyle = PointRenderStyleEnum.kFilledCircleSelectPointStyle;
            pointGraphics[3].CoordinateSet    = dataSets.CreateCoordinateSet(dataSets.Count + 1);
            pointGraphics[3].CoordinateSet.Add(1, Tg.CreatePoint(0, 0, 0));

            doc.Views[1].Update();
        }
        void DoDemo()
        {
            Inventor.Application InvApp = AdnInventorUtilities.InvApplication;

            if (InvApp.ActiveDocument == null || !(InvApp.ActiveDocument is DrawingDocument))
            {
                System.Windows.Forms.MessageBox.Show(
                    "A Drawing Document must be active...",
                    "Invalid Document Error",
                    System.Windows.Forms.MessageBoxButtons.OK,
                    System.Windows.Forms.MessageBoxIcon.Information);

                return;
            }

            _Tg = InvApp.TransientGeometry;

            _interactionManager = new AdnInteractionManager(InvApp);

            _interactionManager.Initialize();

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

            _interactionManager.MouseEvents.MouseMoveEnabled = true;

            _interactionManager.MouseEvents.OnMouseDown +=
                new MouseEventsSink_OnMouseDownEventHandler(MouseEvents_OnMouseDown);

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

            _interactionManager.Start("Place Symbol: ");

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

            _clientGraphicsMng.Transacting = true;

            _clientGraphicsMng.SetGraphicsSource(
                _interactionManager.InteractionEvents);

            _symbolNode = null;

            DrawingDocument document = InvApp.ActiveDocument as DrawingDocument;

            _sheet = document.ActiveSheet;

            _symbolNode = null;
        }
        //////////////////////////////////////////////////////////////////////////////////////////////
        // Description: Displays a LineGraphics between points [0, 0, 0] and [1, 1, 1].
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        static public void LineGraphicsDemo()
        {
            PartDocument doc =
                AdnInventorUtilities.InvApplication.ActiveDocument
                as PartDocument;

            // ClientId, can be any string
            // Typically use instead current add-in GUID
            string clientId = "{Add-in Guid}";

            // Add a new graphics group.
            // This will fail if a group with same name already exists
            ClientGraphics graphics =
                doc.ComponentDefinition.ClientGraphicsCollection.Add(clientId);

            // Add a new graphic node, with Id=1.
            // Id needs to be unique within graphics group
            GraphicsNode node = graphics.AddNode(1);

            // Add new data set
            GraphicsDataSets dataSets =
                doc.GraphicsDataSetsCollection.Add(clientId);

            // Add new coordinate set
            // Id needs to be unique within data set
            GraphicsCoordinateSet coordSet = dataSets.CreateCoordinateSet(1);

            // Fill up coordinates
            // Point1: [0.0, 0.0, 0.0]
            // Point2: [1.0, 1.0, 1.0]
            double[] coords = new double[]
            {
                0.0, 0.0, 0.0,
                1.0, 1.0, 1.0
            };

            coordSet.PutCoordinates(ref coords);

            // Create new GraphicsPrimitive
            LineGraphics lineGraphPrimitive = node.AddLineGraphics();

            lineGraphPrimitive.LineWeight = 5.0;

            // Set coordinates
            lineGraphPrimitive.CoordinateSet = coordSet;

            // Update the current view, so we see the graphics
            doc.Views[1].Update();
        }
        public GraphicsNode CreateNewGraphicsNode(int customId)
        {
            try
            {
                AdnGraphics graphicsData = WorkingGraphics;

                GraphicsNode node = graphicsData.ClientGraphics.AddNode(customId);

                return(node);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 24
0
        public override void GraphicsNodeInitialize()
        {
            base.GraphicsNodeInitialize();
            GraphicsNode.txtPropety_AddLine("filter = " + filter);
            string temp1 = "";

            temp1 = "kernel_size = (";
            foreach (int i in kernel_size)
            {
                temp1 += i.ToString() + ", ";
            }
            temp1  = temp1.Remove(temp1.LastIndexOf(", "));
            temp1 += ")";
            GraphicsNode.txtPropety_AddLine(temp1);
        }
        //////////////////////////////////////////////////////////////////////////////////////////////
        // Description: Displays a PointGraphics using custom bitmap image.
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        static public void PointGraphicsDemo()
        {
            PartDocument doc =
                AdnInventorUtilities.InvApplication.ActiveDocument
                as PartDocument;

            string clientId = "{Add-in Guid}";

            ClientGraphics   graphics = null;
            GraphicsDataSets dataSets = null;

            try
            {
                graphics = doc.ComponentDefinition.ClientGraphicsCollection[clientId];
                dataSets = doc.GraphicsDataSetsCollection[clientId];
            }
            catch
            {
                graphics = doc.ComponentDefinition.ClientGraphicsCollection.Add(clientId);
                dataSets = doc.GraphicsDataSetsCollection.Add(clientId);
            }

            GraphicsNode node = graphics.AddNode(graphics.Count + 1);

            GraphicsCoordinateSet coordSet = dataSets.CreateCoordinateSet(dataSets.Count + 1);

            double[] coords = new double[]
            {
                5.0, 0.0, 0.0
            };

            coordSet.PutCoordinates(ref coords);

            GraphicsImageSet imageSet = dataSets.CreateImageSet(dataSets.Count + 1);

            stdole.IPictureDisp image =
                PictureDispConverter.ToIPictureDisp(Resources.PointImage);

            imageSet.Add(1, image, null, -1, -1);

            PointGraphics pointGraphPrimitive = node.AddPointGraphics();

            pointGraphPrimitive.CoordinateSet = coordSet;
            pointGraphPrimitive.SetCustomImage(imageSet, 1);

            doc.Views[1].Update();
        }
Exemplo n.º 26
0
        public MoveCmd()
        {
            m_moveCmdDlg = null;

            m_selectFace     = null;
            m_selectiFeature = null;

            m_UCS = null;

            m_previewClientGraphicsNode = null;
            m_pointGraphics             = null;
            m_graphicsCoordinateSet     = null;
            m_graphicsColorSet          = null;
            m_graphicsColorIndexSet     = null;

            m_highlightSet = null;
        }
Exemplo n.º 27
0
            public DimData(
                Point point1,
                Point point2,
                LineGraphics extLine1,
                LineGraphics extLine2,
                LineGraphics dimLine,
                GraphicsNode node)
            {
                Point1 = point1;
                Point2 = point2;

                ExtLine1 = extLine1;
                ExtLine2 = extLine2;
                DimLine  = dimLine;

                DimNode = node;
            }
Exemplo n.º 28
0
            public DimData(
                Point point1,
                Point point2, 
                LineGraphics extLine1, 
                LineGraphics extLine2, 
                LineGraphics dimLine,
                GraphicsNode node)
            {
                Point1 = point1;
                Point2 = point2;

                ExtLine1 = extLine1;
                ExtLine2 = extLine2;
                DimLine = dimLine;

                DimNode = node;
            }
Exemplo n.º 29
0
        private void UpdateData()
        {
            Box rubikBox = mInventorApp.TransientGeometry.CreateBox();

            foreach (GraphicsNode node in mCubes)
            {
                Box nodeBox = node.RangeBox;
                //Point max = nodeBox.MaxPoint;
                //Point min = nodeBox.MinPoint;

                //max.TranslateBy(node.Transformation.Translation);
                //min.TranslateBy(node.Transformation.Translation);

                //nodeBox.MaxPoint = max;
                //nodeBox.MinPoint = min;

                rubikBox.Extend(node.RangeBox.MaxPoint);
                rubikBox.Extend(node.RangeBox.MinPoint);
            }

            mCubeArray  = new GraphicsNode[3, 3, 3];
            mCubeIJKMap = new Dictionary <GraphicsNode, IJK>();
            foreach (GraphicsNode node in mCubes)
            {
                // find the midpt
                Box      nodeBox = node.RangeBox;
                double[] midPt   = { (nodeBox.MaxPoint.X + nodeBox.MinPoint.X) / 2.0,
                                     (nodeBox.MaxPoint.Y + nodeBox.MinPoint.Y) / 2.0,
                                     (nodeBox.MaxPoint.Z + nodeBox.MinPoint.Z) / 2.0 };

                double[] delta = { nodeBox.MaxPoint.X - nodeBox.MinPoint.X
                                   , nodeBox.MaxPoint.Y - nodeBox.MinPoint.Y
                                   , nodeBox.MaxPoint.Z - nodeBox.MinPoint.Z };

                int i = (int)((midPt[0] - rubikBox.MinPoint.X) / delta[0]);
                int j = (int)((midPt[1] - rubikBox.MinPoint.Y) / delta[1]);
                int k = (int)((midPt[2] - rubikBox.MinPoint.Z) / delta[2]);

                mCubeIJKMap.Add(node, new IJK()
                {
                    I = i, J = j, K = k
                });
                mCubeArray[i, j, k] = node;
            }
        }
Exemplo n.º 30
0
        public void TerminatePreviewGraphics()
        {
            m_graphicsCoordinateSet.Delete();

            m_graphicsColorSet.Delete();

            m_graphicsColorIndexSet.Delete();

            m_pointGraphics.Delete();

            m_previewClientGraphicsNode.Delete();

            m_graphicsCoordinateSet     = null;
            m_graphicsColorSet          = null;
            m_graphicsColorIndexSet     = null;
            m_pointGraphics             = null;
            m_previewClientGraphicsNode = null;
        }
Exemplo n.º 31
0
        void DoDemo()
        {
            Inventor.Application InvApp = AdnInventorUtilities.InvApplication;

            //Create new interaction event
            _interactionEvents = InvApp.CommandManager.CreateInteractionEvents();

            //Store mouse events
            _mouseEvents = _interactionEvents.MouseEvents;

            //Enable mouse move. This is disabled by default for performance reasons
            _mouseEvents.MouseMoveEnabled = true;

            //Listen to OnMouseMove event
            _mouseEvents.OnMouseMove +=
                new MouseEventsSink_OnMouseMoveEventHandler(MouseEvents_OnMouseMove);

            _interactionEvents.StatusBarText = "Select triangle vertex: ";

            //Retrieve InteractionGraphics
            InteractionGraphics ig = _interactionEvents.InteractionGraphics;

            //Create new node
            GraphicsNode node = ig.OverlayClientGraphics.AddNode(1);

            //Add Triangle primitive
            _triangleGraph = node.AddTriangleGraphics();

            //Set up coordinates
            GraphicsCoordinateSet coordSet = ig.GraphicsDataSets.CreateCoordinateSet(1);

            double[] coords = new double[]
            {
                0.0, 0.0, 0.0, //vertex 1
                5.0, 0.0, 0.0, //vertex 2
                2.5, 5.0, 0.0  //vertex 3
            };

            coordSet.PutCoordinates(ref coords);

            _triangleGraph.CoordinateSet = coordSet;

            _interactionEvents.Start();
        }
        public TriangleGraphics DrawTriangle(
            double[] v1,
            double[] v2,
            double[] v3,
            GraphicsNode node)
        {
            try
            {
                AdnGraphics graphicsData = WorkingGraphics;

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

                TriangleGraphics graphic = node.AddTriangleGraphics();

                if ((v1 != null) && (v2 != null) && (v3 != null))
                {
                    GraphicsCoordinateSet coordSet =
                        graphicsData.GraphicsDataSets.CreateCoordinateSet(
                            graphicsData.GetDataSetFreeId());

                    List <double> coordinates = new List <double>();

                    coordinates.AddRange(v1);
                    coordinates.AddRange(v2);
                    coordinates.AddRange(v3);

                    double[] coordsArray = coordinates.ToArray();

                    coordSet.PutCoordinates(ref coordsArray);

                    graphic.CoordinateSet = coordSet;
                }

                return(graphic);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 33
0
        public ComponentGraphics DrawComponent(
            ComponentDefinition compDef,
            GraphicsNode node)
        {
            try
            {
                AdnGraphics graphicsData = WorkingGraphics;

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

                ComponentGraphics graphic = node.AddComponentGraphics(compDef);

                return graphic;
            }
            catch
            {
                return null;
            }
        }
Exemplo n.º 34
0
        public SurfaceGraphics DrawSurface(
            object surface,
            GraphicsNode node)
        {
            try
            {
                AdnGraphics graphicsData = WorkingGraphics;

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

                SurfaceGraphics graphic = node.AddSurfaceGraphics(surface);

                return graphic;
            }
            catch
            {
                return null;
            }
        }
Exemplo n.º 35
0
        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.º 36
0
        public TriangleStripGraphics DrawTriangleStrip(
           double[] coordinates,
           GraphicsNode node)
        {
            try
            {
                AdnGraphics graphicsData = WorkingGraphics;

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

                TriangleStripGraphics graphic = node.AddTriangleStripGraphics();

                if (coordinates != null)
                {
                    GraphicsCoordinateSet coordSet =
                        graphicsData.GraphicsDataSets.CreateCoordinateSet(
                            graphicsData.GetDataSetFreeId());

                    coordSet.PutCoordinates(ref coordinates);

                    graphic.CoordinateSet = coordSet;
                }

                return graphic;
            }
            catch
            {
                return null;
            }
        }
Exemplo n.º 37
0
        public TriangleGraphics DrawTriangle(
            double[] v1,
            double[] v2,
            double[] v3,
            GraphicsNode node)
        {
            try
            {
                AdnGraphics graphicsData = WorkingGraphics;

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

                TriangleGraphics graphic = node.AddTriangleGraphics();

                if ((v1 != null) && (v2 != null) && (v3 != null))
                {
                    GraphicsCoordinateSet coordSet =
                        graphicsData.GraphicsDataSets.CreateCoordinateSet(
                            graphicsData.GetDataSetFreeId());

                    List<double> coordinates = new List<double>();
                    
                    coordinates.AddRange(v1);
                    coordinates.AddRange(v2);
                    coordinates.AddRange(v3);

                    double[] coordsArray = coordinates.ToArray();

                    coordSet.PutCoordinates(ref coordsArray);

                    graphic.CoordinateSet = coordSet;
                }

                return graphic;
            }
            catch
            {
                return null;
            }
        }
Exemplo n.º 38
0
        public LineGraphics DrawLine(
            double[] startPoint, 
            double[] endPoint, 
            GraphicsNode node)
        {
            try
            {
                AdnGraphics graphicsData = WorkingGraphics;

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

                LineGraphics graphic = node.AddLineGraphics();

                if ((startPoint != null) && (endPoint != null))
                {
                    GraphicsCoordinateSet coordSet =
                        graphicsData.GraphicsDataSets.CreateCoordinateSet(
                            graphicsData.GetDataSetFreeId());

                    double[] coordsArray = startPoint.Concat(endPoint).ToArray();

                    coordSet.PutCoordinates(ref coordsArray);

                    graphic.CoordinateSet = coordSet;
                }

                return graphic;
            }
            catch
            {
                return null;
            }
        }
Exemplo n.º 39
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // OnMouseDown Event: we create symbol in the sheet graphics by using SetGraphicsSource(sheet)
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void MouseEvents_OnMouseDown(
            MouseButtonEnum Button,
            ShiftStateEnum ShiftKeys,
            Inventor.Point ModelPosition,
            Point2d ViewPosition,
            Inventor.View View)
        {
            if (Button != MouseButtonEnum.kLeftMouseButton)
                return;

            // Define symbol inputs: center, normal, radius

            Point center = ModelPosition;

            UnitVector normal = _Tg.CreateUnitVector(0, 0, 1);
            
            double radius = _sheet.Width / 30;

            // Add new symbol to the sheet graphics...
            _clientGraphicsMng.SetGraphicsSource(_sheet);

            DrawSymbol(normal, center, radius);

            _clientGraphicsMng.UpdateView();

            _clientGraphicsMng.SetGraphicsSource(
               _interactionManager.InteractionEvents);

            _symbolNode = null;
        }
        /// <summary>
        /// When the appropriate rectangle button is clicked the button's OnExecute event handler
        /// calls this method to hook up the mouse click event which will wait for the user to select 
        /// a point from which to start the drawing of the rectangle
        /// </summary>
        public virtual void StartRectangleInteraction()
        {
            _interactionEvents = _inventorApplication.CommandManager.CreateInteractionEvents();

            _rectangleInteractionGraphics = _interactionEvents.InteractionGraphics;
            _rectangleClientGraphics = _rectangleInteractionGraphics.OverlayClientGraphics;
            _rectangleLineNode = _rectangleClientGraphics.AddNode(1);
            _rectangleGraphicsDataSets = _rectangleInteractionGraphics.GraphicsDataSets;
            _rectangleCoordSet = _rectangleGraphicsDataSets.CreateCoordinateSet(1);
            _rectangleIndexSet = _rectangleGraphicsDataSets.CreateIndexSet(1);

            _onTerminate_Delegate = new InteractionEventsSink_OnTerminateEventHandler(StopInteraction);
            _interactionEvents.OnTerminate += _onTerminate_Delegate;

            _userInputEvents = _inventorApplication.CommandManager.UserInputEvents;
            _userInputEvents_OnContextMenuDelegate = new UserInputEventsSink_OnContextMenuEventHandler(UserInputEvents_OnContextMenu);
            _userInputEvents.OnContextMenu += _userInputEvents_OnContextMenuDelegate;

            _mouseEvents = _interactionEvents.MouseEvents;
            _mouseEvents.PointInferenceEnabled = true;
            _onMouseClick_Delegate = new MouseEventsSink_OnMouseClickEventHandler(OnMouseClick_CreateRectangle);
            _mouseEvents.OnMouseClick += _onMouseClick_Delegate;

            _interactionEvents.StatusBarText = "Select a Point from which to start the rectangle";

            _interactionEvents.AllowCommandAliases = true;

            _interactionEvents.Start();
        }
Exemplo n.º 41
0
        public TextGraphics DrawText(
            string text,
            bool scalable,
            GraphicsNode node)
        {
            try
            {
                AdnGraphics graphicsData = WorkingGraphics;

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

                TextGraphics graphic = (scalable ? node.AddScalableTextGraphics() : node.AddTextGraphics());

                graphic.Text = text;

                return graphic;
            }
            catch
            {
                return null;
            }
        }
Exemplo n.º 42
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // OnMouseMove Event is used to transform  current GraphicsNode moved by the user
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void MouseEvents_OnMouseMove(
            MouseButtonEnum Button,
            ShiftStateEnum ShiftKeys,
            Inventor.Point ModelPosition,
            Point2d ViewPosition,
            Inventor.View View)
        {
            if (_symbolNode == null)
            {
                // Define symbol inputs: center, normal, radius
                Point center = _Tg.CreatePoint(0, 0, 0);

                UnitVector normal = _Tg.CreateUnitVector(0, 0, 1);

                double radius = _sheet.Width / 30;

                _symbolNode = DrawSymbol(normal, center, radius);
            }

            SetNodePosition(_symbolNode, ModelPosition);

            _clientGraphicsMng.UpdateView();
        }
Exemplo n.º 43
0
        public PointGraphics DrawPoint(
            double[] position,
            GraphicsNode node)
        {
            try
            {
                AdnGraphics graphicsData = WorkingGraphics;

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

                PointGraphics graphic = node.AddPointGraphics();

                if (position != null)
                {
                    GraphicsCoordinateSet coordSet =
                        graphicsData.GraphicsDataSets.CreateCoordinateSet(
                            graphicsData.GetDataSetFreeId());

                    coordSet.PutCoordinates(ref position);

                    graphic.CoordinateSet = coordSet;
                }

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

            if (InvApp.ActiveDocument == null || !(InvApp.ActiveDocument is DrawingDocument))
            {
                System.Windows.Forms.MessageBox.Show(
                    "A Drawing Document must be active...",
                    "Invalid Document Error",
                    System.Windows.Forms.MessageBoxButtons.OK,
                    System.Windows.Forms.MessageBoxIcon.Information);

                return;
            }

            _Tg = InvApp.TransientGeometry;

            _interactionManager = new AdnInteractionManager(InvApp);

            _interactionManager.Initialize();

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

            _interactionManager.MouseEvents.MouseMoveEnabled = true;

            _interactionManager.MouseEvents.OnMouseDown +=
                new MouseEventsSink_OnMouseDownEventHandler(MouseEvents_OnMouseDown);

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

            _interactionManager.Start("Place Symbol: ");

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

            _clientGraphicsMng.Transacting = true;

            _clientGraphicsMng.SetGraphicsSource(
                _interactionManager.InteractionEvents);

            _symbolNode = null;

            DrawingDocument document = InvApp.ActiveDocument as DrawingDocument;

            _sheet = document.ActiveSheet;

            _symbolNode = null;
        }