public static void TestDrawRangeBoxs(ref Inventor.Application _InvApplication, ref Inventor.AssemblyDocument assemblyDocument, ref Inventor.ComponentOccurrences Occurrences, string GraphicsName) { if (Occurrences.Count >= 1) { Inventor.ClientGraphics ClientGraphics = null; Inventor.GraphicsCoordinateSet CoordSet = null; Inventor.GraphicsDataSets GraphDataSets = null; Inventor.Box box = null; DeleteNamedGraphics(ref assemblyDocument, GraphicsName); CoordSet = SetClientGraphics(ref assemblyDocument, ref ClientGraphics, ref GraphDataSets, GraphicsName); int length = Occurrences.Count; for (int i = length; i >= 1; i--) { if (GetInventorObjType(Occurrences[i]) == Inventor.ObjectTypeEnum.kComponentOccurrenceObject) { System.Diagnostics.Debug.WriteLine("Just Selected"); Inventor.ComponentOccurrence componentOccurrence = Occurrences[i]; box = componentOccurrence.RangeBox; DrawBox(ref _InvApplication, ref ClientGraphics, ref CoordSet, ref GraphDataSets, ref box); } //else if (GetInventorObjType(justSelectedEntities[i]) == Inventor.ObjectTypeEnum.kRectangularOccurrencePatternObject) //{ // Inventor.OccurrencePattern OccurrencePattern = justSelectedEntities[i]; // int PatternLength = 10; // for (int x = PatternLength - 1; x >= 1; x--) // { // } //} use after idea tested } } else { return; } }
private static Inventor.GraphicsCoordinateSet SetClientGraphics(ref Inventor.AssemblyDocument assemblyDocument, ref Inventor.ClientGraphics ClientGraphics, ref Inventor.GraphicsDataSets GraphDataSets, string GraphicsName) { Inventor.AssemblyComponentDefinition ComponentDefinition = assemblyDocument.ComponentDefinition; // add ClientGraphics ClientGraphics = ComponentDefinition.ClientGraphicsCollection.Add(GraphicsName); //add GraphicsDataSets try { GraphDataSets = assemblyDocument.GraphicsDataSetsCollection[GraphicsName]; if (GraphDataSets != null) { GraphDataSets.Delete(); } } catch { } GraphDataSets = assemblyDocument.GraphicsDataSetsCollection.Add(GraphicsName); return(GraphDataSets.CreateCoordinateSet(1)); //Inventor.GraphicsCoordinateSet oCoordSet = GraphDataSets.CreateCoordinateSet(1); //return oCoordSet; }
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(); }