コード例 #1
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;
        }
コード例 #2
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;
        }
コード例 #3
0
        /// <summary>
        /// Draws the interaction graphics rectangle. Again, two paths for the part sketch or drawing sketch, with
        /// the drawing sketch not getting any color overrides due to how it blends into the "paper". Instead it
        /// defaults to black in the drawing sketch.  The part sketch gets a color from the Degrees of Freedom color
        /// schema.
        /// </summary>
        protected void DrawInteractionRectangle()
        {
            _upperRightPoint2d.X = _pickedPoint2d.X + 0.0001;
            _upperRightPoint2d.Y = _pickedPoint2d.Y + 0.0001;

            PositionPoint2dObjects();

            WriteToInteractionPointCoords();

            _rectangleCoordSet.PutCoordinates(ref _rectanglePointCoords);

            if (_planarSketch != null)
            {
                _activeDOFFreeColor        = _inventorApplication.ActiveColorScheme.DOFFreeColor;
                _rectangleGraphicsColorSet = _rectangleGraphicsDataSets.CreateColorSet(1);
                _rectangleGraphicsColorSet.Add(1, _activeDOFFreeColor.Red, _activeDOFFreeColor.Green, _activeDOFFreeColor.Blue);

                _rectangleIndexSet.Add(1, 1);
                _rectangleIndexSet.Add(2, 2);
                _rectangleIndexSet.Add(3, 3);
                _rectangleIndexSet.Add(4, 4);
                _rectangleIndexSet.Add(5, 1);

                _rectangleLineStripGraphics = _rectangleLineNode.AddLineStripGraphics();
                _rectangleLineStripGraphics.CoordinateSet      = _rectangleCoordSet;
                _rectangleLineStripGraphics.CoordinateIndexSet = _rectangleIndexSet;
                _rectangleLineStripGraphics.ColorSet           = _rectangleGraphicsColorSet;
            }
            else if (_drawingSketch != null)
            {
                _rectangleIndexSet.Add(1, 1);
                _rectangleIndexSet.Add(2, 2);
                _rectangleIndexSet.Add(3, 3);
                _rectangleIndexSet.Add(4, 4);
                _rectangleIndexSet.Add(5, 1);

                _rectangleLineStripGraphics = _rectangleLineNode.AddLineStripGraphics();
                _rectangleLineStripGraphics.CoordinateSet      = _rectangleCoordSet;
                _rectangleLineStripGraphics.CoordinateIndexSet = _rectangleIndexSet;
            }

            _rectangleInteractionGraphics.UpdateOverlayGraphics(_inventorApplication.ActiveView);
        }
コード例 #4
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // Description: Displays a LineGraphics using Index and Color Sets.
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        static public void IndexSetDemo()
        {
            PartDocument doc =
                AdnInventorUtilities.InvApplication.ActiveDocument
                as PartDocument;

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

            ClientGraphics   graphics = null;
            GraphicsDataSets dataSets = null;

            // Add some error handling in case
            // graphics collection and data already exist
            try
            {
                graphics = doc.ComponentDefinition.ClientGraphicsCollection[clientId];
                dataSets = doc.GraphicsDataSetsCollection[clientId];
            }
            catch
            {
                graphics = doc.ComponentDefinition.ClientGraphicsCollection.Add(clientId);
                dataSets = doc.GraphicsDataSetsCollection.Add(clientId);
            }

            // Add new node and coord set
            // Id generation by increment - bad because previous nodes/sets
            // may have been deleted previously, hence making count invalid

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

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

            double[] coords = new double[]
            {
                0.0, 0.0, 0.0, //point 1
                1.0, 1.0, 0.0, //point 2
                0.0, 1.0, 0.0, //point 3
                1.0, 0.0, 0.0  //point 4
            };

            coordSet.PutCoordinates(ref coords);

            LineGraphics lineGraphPrimitive = node.AddLineGraphics();

            lineGraphPrimitive.LineWeight = 5.0;

            //Create Coordinate Index Set
            GraphicsIndexSet indexSetCoords = dataSets.CreateIndexSet(dataSets.Count + 1);

            indexSetCoords.Add(1, 1); //from point 1
            indexSetCoords.Add(2, 3); //connect to point 3
            indexSetCoords.Add(3, 3); //from point 3
            indexSetCoords.Add(4, 2); //connect to point 2
            indexSetCoords.Add(5, 2); //from point 2
            indexSetCoords.Add(6, 4); //connect to point 4

            lineGraphPrimitive.CoordinateSet      = coordSet;
            lineGraphPrimitive.CoordinateIndexSet = indexSetCoords;


            //Create the color set with two colors
            GraphicsColorSet colorSet = dataSets.CreateColorSet(dataSets.Count + 1);

            colorSet.Add(1, 221, 0, 0);
            colorSet.Add(2, 255, 170, 0);
            colorSet.Add(3, 119, 187, 17);

            //Create the index set for color
            GraphicsIndexSet indexSetColors = dataSets.CreateIndexSet(dataSets.Count + 1);

            indexSetColors.Add(1, 3); //line 1 uses color 3
            indexSetColors.Add(2, 1); //line 2 uses color 1
            indexSetColors.Add(3, 2); //line 3 uses color 2

            lineGraphPrimitive.ColorSet      = colorSet;
            lineGraphPrimitive.ColorIndexSet = indexSetColors;

            lineGraphPrimitive.ColorBinding = ColorBindingEnum.kPerItemColors;

            doc.Views[1].Update();
        }
コード例 #5
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // Description: Displays a TriangleFan Graphics.
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        static public void TriangleFanGraphicsDemo()
        {
            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[]
            {
                0.0, 0.0, 0.0, //point 1
                1.0, 1.0, 0.0, //point 2
                2.0, 0.0, 0.0, //point 3
                3.0, 1.0, 0.0, //point 4
                4.0, 0.0, 0.0, //point 5
                5.0, 1.0, 0.0, //point 6
                6.0, 0.0, 0.0, //point 7
            };

            coordSet.PutCoordinates(ref coords);

            TriangleFanGraphics triFanPrimitive = node.AddTriangleFanGraphics();

            int[] strips = new int[]
            {
                3, //points 1,2,3 for strip 1
                4  //points 4,5,6,7 for strip 2
            };

            triFanPrimitive.PutStripLengths(ref strips);

            //Create the color set with 3 colors
            GraphicsColorSet colorSet = dataSets.CreateColorSet(dataSets.Count + 1);

            colorSet.Add(1, 221, 0, 0);
            colorSet.Add(2, 119, 187, 17);
            colorSet.Add(3, 119, 187, 17);

            //Create the index set for color
            GraphicsIndexSet indexSetColors = dataSets.CreateIndexSet(dataSets.Count + 1);

            indexSetColors.Add(1, 2); //strip 1 uses color 1
            indexSetColors.Add(2, 1); //strip 2 uses color 2

            triFanPrimitive.CoordinateSet = coordSet;
            triFanPrimitive.ColorIndexSet = indexSetColors;
            triFanPrimitive.ColorSet      = colorSet;
            triFanPrimitive.ColorBinding  = ColorBindingEnum.kPerStripColors;

            doc.Views[1].Update();
        }