////////////////////////////////////////////////////////////////////////////////////////////// // 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(); }
//----------------------------------------------------------------------------- //----------------- 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 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); } }
////////////////////////////////////////////////////////////////////////////////////////////// // 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 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; } }