/// ////////////////////////////////////////////////////////////////////////////////////////////////////// private static void DrawClientGraphicSolid(ref Inventor.Application _InvApplication, ref Inventor.ClientGraphics ClientGraphics, ref Inventor.AssemblyDocument assemblyDocument, string AssetName) {//"Clear - Green 1" "Clear" Inventor.Asset localAsset; localAsset = assemblyDocument.Assets[AssetName]; Inventor.GraphicsNode SurfacesNode = ClientGraphics.AddNode(1); SurfacesNode.Appearance = localAsset; Inventor.Box box = null; Inventor.SurfaceBody SurfaceBody; Inventor.TransientBRep TransientBRep; TransientBRep = _InvApplication.TransientBRep; Inventor.SurfaceGraphics SurfaceGraphics; int length = assemblyDocument.ComponentDefinition.Occurrences.Count; for (int i = length; i >= 1; i--) { if (GetInventorObjType(assemblyDocument.ComponentDefinition.Occurrences[i]) == Inventor.ObjectTypeEnum.kComponentOccurrenceObject) { Inventor.ComponentOccurrence componentOccurrence = assemblyDocument.ComponentDefinition.Occurrences[i]; box = componentOccurrence.RangeBox; SurfaceBody = TransientBRep.CreateSolidBlock(box.Copy()); SurfaceGraphics = SurfacesNode.AddSurfaceGraphics(SurfaceBody); SurfacesNode.Appearance = localAsset; } } _InvApplication.ActiveView.Update(); }
private string GetExtents(Inventor.SurfaceBody SurfaceBody) { string VectorDirection = "X"; double[] Lengths = new double[3]; Inventor.Box ExtentsBox = SurfaceBody.RangeBox; Lengths[0] = Math.Abs(ExtentsBox.MaxPoint.X) + Math.Abs(ExtentsBox.MinPoint.X); Lengths[1] = Math.Abs(ExtentsBox.MaxPoint.Y) + Math.Abs(ExtentsBox.MinPoint.Y); Lengths[2] = Math.Abs(ExtentsBox.MaxPoint.Z) + Math.Abs(ExtentsBox.MinPoint.Z); int Mx = Array.IndexOf(Lengths, Lengths.Max()); int Mn = Array.IndexOf(Lengths, Lengths.Min()); // RangeMid = GetMedian(Lengths); // int Md = Array.IndexOf(Lengths, RangeMid); if (Mx == 0) { VectorDirection = "X"; } if (Mx == 1) { VectorDirection = "Y"; } if (Mx == 2) { VectorDirection = "Z"; } return(VectorDirection); }
public static void DrawRangeBoxs(ref Inventor.Application Inv_Application, ref Inventor.AssemblyDocument assemblyDocument, Inventor.ObjectsEnumerator justSelectedEntities) { //Inventor.ComponentDefinition componentDefinition = (Inventor.ComponentDefinition)assemblyDocument.ComponentDefinition; if (justSelectedEntities.Count >= 1) { if (assemblyDocument.GraphicsDataSetsCollection.Count >= 1) { int length = justSelectedEntities.Count; for (int i = length - 1; i >= 0; i--) { if (GetInventorObjType(justSelectedEntities[i]) == Inventor.ObjectTypeEnum.kComponentOccurrenceObject) { Inventor.Box box = null; System.Diagnostics.Debug.WriteLine("Just Selected"); Inventor.ComponentOccurrence componentOccurrence = justSelectedEntities[i]; box = componentOccurrence.RangeBox; } //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 { Inventor.ClientGraphics clientGraphics = assemblyDocument.ComponentDefinition.ClientGraphicsCollection["RangeID"]; assemblyDocument.GraphicsDataSetsCollection["RangeID"].Delete(); clientGraphics.Delete(); } } else { return; } }
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 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(); }