public LineStripGraphics DrawLineStrip(
            double[] coordinates,
            GraphicsNode node)
        {
            try
            {
                AdnGraphics graphicsData = WorkingGraphics;

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

                LineStripGraphics graphic = node.AddLineStripGraphics();

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

                    coordSet.PutCoordinates(ref coordinates);

                    graphic.CoordinateSet = coordSet;
                }

                return(graphic);
            }
            catch
            {
                return(null);
            }
        }
Example #2
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);
        }
        public LineStripGraphics DrawLineStrip(
            double[] coordinates,
            GraphicsNode node)
        {
            try
            {
                AdnGraphics graphicsData = WorkingGraphics;

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

                LineStripGraphics graphic = node.AddLineStripGraphics();

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

                    coordSet.PutCoordinates(ref coordinates);

                    graphic.CoordinateSet = coordSet;
                }

                return graphic;
            }
            catch
            {
                return null;
            }
        }
Example #4
0
        private void m_MouseEvents_OnMouseDown(Inventor.MouseButtonEnum Button, Inventor.ShiftStateEnum ShiftKeys, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View)
        {
            //if the interaction event is MyScreenshot,
            //then get the view position and model position

            if (m_InteractionEvents.Name == "MyScreenshot")
            {
                m_MouseStartViewPt = ViewPosition;
                m_StartModelPt     = ModelPosition;
                m_flagMouseDown    = true;

                //clean the last graphics
                m_InteractionEvents.InteractionGraphics.PreviewClientGraphics.Delete();
                m_inventorApplication.ActiveView.Update();

                //gi node
                oGiNode   = m_InteractionEvents.InteractionGraphics.PreviewClientGraphics.AddNode(1);
                oCoordSet = m_InteractionEvents.InteractionGraphics.GraphicsDataSets.CreateCoordinateSet(1);

                //color set
                oColorSet = m_InteractionEvents.InteractionGraphics.GraphicsDataSets.CreateColorSet(1);
                oColorSet.Add(1, 255, 0, 0);

                TransientGeometry tg    = m_inventorApplication.TransientGeometry;
                Inventor.Point    tempP = tg.CreatePoint(ViewPosition.X, ViewPosition.Y, 0);

                oCoordSet.Add(1, tempP);
                oCoordSet.Add(2, tempP);
                oCoordSet.Add(3, tempP);
                oCoordSet.Add(4, tempP);
                oCoordSet.Add(5, tempP);

                try
                {
                    if (oGiLineStripG != null)
                    {
                        oGiLineStripG.Delete();
                        oGiLineStripG = null;
                    }
                    oGiLineStripG = oGiNode.AddLineStripGraphics();
                    oGiLineStripG.CoordinateSet = oCoordSet;
                    oGiLineStripG.ColorSet      = oColorSet;
                    oGiLineStripG.BurnThrough   = true;
                }
                catch (Exception ex)
                {
                    //a problem in Inventor 2009( R13 ) with
                    //LineStripGraphics.BurnThrough. Use LineGraphics as workaround

                    if (oGiLineG != null)
                    {
                        oGiLineG.Delete();
                        oGiLineG = null;
                    }

                    oGiLineG = oGiNode.AddLineGraphics();
                    oGiLineG.CoordinateSet = oCoordSet;
                    oGiLineG.ColorSet      = oColorSet;
                    oGiLineG.BurnThrough   = true;
                }
            }
        }