示例#1
0
        private static void Test(ref Inventor.Application _InvApplication, ref Inventor.AssemblyDocument assemblyDocument, string ClientGraphicsName)
        {
            Inventor.AssemblyComponentDefinition ComponentDefinition = assemblyDocument.ComponentDefinition;

            // add ClientGraphics
            Inventor.ClientGraphics ClientGraphics = null;

            ClientGraphics = DeleteNamedGraphics(ref assemblyDocument, ClientGraphicsName);

            ClientGraphics = ComponentDefinition.ClientGraphicsCollection.Add(ClientGraphicsName);

            //add GraphicsDataSets
            Inventor.GraphicsDataSets GraphDataSets;
            try
            {
                GraphDataSets = assemblyDocument.GraphicsDataSetsCollection[ClientGraphicsName];
                if (GraphDataSets != null)
                {
                    GraphDataSets.Delete();
                }
            }
            catch
            { }

            GraphDataSets = assemblyDocument.GraphicsDataSetsCollection.Add(ClientGraphicsName);
            Inventor.GraphicsCoordinateSet oCoordSet = GraphDataSets.CreateCoordinateSet(1);

            // add GraphicsNode
            Inventor.GraphicsNode LineNode = ClientGraphics.AddNode(1);
            // add LineGraphics
            Inventor.LineGraphics LineSet = LineNode.AddLineGraphics();
            LineSet.CoordinateSet = oCoordSet;

            Inventor.TransientGeometry oTG = _InvApplication.TransientGeometry;

            oCoordSet.Add(1, oTG.CreatePoint(0, 0, 0));
            oCoordSet.Add(2, oTG.CreatePoint(20, 30, 0));

            oCoordSet.Add(3, oTG.CreatePoint(40, 20, 0));
            oCoordSet.Add(4, oTG.CreatePoint(60, 30, 100));

            // set LineDefinitionSpace as screen space
            LineSet.LineDefinitionSpace = Inventor.LineDefinitionSpaceEnum.kScreenSpace;
            // set Colour
            Inventor.GraphicsColorSet graphicsColorSet = LineSet.ColorSet;
            graphicsColorSet = GraphDataSets.CreateColorSet(1);
            LineSet.ColorSet = graphicsColorSet;
            LineSet.ColorSet.Add(1, 255, 1, 0);
            // set lineweight
            LineSet.LineWeight = 2;
            // set LineType
            LineSet.LineType = Inventor.LineTypeEnum.kChainLineType;
            // set LineScale
            LineSet.LineScale = 2;

            _InvApplication.ActiveView.Update();
        }
