//----------------------------------------------------------------------------- //----------------- 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; }
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 BlockFormCmd() { m_blockForm = null; m_previewClientGraphicsNode = null; m_triangleStripGraphics = null; m_graphicsCoordinateSet = null; m_graphicsColorSet = null; m_graphicsColorIndexSet = null; }
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; } } }
protected void ResetRectangle() { if (_mouseEvents != null) { _mouseEvents.OnMouseMove -= _onMouseMove_Delegate; _onMouseMove_Delegate = null; _mouseEvents.OnMouseClick -= _onMouseClick_Delegate; _onMouseClick_Delegate = null; _mouseEvents = null; } _rectangleLines = null; _horizontalMidPointAlign = null; _verticalMidPointAlign = null; _userInputEvents.OnContextMenu -= _userInputEvents_OnContextMenuDelegate; _userInputEvents_OnContextMenuDelegate = null; _planarSketch = null; _drawingSketch = null; _secondSelectedSketchEntity = null; _inferredOriginPoint = null; _inferredFinalPositionPoint = null; _firstSelectedSketchEntity = null; _pickedPoint2d = null; _pickedSketchPoint = null; _rectangleOriginSketchPoint = null; _rectangleCoordSet = null; _rectanglePointCoords = null; _rectangleInteractionGraphics = null; _rectangleGraphicsColorSet = null; _interactionEvents.OnTerminate -= _onTerminate_Delegate; _interactionEvents.Stop(); _interactionEvents = null; }
/// <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); }