////////////////////////////////////////////////////////////////////////////////////////////// // Create a list of GraphicsNode, sliced by the plane argument and set their visibility. // A list of nodes is used here, so we can attribute each node a different render style // if needed. // ////////////////////////////////////////////////////////////////////////////////////////////// List <GraphicsNode> CreateSlicedNodes(Plane plane, bool visibility) { List <GraphicsNode> nodes = new List <GraphicsNode>(); foreach (KeyValuePair <SurfaceBody, SurfaceBody> pair in _surfaceBodies) { SurfaceGraphics surfGraph = _clientGraphicsMng.DrawSurface(pair.Value); GraphicsNode node = surfGraph.Parent; StyleSourceTypeEnum styleSourceType; node.RenderStyle = pair.Key.GetRenderStyle(out styleSourceType); nodes.Add(node); } ObjectCollection slicingPlanes = AdnInventorUtilities.InvApplication.TransientObjects.CreateObjectCollection(null); slicingPlanes.Add(plane); foreach (GraphicsNode node in nodes) { node.SliceGraphics(true, slicingPlanes, false, null); node.Visible = visibility; node.Selectable = true; } return(nodes); }
public TextGraphics DrawText( string text, bool scalable, GraphicsNode node) { try { AdnGraphics graphicsData = WorkingGraphics; if (node == null) { node = graphicsData.ClientGraphics.AddNode( graphicsData.GetGraphicNodeFreeId()); } TextGraphics graphic = (scalable ? node.AddScalableTextGraphics() : node.AddTextGraphics()); graphic.Text = text; return(graphic); } catch { return(null); } }
public PointGraphics DrawPoint( double[] position, GraphicsNode node) { try { AdnGraphics graphicsData = WorkingGraphics; if (node == null) { node = graphicsData.ClientGraphics.AddNode( graphicsData.GetGraphicNodeFreeId()); } PointGraphics graphic = node.AddPointGraphics(); if (position != null) { GraphicsCoordinateSet coordSet = graphicsData.GraphicsDataSets.CreateCoordinateSet( graphicsData.GetDataSetFreeId()); coordSet.PutCoordinates(ref position); graphic.CoordinateSet = coordSet; } return(graphic); } catch { return(null); } }
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 TriangleStripGraphics DrawTriangleStrip( double[] coordinates, GraphicsNode node) { try { AdnGraphics graphicsData = WorkingGraphics; if (node == null) { node = graphicsData.ClientGraphics.AddNode( graphicsData.GetGraphicNodeFreeId()); } TriangleStripGraphics graphic = node.AddTriangleStripGraphics(); if (coordinates != null) { GraphicsCoordinateSet coordSet = graphicsData.GraphicsDataSets.CreateCoordinateSet( graphicsData.GetDataSetFreeId()); coordSet.PutCoordinates(ref coordinates); graphic.CoordinateSet = coordSet; } return(graphic); } catch { return(null); } }
////////////////////////////////////////////////////////////////////////////////////////////// // OnMouseDown Event: we create symbol in the sheet graphics by using SetGraphicsSource(sheet) // ////////////////////////////////////////////////////////////////////////////////////////////// void MouseEvents_OnMouseDown( MouseButtonEnum Button, ShiftStateEnum ShiftKeys, Inventor.Point ModelPosition, Point2d ViewPosition, Inventor.View View) { if (Button != MouseButtonEnum.kLeftMouseButton) { return; } // Define symbol inputs: center, normal, radius Point center = ModelPosition; UnitVector normal = _Tg.CreateUnitVector(0, 0, 1); double radius = _sheet.Width / 30; // Add new symbol to the sheet graphics... _clientGraphicsMng.SetGraphicsSource(_sheet); DrawSymbol(normal, center, radius); _clientGraphicsMng.UpdateView(); _clientGraphicsMng.SetGraphicsSource( _interactionManager.InteractionEvents); _symbolNode = null; }
//----------------------------------------------------------------------------- //----------------- 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 override void GraphicsNodeInitialize() { base.GraphicsNodeInitialize(); GraphicsNode.txtPropety_AddLine("rate = " + this.rate); GraphicsNode.txtPropety_AddLine("noise_shape = " + this.noise_shape); GraphicsNode.txtPropety_AddLine("seed = " + this.seed); }
/// <summary> /// When the appropriate rectangle button is clicked the button's OnExecute event handler /// calls this method to hook up the mouse click event which will wait for the user to select /// a point from which to start the drawing of the rectangle /// </summary> public virtual void StartRectangleInteraction() { _interactionEvents = _inventorApplication.CommandManager.CreateInteractionEvents(); _rectangleInteractionGraphics = _interactionEvents.InteractionGraphics; _rectangleClientGraphics = _rectangleInteractionGraphics.OverlayClientGraphics; _rectangleLineNode = _rectangleClientGraphics.AddNode(1); _rectangleGraphicsDataSets = _rectangleInteractionGraphics.GraphicsDataSets; _rectangleCoordSet = _rectangleGraphicsDataSets.CreateCoordinateSet(1); _rectangleIndexSet = _rectangleGraphicsDataSets.CreateIndexSet(1); _onTerminate_Delegate = new InteractionEventsSink_OnTerminateEventHandler(StopInteraction); _interactionEvents.OnTerminate += _onTerminate_Delegate; _userInputEvents = _inventorApplication.CommandManager.UserInputEvents; _userInputEvents_OnContextMenuDelegate = new UserInputEventsSink_OnContextMenuEventHandler(UserInputEvents_OnContextMenu); _userInputEvents.OnContextMenu += _userInputEvents_OnContextMenuDelegate; _mouseEvents = _interactionEvents.MouseEvents; _mouseEvents.PointInferenceEnabled = true; _onMouseClick_Delegate = new MouseEventsSink_OnMouseClickEventHandler(OnMouseClick_CreateRectangle); _mouseEvents.OnMouseClick += _onMouseClick_Delegate; _interactionEvents.StatusBarText = "Select a Point from which to start the rectangle"; _interactionEvents.AllowCommandAliases = true; _interactionEvents.Start(); }
////////////////////////////////////////////////////////////////////////////////////////////// // // ////////////////////////////////////////////////////////////////////////////////////////////// void InsertAsSurfaceGraphics(Matrix transfo) { Inventor.Application InvApp = AdnInventorUtilities.InvApplication; Document document = InvApp.ActiveDocument; ComponentDefinition compDef = AdnInventorUtilities.GetCompDefinition(document); _clientGraphicsMng.SetGraphicsSource(InvApp.ActiveDocument); Dictionary <SurfaceBody, SurfaceBody> surfaceBodies = AdnInventorUtilities.GetTransientBodies( AdnInventorUtilities.GetCompDefinition(_componentDocument)); foreach (KeyValuePair <SurfaceBody, SurfaceBody> pair in surfaceBodies) { SurfaceGraphics surfGraph = _clientGraphicsMng.DrawSurface(pair.Value); GraphicsNode node = surfGraph.Parent; node.Transformation = transfo; node.Selectable = true; StyleSourceTypeEnum styleSourceType; node.RenderStyle = pair.Key.GetRenderStyle(out styleSourceType); } }
////////////////////////////////////////////////////////////////////////////////////////////// // 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(); }
public override void GraphicsNodeInitialize() { base.GraphicsNodeInitialize(); this.GraphicsNode.NodeByType(Enum.GetName(typeof(LayerTypes), this.Type)); GraphicsNode.txtPropety_AddLine("p = " + this.p); GraphicsNode.txtPropety_AddLine("inplace = " + this.inplace); }
public override void GraphicsNodeInitialize() { base.GraphicsNodeInitialize(); this.GraphicsNode.NodeByType(Enum.GetName(typeof(LayerTypes), this.Type)); GraphicsNode.txtPropety_AddLine("units = " + this.units); GraphicsNode.txtPropety_AddLine("activation = " + this.activation); }
////////////////////////////////////////////////////////////////////////////////////// // Use: Returns a new GraphicsNode // ////////////////////////////////////////////////////////////////////////////////////// public GraphicsNode CreateNewGraphicsNode() { AdnGraphics graphicsData = WorkingGraphics; GraphicsNode node = graphicsData.ClientGraphics.AddNode( graphicsData.GetGraphicNodeFreeId()); return(node); }
public override void GraphicsNodeInitialize() { base.GraphicsNodeInitialize(); GraphicsNode.txtPropety_AddLine("kernel_size = " + kernel_size); GraphicsNode.txtPropety_AddLine("strides = " + strides); GraphicsNode.txtPropety_AddLine("padding = " + padding); GraphicsNode.txtPropety_AddLine("dilation = " + dilation); }
public override void GraphicsNodeInitialize() { base.GraphicsNodeInitialize(); GraphicsNode.txtPropety_AddLine("in_channels = " + in_channels); GraphicsNode.txtPropety_AddLine("out_channels = " + out_channels); GraphicsNode.txtPropety_AddLine("kernel_size = " + kernel_size); }
//-------------------------------------------------------- public BlockFormCmd() { m_blockForm = null; m_previewClientGraphicsNode = null; m_triangleStripGraphics = null; m_graphicsCoordinateSet = null; m_graphicsColorSet = null; m_graphicsColorIndexSet = null; }
////////////////////////////////////////////////////////////////////////////////////////////// // Set position of a GraphicsNode // ////////////////////////////////////////////////////////////////////////////////////////////// void SetNodePosition(GraphicsNode node, Point position) { Matrix transfo = node.Transformation; Vector Tx = _Tg.CreateVector( position.X, position.Y, position.Z); transfo.SetTranslation(Tx, false); node.Transformation = transfo; }
////////////////////////////////////////////////////////////////////////////////////////////// // Set position of a GraphicsNode // ////////////////////////////////////////////////////////////////////////////////////////////// void SetNodePosition(GraphicsNode node, Point position) { Matrix transfo = node.Transformation; Vector Tx = _Tg.CreateVector( position.X, position.Y, position.Z); transfo.SetTranslation(Tx, false); node.Transformation = transfo; }
////////////////////////////////////////////////////////////////////////////////////////////// // Description: Displays PointGraphics with various RenderStyles // ////////////////////////////////////////////////////////////////////////////////////////////// static public void PointGraphicsRenderDemo() { 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); } TransientGeometry Tg = AdnInventorUtilities.InvApplication.TransientGeometry; GraphicsNode node = graphics.AddNode(graphics.Count + 1); PointGraphics[] pointGraphics = new PointGraphics[4]; pointGraphics[0] = node.AddPointGraphics(); pointGraphics[1] = node.AddPointGraphics(); pointGraphics[2] = node.AddPointGraphics(); pointGraphics[3] = node.AddPointGraphics(); pointGraphics[0].PointRenderStyle = PointRenderStyleEnum.kCirclePointStyle; pointGraphics[0].CoordinateSet = dataSets.CreateCoordinateSet(dataSets.Count + 1); pointGraphics[0].CoordinateSet.Add(1, Tg.CreatePoint(5, 5, 0)); pointGraphics[1].PointRenderStyle = PointRenderStyleEnum.kCrossPointStyle; pointGraphics[1].CoordinateSet = dataSets.CreateCoordinateSet(dataSets.Count + 1); pointGraphics[1].CoordinateSet.Add(1, Tg.CreatePoint(10, 0, 0)); pointGraphics[2].PointRenderStyle = PointRenderStyleEnum.kXPointStyle; pointGraphics[2].CoordinateSet = dataSets.CreateCoordinateSet(dataSets.Count + 1); pointGraphics[2].CoordinateSet.Add(1, Tg.CreatePoint(5, -5, 0)); pointGraphics[3].PointRenderStyle = PointRenderStyleEnum.kFilledCircleSelectPointStyle; pointGraphics[3].CoordinateSet = dataSets.CreateCoordinateSet(dataSets.Count + 1); pointGraphics[3].CoordinateSet.Add(1, Tg.CreatePoint(0, 0, 0)); doc.Views[1].Update(); }
void DoDemo() { Inventor.Application InvApp = AdnInventorUtilities.InvApplication; if (InvApp.ActiveDocument == null || !(InvApp.ActiveDocument is DrawingDocument)) { System.Windows.Forms.MessageBox.Show( "A Drawing Document must be active...", "Invalid Document Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); return; } _Tg = InvApp.TransientGeometry; _interactionManager = new AdnInteractionManager(InvApp); _interactionManager.Initialize(); _interactionManager.OnTerminateEvent += new AdnInteractionManager.OnTerminateHandler(OnTerminateEvent); _interactionManager.MouseEvents.MouseMoveEnabled = true; _interactionManager.MouseEvents.OnMouseDown += new MouseEventsSink_OnMouseDownEventHandler(MouseEvents_OnMouseDown); _interactionManager.MouseEvents.OnMouseMove += new MouseEventsSink_OnMouseMoveEventHandler(MouseEvents_OnMouseMove); _interactionManager.Start("Place Symbol: "); _clientGraphicsMng = new AdnClientGraphicsManager( AdnInventorUtilities.InvApplication, AdnInventorUtilities.AddInGuid); _clientGraphicsMng.Transacting = true; _clientGraphicsMng.SetGraphicsSource( _interactionManager.InteractionEvents); _symbolNode = null; DrawingDocument document = InvApp.ActiveDocument as DrawingDocument; _sheet = document.ActiveSheet; _symbolNode = null; }
////////////////////////////////////////////////////////////////////////////////////////////// // Description: Displays a LineGraphics between points [0, 0, 0] and [1, 1, 1]. // ////////////////////////////////////////////////////////////////////////////////////////////// static public void LineGraphicsDemo() { PartDocument doc = AdnInventorUtilities.InvApplication.ActiveDocument as PartDocument; // ClientId, can be any string // Typically use instead current add-in GUID string clientId = "{Add-in Guid}"; // Add a new graphics group. // This will fail if a group with same name already exists ClientGraphics graphics = doc.ComponentDefinition.ClientGraphicsCollection.Add(clientId); // Add a new graphic node, with Id=1. // Id needs to be unique within graphics group GraphicsNode node = graphics.AddNode(1); // Add new data set GraphicsDataSets dataSets = doc.GraphicsDataSetsCollection.Add(clientId); // Add new coordinate set // Id needs to be unique within data set GraphicsCoordinateSet coordSet = dataSets.CreateCoordinateSet(1); // Fill up coordinates // Point1: [0.0, 0.0, 0.0] // Point2: [1.0, 1.0, 1.0] double[] coords = new double[] { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 }; coordSet.PutCoordinates(ref coords); // Create new GraphicsPrimitive LineGraphics lineGraphPrimitive = node.AddLineGraphics(); lineGraphPrimitive.LineWeight = 5.0; // Set coordinates lineGraphPrimitive.CoordinateSet = coordSet; // Update the current view, so we see the graphics doc.Views[1].Update(); }
public GraphicsNode CreateNewGraphicsNode(int customId) { try { AdnGraphics graphicsData = WorkingGraphics; GraphicsNode node = graphicsData.ClientGraphics.AddNode(customId); return(node); } catch { return(null); } }
public override void GraphicsNodeInitialize() { base.GraphicsNodeInitialize(); GraphicsNode.txtPropety_AddLine("filter = " + filter); string temp1 = ""; temp1 = "kernel_size = ("; foreach (int i in kernel_size) { temp1 += i.ToString() + ", "; } temp1 = temp1.Remove(temp1.LastIndexOf(", ")); temp1 += ")"; GraphicsNode.txtPropety_AddLine(temp1); }
////////////////////////////////////////////////////////////////////////////////////////////// // Description: Displays a PointGraphics using custom bitmap image. // ////////////////////////////////////////////////////////////////////////////////////////////// static public void PointGraphicsDemo() { 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[] { 5.0, 0.0, 0.0 }; coordSet.PutCoordinates(ref coords); GraphicsImageSet imageSet = dataSets.CreateImageSet(dataSets.Count + 1); stdole.IPictureDisp image = PictureDispConverter.ToIPictureDisp(Resources.PointImage); imageSet.Add(1, image, null, -1, -1); PointGraphics pointGraphPrimitive = node.AddPointGraphics(); pointGraphPrimitive.CoordinateSet = coordSet; pointGraphPrimitive.SetCustomImage(imageSet, 1); doc.Views[1].Update(); }
public MoveCmd() { m_moveCmdDlg = null; m_selectFace = null; m_selectiFeature = null; m_UCS = null; m_previewClientGraphicsNode = null; m_pointGraphics = null; m_graphicsCoordinateSet = null; m_graphicsColorSet = null; m_graphicsColorIndexSet = null; m_highlightSet = null; }
public DimData( Point point1, Point point2, LineGraphics extLine1, LineGraphics extLine2, LineGraphics dimLine, GraphicsNode node) { Point1 = point1; Point2 = point2; ExtLine1 = extLine1; ExtLine2 = extLine2; DimLine = dimLine; DimNode = node; }
public DimData( Point point1, Point point2, LineGraphics extLine1, LineGraphics extLine2, LineGraphics dimLine, GraphicsNode node) { Point1 = point1; Point2 = point2; ExtLine1 = extLine1; ExtLine2 = extLine2; DimLine = dimLine; DimNode = node; }
private void UpdateData() { Box rubikBox = mInventorApp.TransientGeometry.CreateBox(); foreach (GraphicsNode node in mCubes) { Box nodeBox = node.RangeBox; //Point max = nodeBox.MaxPoint; //Point min = nodeBox.MinPoint; //max.TranslateBy(node.Transformation.Translation); //min.TranslateBy(node.Transformation.Translation); //nodeBox.MaxPoint = max; //nodeBox.MinPoint = min; rubikBox.Extend(node.RangeBox.MaxPoint); rubikBox.Extend(node.RangeBox.MinPoint); } mCubeArray = new GraphicsNode[3, 3, 3]; mCubeIJKMap = new Dictionary <GraphicsNode, IJK>(); foreach (GraphicsNode node in mCubes) { // find the midpt Box nodeBox = node.RangeBox; double[] midPt = { (nodeBox.MaxPoint.X + nodeBox.MinPoint.X) / 2.0, (nodeBox.MaxPoint.Y + nodeBox.MinPoint.Y) / 2.0, (nodeBox.MaxPoint.Z + nodeBox.MinPoint.Z) / 2.0 }; double[] delta = { nodeBox.MaxPoint.X - nodeBox.MinPoint.X , nodeBox.MaxPoint.Y - nodeBox.MinPoint.Y , nodeBox.MaxPoint.Z - nodeBox.MinPoint.Z }; int i = (int)((midPt[0] - rubikBox.MinPoint.X) / delta[0]); int j = (int)((midPt[1] - rubikBox.MinPoint.Y) / delta[1]); int k = (int)((midPt[2] - rubikBox.MinPoint.Z) / delta[2]); mCubeIJKMap.Add(node, new IJK() { I = i, J = j, K = k }); mCubeArray[i, j, k] = node; } }
public void TerminatePreviewGraphics() { m_graphicsCoordinateSet.Delete(); m_graphicsColorSet.Delete(); m_graphicsColorIndexSet.Delete(); m_pointGraphics.Delete(); m_previewClientGraphicsNode.Delete(); m_graphicsCoordinateSet = null; m_graphicsColorSet = null; m_graphicsColorIndexSet = null; m_pointGraphics = null; m_previewClientGraphicsNode = null; }
void DoDemo() { Inventor.Application InvApp = AdnInventorUtilities.InvApplication; //Create new interaction event _interactionEvents = InvApp.CommandManager.CreateInteractionEvents(); //Store mouse events _mouseEvents = _interactionEvents.MouseEvents; //Enable mouse move. This is disabled by default for performance reasons _mouseEvents.MouseMoveEnabled = true; //Listen to OnMouseMove event _mouseEvents.OnMouseMove += new MouseEventsSink_OnMouseMoveEventHandler(MouseEvents_OnMouseMove); _interactionEvents.StatusBarText = "Select triangle vertex: "; //Retrieve InteractionGraphics InteractionGraphics ig = _interactionEvents.InteractionGraphics; //Create new node GraphicsNode node = ig.OverlayClientGraphics.AddNode(1); //Add Triangle primitive _triangleGraph = node.AddTriangleGraphics(); //Set up coordinates GraphicsCoordinateSet coordSet = ig.GraphicsDataSets.CreateCoordinateSet(1); double[] coords = new double[] { 0.0, 0.0, 0.0, //vertex 1 5.0, 0.0, 0.0, //vertex 2 2.5, 5.0, 0.0 //vertex 3 }; coordSet.PutCoordinates(ref coords); _triangleGraph.CoordinateSet = coordSet; _interactionEvents.Start(); }
public TriangleGraphics DrawTriangle( double[] v1, double[] v2, double[] v3, GraphicsNode node) { try { AdnGraphics graphicsData = WorkingGraphics; if (node == null) { node = graphicsData.ClientGraphics.AddNode( graphicsData.GetGraphicNodeFreeId()); } TriangleGraphics graphic = node.AddTriangleGraphics(); if ((v1 != null) && (v2 != null) && (v3 != null)) { GraphicsCoordinateSet coordSet = graphicsData.GraphicsDataSets.CreateCoordinateSet( graphicsData.GetDataSetFreeId()); List <double> coordinates = new List <double>(); coordinates.AddRange(v1); coordinates.AddRange(v2); coordinates.AddRange(v3); double[] coordsArray = coordinates.ToArray(); coordSet.PutCoordinates(ref coordsArray); graphic.CoordinateSet = coordSet; } return(graphic); } catch { return(null); } }
public ComponentGraphics DrawComponent( ComponentDefinition compDef, GraphicsNode node) { try { AdnGraphics graphicsData = WorkingGraphics; if (node == null) { node = graphicsData.ClientGraphics.AddNode( graphicsData.GetGraphicNodeFreeId()); } ComponentGraphics graphic = node.AddComponentGraphics(compDef); return graphic; } catch { return null; } }
public SurfaceGraphics DrawSurface( object surface, GraphicsNode node) { try { AdnGraphics graphicsData = WorkingGraphics; if (node == null) { node = graphicsData.ClientGraphics.AddNode( graphicsData.GetGraphicNodeFreeId()); } SurfaceGraphics graphic = node.AddSurfaceGraphics(surface); return graphic; } catch { return null; } }
public CurveGraphics DrawCurve( object curve, GraphicsNode node) { try { AdnGraphics graphicsData = WorkingGraphics; if (node == null) { node = graphicsData.ClientGraphics.AddNode( graphicsData.GetGraphicNodeFreeId()); } CurveGraphics graphic = node.AddCurveGraphics(curve); return graphic; } catch { return null; } }
public TriangleStripGraphics DrawTriangleStrip( double[] coordinates, GraphicsNode node) { try { AdnGraphics graphicsData = WorkingGraphics; if (node == null) { node = graphicsData.ClientGraphics.AddNode( graphicsData.GetGraphicNodeFreeId()); } TriangleStripGraphics graphic = node.AddTriangleStripGraphics(); if (coordinates != null) { GraphicsCoordinateSet coordSet = graphicsData.GraphicsDataSets.CreateCoordinateSet( graphicsData.GetDataSetFreeId()); coordSet.PutCoordinates(ref coordinates); graphic.CoordinateSet = coordSet; } return graphic; } catch { return null; } }
public TriangleGraphics DrawTriangle( double[] v1, double[] v2, double[] v3, GraphicsNode node) { try { AdnGraphics graphicsData = WorkingGraphics; if (node == null) { node = graphicsData.ClientGraphics.AddNode( graphicsData.GetGraphicNodeFreeId()); } TriangleGraphics graphic = node.AddTriangleGraphics(); if ((v1 != null) && (v2 != null) && (v3 != null)) { GraphicsCoordinateSet coordSet = graphicsData.GraphicsDataSets.CreateCoordinateSet( graphicsData.GetDataSetFreeId()); List<double> coordinates = new List<double>(); coordinates.AddRange(v1); coordinates.AddRange(v2); coordinates.AddRange(v3); double[] coordsArray = coordinates.ToArray(); coordSet.PutCoordinates(ref coordsArray); graphic.CoordinateSet = coordSet; } return graphic; } catch { return null; } }
public LineGraphics DrawLine( double[] startPoint, double[] endPoint, GraphicsNode node) { try { AdnGraphics graphicsData = WorkingGraphics; if (node == null) { node = graphicsData.ClientGraphics.AddNode( graphicsData.GetGraphicNodeFreeId()); } LineGraphics graphic = node.AddLineGraphics(); if ((startPoint != null) && (endPoint != null)) { GraphicsCoordinateSet coordSet = graphicsData.GraphicsDataSets.CreateCoordinateSet( graphicsData.GetDataSetFreeId()); double[] coordsArray = startPoint.Concat(endPoint).ToArray(); coordSet.PutCoordinates(ref coordsArray); graphic.CoordinateSet = coordSet; } return graphic; } catch { return null; } }
////////////////////////////////////////////////////////////////////////////////////////////// // OnMouseDown Event: we create symbol in the sheet graphics by using SetGraphicsSource(sheet) // ////////////////////////////////////////////////////////////////////////////////////////////// void MouseEvents_OnMouseDown( MouseButtonEnum Button, ShiftStateEnum ShiftKeys, Inventor.Point ModelPosition, Point2d ViewPosition, Inventor.View View) { if (Button != MouseButtonEnum.kLeftMouseButton) return; // Define symbol inputs: center, normal, radius Point center = ModelPosition; UnitVector normal = _Tg.CreateUnitVector(0, 0, 1); double radius = _sheet.Width / 30; // Add new symbol to the sheet graphics... _clientGraphicsMng.SetGraphicsSource(_sheet); DrawSymbol(normal, center, radius); _clientGraphicsMng.UpdateView(); _clientGraphicsMng.SetGraphicsSource( _interactionManager.InteractionEvents); _symbolNode = null; }
/// <summary> /// When the appropriate rectangle button is clicked the button's OnExecute event handler /// calls this method to hook up the mouse click event which will wait for the user to select /// a point from which to start the drawing of the rectangle /// </summary> public virtual void StartRectangleInteraction() { _interactionEvents = _inventorApplication.CommandManager.CreateInteractionEvents(); _rectangleInteractionGraphics = _interactionEvents.InteractionGraphics; _rectangleClientGraphics = _rectangleInteractionGraphics.OverlayClientGraphics; _rectangleLineNode = _rectangleClientGraphics.AddNode(1); _rectangleGraphicsDataSets = _rectangleInteractionGraphics.GraphicsDataSets; _rectangleCoordSet = _rectangleGraphicsDataSets.CreateCoordinateSet(1); _rectangleIndexSet = _rectangleGraphicsDataSets.CreateIndexSet(1); _onTerminate_Delegate = new InteractionEventsSink_OnTerminateEventHandler(StopInteraction); _interactionEvents.OnTerminate += _onTerminate_Delegate; _userInputEvents = _inventorApplication.CommandManager.UserInputEvents; _userInputEvents_OnContextMenuDelegate = new UserInputEventsSink_OnContextMenuEventHandler(UserInputEvents_OnContextMenu); _userInputEvents.OnContextMenu += _userInputEvents_OnContextMenuDelegate; _mouseEvents = _interactionEvents.MouseEvents; _mouseEvents.PointInferenceEnabled = true; _onMouseClick_Delegate = new MouseEventsSink_OnMouseClickEventHandler(OnMouseClick_CreateRectangle); _mouseEvents.OnMouseClick += _onMouseClick_Delegate; _interactionEvents.StatusBarText = "Select a Point from which to start the rectangle"; _interactionEvents.AllowCommandAliases = true; _interactionEvents.Start(); }
public TextGraphics DrawText( string text, bool scalable, GraphicsNode node) { try { AdnGraphics graphicsData = WorkingGraphics; if (node == null) { node = graphicsData.ClientGraphics.AddNode( graphicsData.GetGraphicNodeFreeId()); } TextGraphics graphic = (scalable ? node.AddScalableTextGraphics() : node.AddTextGraphics()); graphic.Text = text; return graphic; } catch { return null; } }
////////////////////////////////////////////////////////////////////////////////////////////// // OnMouseMove Event is used to transform current GraphicsNode moved by the user // ////////////////////////////////////////////////////////////////////////////////////////////// void MouseEvents_OnMouseMove( MouseButtonEnum Button, ShiftStateEnum ShiftKeys, Inventor.Point ModelPosition, Point2d ViewPosition, Inventor.View View) { if (_symbolNode == null) { // Define symbol inputs: center, normal, radius Point center = _Tg.CreatePoint(0, 0, 0); UnitVector normal = _Tg.CreateUnitVector(0, 0, 1); double radius = _sheet.Width / 30; _symbolNode = DrawSymbol(normal, center, radius); } SetNodePosition(_symbolNode, ModelPosition); _clientGraphicsMng.UpdateView(); }
public PointGraphics DrawPoint( double[] position, GraphicsNode node) { try { AdnGraphics graphicsData = WorkingGraphics; if (node == null) { node = graphicsData.ClientGraphics.AddNode( graphicsData.GetGraphicNodeFreeId()); } PointGraphics graphic = node.AddPointGraphics(); if (position != null) { GraphicsCoordinateSet coordSet = graphicsData.GraphicsDataSets.CreateCoordinateSet( graphicsData.GetDataSetFreeId()); coordSet.PutCoordinates(ref position); graphic.CoordinateSet = coordSet; } return graphic; } catch { return null; } }
void DoDemo() { Inventor.Application InvApp = AdnInventorUtilities.InvApplication; if (InvApp.ActiveDocument == null || !(InvApp.ActiveDocument is DrawingDocument)) { System.Windows.Forms.MessageBox.Show( "A Drawing Document must be active...", "Invalid Document Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); return; } _Tg = InvApp.TransientGeometry; _interactionManager = new AdnInteractionManager(InvApp); _interactionManager.Initialize(); _interactionManager.OnTerminateEvent += new AdnInteractionManager.OnTerminateHandler(OnTerminateEvent); _interactionManager.MouseEvents.MouseMoveEnabled = true; _interactionManager.MouseEvents.OnMouseDown += new MouseEventsSink_OnMouseDownEventHandler(MouseEvents_OnMouseDown); _interactionManager.MouseEvents.OnMouseMove += new MouseEventsSink_OnMouseMoveEventHandler(MouseEvents_OnMouseMove); _interactionManager.Start("Place Symbol: "); _clientGraphicsMng = new AdnClientGraphicsManager( AdnInventorUtilities.InvApplication, AdnInventorUtilities.AddInGuid); _clientGraphicsMng.Transacting = true; _clientGraphicsMng.SetGraphicsSource( _interactionManager.InteractionEvents); _symbolNode = null; DrawingDocument document = InvApp.ActiveDocument as DrawingDocument; _sheet = document.ActiveSheet; _symbolNode = null; }