////////////////////////////////////////////////////////////////////////////////////////////// // 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(); }
////////////////////////////////////////////////////////////////////////////////////////////// // // ////////////////////////////////////////////////////////////////////////////////////////////// void SelectEvents_OnSelect( ObjectsEnumerator JustSelectedEntities, SelectionDeviceEnum SelectionDevice, Point ModelPosition, Point2d ViewPosition, View View) { switch (_mode) { case SelectModeEnum.kPlaneSelect: { _plane = AdnInventorUtilities.GetPlane(JustSelectedEntities[1]); _interactionManager.MouseEvents.MouseMoveEnabled = true; _interactionManager.ClearSelectionFilters(); _interactionManager.AddSelectionFilter(SelectionFilterEnum.kPartVertexFilter); _interactionManager.AddSelectionFilter(SelectionFilterEnum.kWorkPointFilter); _interactionManager.InteractionEvents.StatusBarText = "Select center: "; _mode = SelectModeEnum.kCenterSelect; break; } case SelectModeEnum.kCenterSelect: { _center = AdnInventorUtilities.GetPoint(JustSelectedEntities[1]); Circle circle = AdnInventorUtilities.InvApplication.TransientGeometry.CreateCircle( _center, _plane.Normal, 0.001); _curveGraph = _clientGraphicsMng.DrawCurve(circle); _curveGraph.LineWeight = 0.5; _interactionManager.InteractionEvents.StatusBarText = "Select radius: "; _interactionManager.MouseEvents.OnMouseMove += new MouseEventsSink_OnMouseMoveEventHandler(MouseEvents_OnMouseMove); _interactionManager.SelectEvents.OnSelect -= new SelectEventsSink_OnSelectEventHandler(SelectEvents_OnSelect); _mode = SelectModeEnum.kRadiusSelect; break; } default: break; } }
////////////////////////////////////////////////////////////////////////////////////////////// // Creates a new GraphicsNode that contains our graphic symbol // ////////////////////////////////////////////////////////////////////////////////////////////// GraphicsNode DrawSymbol( UnitVector normal, Point center, double radius) { Circle circle = _Tg.CreateCircle(center, normal, radius); double[] up = new double[] { center.X, center.Y + radius, 0 }; double[] down = new double[] { center.X, center.Y - radius, 0 }; double[] right = new double[] { center.X + radius, center.Y, 0 }; double[] left = new double[] { center.X - radius, center.Y, 0 }; GraphicsNode node = _clientGraphicsMng.CreateNewGraphicsNode(); node.Selectable = true; CurveGraphics curve = _clientGraphicsMng.DrawCurve(circle, node); LineGraphics lineVert = _clientGraphicsMng.DrawLine(up, down, node); LineGraphics lineHorz = _clientGraphicsMng.DrawLine(left, right, node); return(node); }