示例#2
0
        private static void DrawBox(ref Inventor.Application _InvApplication, ref Inventor.ClientGraphics ClientGraphics, ref Inventor.GraphicsCoordinateSet oCoordSet, ref Inventor.GraphicsDataSets GraphDataSets, ref Inventor.Box box)
        {
            Inventor.GraphicsNode LineNode = ClientGraphics.AddNode(1);
            // ClientGraphics.Selectable = Inventor.GraphicsSelectabilityEnum.kAllGraphicsSelectable;
            // add LineGraphics
            Inventor.LineGraphics LineSet = LineNode.AddLineGraphics();
            LineSet.CoordinateSet = oCoordSet;

            Inventor.TransientGeometry oTG = _InvApplication.TransientGeometry;
            //Line 1 Start Point End Point
            oCoordSet.Add(1, oTG.CreatePoint(box.MinPoint.X, box.MinPoint.Y, box.MinPoint.Z));
            oCoordSet.Add(2, oTG.CreatePoint(box.MaxPoint.X, box.MinPoint.Y, box.MinPoint.Z));
            //Line 2 Start Point End Point
            oCoordSet.Add(3, oTG.CreatePoint(box.MaxPoint.X, box.MinPoint.Y, box.MinPoint.Z));
            oCoordSet.Add(4, oTG.CreatePoint(box.MaxPoint.X, box.MaxPoint.Y, box.MinPoint.Z));
            //Line 3 Start Point End Point
            oCoordSet.Add(5, oTG.CreatePoint(box.MaxPoint.X, box.MaxPoint.Y, box.MinPoint.Z));
            oCoordSet.Add(6, oTG.CreatePoint(box.MinPoint.X, box.MaxPoint.Y, box.MinPoint.Z));
            //Line 4 Start Point End Point
            oCoordSet.Add(7, oTG.CreatePoint(box.MinPoint.X, box.MaxPoint.Y, box.MinPoint.Z));
            oCoordSet.Add(8, oTG.CreatePoint(box.MinPoint.X, box.MinPoint.Y, box.MinPoint.Z));
            //Upper Line 1 Start Point End Point
            oCoordSet.Add(9, oTG.CreatePoint(box.MinPoint.X, box.MinPoint.Y, box.MaxPoint.Z));
            oCoordSet.Add(10, oTG.CreatePoint(box.MaxPoint.X, box.MinPoint.Y, box.MaxPoint.Z));
            //Upper Line 2 Start Point End Point
            oCoordSet.Add(11, oTG.CreatePoint(box.MaxPoint.X, box.MinPoint.Y, box.MaxPoint.Z));
            oCoordSet.Add(12, oTG.CreatePoint(box.MaxPoint.X, box.MaxPoint.Y, box.MaxPoint.Z));
            //Upper Line 3 Start Point End Point
            oCoordSet.Add(13, oTG.CreatePoint(box.MaxPoint.X, box.MaxPoint.Y, box.MaxPoint.Z));
            oCoordSet.Add(14, oTG.CreatePoint(box.MinPoint.X, box.MaxPoint.Y, box.MaxPoint.Z));
            //Upper Line 4 Start Point End Point
            oCoordSet.Add(15, oTG.CreatePoint(box.MinPoint.X, box.MaxPoint.Y, box.MaxPoint.Z));
            oCoordSet.Add(16, oTG.CreatePoint(box.MinPoint.X, box.MinPoint.Y, box.MaxPoint.Z));
            //Line Vert 1 Start Point End Point
            oCoordSet.Add(17, oTG.CreatePoint(box.MinPoint.X, box.MinPoint.Y, box.MinPoint.Z));
            oCoordSet.Add(18, oTG.CreatePoint(box.MinPoint.X, box.MinPoint.Y, box.MaxPoint.Z));
            //Line Vert 2 Start Point End Point
            oCoordSet.Add(19, oTG.CreatePoint(box.MaxPoint.X, box.MinPoint.Y, box.MinPoint.Z));
            oCoordSet.Add(20, oTG.CreatePoint(box.MaxPoint.X, box.MinPoint.Y, box.MaxPoint.Z));
            //Line Vert 3 Start Point End Point
            oCoordSet.Add(21, oTG.CreatePoint(box.MaxPoint.X, box.MaxPoint.Y, box.MinPoint.Z));
            oCoordSet.Add(22, oTG.CreatePoint(box.MaxPoint.X, box.MaxPoint.Y, box.MaxPoint.Z));
            //Line Vert 4 Start Point End Point
            oCoordSet.Add(23, oTG.CreatePoint(box.MinPoint.X, box.MaxPoint.Y, box.MinPoint.Z));
            oCoordSet.Add(24, oTG.CreatePoint(box.MinPoint.X, box.MaxPoint.Y, box.MaxPoint.Z));
            // set LineDefinitionSpace as screen space
            LineSet.LineDefinitionSpace = Inventor.LineDefinitionSpaceEnum.kScreenSpace;
            // set Colour
            Inventor.GraphicsColorSet graphicsColorSet = LineSet.ColorSet;
            graphicsColorSet = GraphDataSets.CreateColorSet(1);
            LineSet.ColorSet = graphicsColorSet;
            LineSet.ColorSet.Add(1, 255, 1, 0);
            // set lineweight
            LineSet.LineWeight = 2;
            // set LineType
            LineSet.LineType = Inventor.LineTypeEnum.kChainLineType;
            // set LineScale
            LineSet.LineScale = 2;

            _InvApplication.ActiveView.Update();
        }