private static double[] GetScaleValues(Inventor.Sheet CurrentSheet) { double [] ScaleValues; string[] DrawingScales; dynamic[] DynamScales; Inventor.DrawingDocument DrawingDocument = (Inventor.DrawingDocument)CurrentSheet.Parent; Inventor.DrawingStandardStyle DrawingStandardStyle = DrawingDocument.StylesManager.ActiveStandardStyle; DynamScales = DrawingStandardStyle.PresetScales; DrawingScales = new string[DynamScales.Length]; ScaleValues = new double[DynamScales.Length]; DrawingScales = DrawingStandardStyle.PresetScales; DynamScales = null; int i = 0; foreach (string ScaleString in DrawingScales) { double ScalingValue = 1; double ScalerValue = 1; if (ScaleString != null) { int Delimitor = ScaleString.IndexOf(":"); ScalingValue = Convert.ToDouble(ScaleString.Substring(0, Delimitor)); ScalerValue = Convert.ToDouble(ScaleString.Substring(Delimitor + 1, ScaleString.Length - (Delimitor + 1))); } ScaleValues[i] = ScalingValue / ScalerValue; i++; } return(ScaleValues); }
private static void SetViewScale(Inventor.Sheet CurrentSheet, ref Inventor.DrawingView DrawingView) { double DrawingTitelBlockHeight = 5; if (CurrentSheet.Size == Inventor.DrawingSheetSizeEnum.kA4DrawingSheetSize) { DrawingTitelBlockHeight = 5; } else if (CurrentSheet.Size == Inventor.DrawingSheetSizeEnum.kA3DrawingSheetSize) { DrawingTitelBlockHeight = 5; } double TargetViewGapWidth = 2; double TargetViewGapHeight = 3; double TargetViewWidth = CurrentSheet.Width - (2 * TargetViewGapWidth); double TargetViewHeight = CurrentSheet.Height - ((2 * TargetViewGapHeight) + DrawingTitelBlockHeight); double SheetWidth = CurrentSheet.Width; double SheetHeight = CurrentSheet.Height; double[] ViewCenter = new double[2]; string[] DrawingScales; dynamic[] DynamScales; Inventor.DrawingDocument DrawingDocument = (Inventor.DrawingDocument)CurrentSheet.Parent; Inventor.DrawingStandardStyle DrawingStandardStyle = DrawingDocument.StylesManager.ActiveStandardStyle; DynamScales = DrawingStandardStyle.PresetScales; DrawingScales = new string[DynamScales.Length]; DrawingScales = DrawingStandardStyle.PresetScales; DynamScales = null; foreach (string ScaleString in DrawingScales) { double ScalingValue = 1; double ScalerValue = 1; double Scale = 0; if (ScaleString != null) { int Delimitor = ScaleString.IndexOf(":"); ScalingValue = Convert.ToDouble(ScaleString.Substring(0, Delimitor)); ScalerValue = Convert.ToDouble(ScaleString.Substring(Delimitor + 1, ScaleString.Length - (Delimitor + 1))); } Scale = ScalingValue / ScalerValue; } for (int i = 0; i < 50; i++) { DrawingView.Scale = TargetViewWidth / DrawingView.Width * DrawingView.Scale; if (DrawingView.Height > TargetViewHeight) { DrawingView.Scale = TargetViewHeight / DrawingView.Height * DrawingView.Scale; } } }