////////////////////////////////////////////////////////////////////////////////////////////// // // ////////////////////////////////////////////////////////////////////////////////////////////// void MouseEvents_OnMouseDown( MouseButtonEnum Button, ShiftStateEnum ShiftKeys, Inventor.Point ModelPosition, Point2d ViewPosition, Inventor.View View) { if (Button != MouseButtonEnum.kLeftMouseButton) { return; } if (_lineStripGraph == null) { double[] front = AdnInventorUtilities.ToArray(ModelPosition); double[] back = AdnInventorUtilities.ToArray(ModelPosition); double[] combined = front.Concat(back).ToArray(); _rd = new Random(); _lineStripGraph = _clientGraphicsMng.DrawLineStrip( combined, null); _lineStripGraph.ColorBinding = ColorBindingEnum.kPerItemColors; int id = _clientGraphicsMng.WorkingGraphics.GetDataSetFreeId(); _lineStripGraph.ColorSet = _clientGraphicsMng.WorkingGraphics.GraphicsDataSets.CreateColorSet(id); _lineStripGraph.ColorSet.Add( _lineStripGraph.ColorSet.Count + 1, (byte)_rd.Next(0, 255), (byte)_rd.Next(0, 255), (byte)_rd.Next(0, 255)); _lineStripGraph.LineWeight = 5; _interactionManager.MouseEvents.MouseMoveEnabled = true; _interactionManager.MouseEvents.OnMouseMove += new MouseEventsSink_OnMouseMoveEventHandler(MouseEvents_OnMouseMove); } else { _lineStripGraph.CoordinateSet.Add( _lineStripGraph.CoordinateSet.Count + 1, ModelPosition); _lineStripGraph.ColorSet.Add( _lineStripGraph.ColorSet.Count + 1, (byte)_rd.Next(0, 255), (byte)_rd.Next(0, 255), (byte)_rd.Next(0, 255)); } }
////////////////////////////////////////////////////////////////////////////////////////////// // The public static method to start the demo // ////////////////////////////////////////////////////////////////////////////////////////////// public static void Demo() { Inventor.Application InvApp = AdnInventorUtilities.InvApplication; object selection1 = InvApp.CommandManager.Pick( SelectionFilterEnum.kPartVertexFilter, "Select first vertex: "); if (selection1 == null) { return; } object selection2 = InvApp.CommandManager.Pick( SelectionFilterEnum.kPartVertexFilter, "Select second vertex: "); if (selection2 == null) { return; } object selection3 = InvApp.CommandManager.Pick( SelectionFilterEnum.kPartVertexFilter, "Select third vertex: "); if (selection3 == null) { return; } List <double> coords = new List <double>(); coords.AddRange(AdnInventorUtilities.ToArray(AdnInventorUtilities.GetPoint(selection1))); coords.AddRange(AdnInventorUtilities.ToArray(AdnInventorUtilities.GetPoint(selection2))); coords.AddRange(AdnInventorUtilities.ToArray(AdnInventorUtilities.GetPoint(selection3))); AdnClientGraphicsManager clientGraphicsMng = new AdnClientGraphicsManager( InvApp, AdnInventorUtilities.AddInGuid); LineStripGraphics lineStrip = clientGraphicsMng.DrawLineStrip(coords.ToArray()); lineStrip.LineWeight = 5.0; int id = clientGraphicsMng.WorkingGraphics.GetDataSetFreeId(); lineStrip.ColorSet = clientGraphicsMng.WorkingGraphics.GraphicsDataSets.CreateColorSet(id); lineStrip.ColorSet.Add(1, 119, 187, 17); clientGraphicsMng.UpdateView(); }