public static void Draw(ref Inventor.Application _InvApplication, string Type) { string GraphicsName = "CG_Test"; Inventor.AssemblyDocument assemblyDocument = (Inventor.AssemblyDocument)_InvApplication.ActiveDocument; Inventor.ComponentOccurrences Occurrences = assemblyDocument.ComponentDefinition.Occurrences; if (Type == "Run") { // Test(ref _InvApplication,ref assemblyDocument, GraphicsName); //TestDrawRangeBoxs(ref _InvApplication, ref assemblyDocument, ref Occurrences, GraphicsName); Inventor.ClientGraphics ClientGraphics = null; DeleteNamedGraphics(ref assemblyDocument, GraphicsName); ClientGraphics = assemblyDocument.ComponentDefinition.ClientGraphicsCollection.Add(GraphicsName); DrawClientGraphicSolid(ref _InvApplication, ref ClientGraphics, ref assemblyDocument, "Clear - Green 1"); SetHighLightSet(ref _InvApplication, ref assemblyDocument, ref Occurrences, ""); } else { DeleteNamedGraphics(ref assemblyDocument, GraphicsName); _InvApplication.ActiveView.Update(); } // Inventor.AssemblyComponentDefinition ComponentDefinition = null; // Inventor.ClientGraphics ClientGraphics = null; }
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 void SetHighLightSet(ref Inventor.Application _InvApplication, ref Inventor.AssemblyDocument assemblyDocument, ref Inventor.ComponentOccurrences Occurrences, string GraphicsName) { if (Occurrences.Count >= 1) { //Inventor.ObjectCollection objectCollection = _InvApplication. Inventor.HighlightSet highlightSet = assemblyDocument.HighlightSets.Add(); highlightSet.Color = _InvApplication.TransientObjects.CreateColor(255, 0, 0, 1); //highlightSet.AddMultipleItems(Occurrences); 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]; //highlightSet.AddItem(componentOccurrence); } } } else { return; } }