public void CreateThumbnail() { if (assmbly) { bool bRet; double xSize = 2 * .0254; double ySize = 2 * .0254; double xCenter = (xSize / 2) - Settings.Default.WeirdArbitraryFactor; double yCenter = (ySize / 2); swDwgPaperSizes_e paperSize = swDwgPaperSizes_e.swDwgPapersUserDefined; swDwgTemplates_e drwgTemplate = swDwgTemplates_e.swDwgTemplateNone; swDisplayMode_e dispMode = swDisplayMode_e.swFACETED_HIDDEN; //G:\\Solid Works\\AMSTORE_SHEET_FORMATS\\AM_PART.slddrt //swModel = (ModelDoc2)swApp.NewDocument(@"\\AMSTORE-SVR-22\cad\Solid Works\AMSTORE_SHEET_FORMATS\zPostCard.slddrt", (int)paperSize, xSize, ySize); swModel = (ModelDoc2)swApp.NewDocument(APathSet.ShtFmtPath, (int)paperSize, xSize, ySize); swDraw = (DrawingDoc)swModel; bRet = swDraw.SetupSheet5("AMS1", (int)paperSize, (int)drwgTemplate, 1, 1, false, "", xSize, ySize, "Default", false); View view = swDraw.DropDrawingViewFromPalette(76, xSize, ySize, 0); swDraw.ActivateView("Drawing View1"); bRet = swModel.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", xSize, ySize, 0, false, 0, null, 0); view = swDraw.CreateDrawViewFromModelView3(sourcePath, "*Isometric", xCenter, yCenter, 0); bRet = view.SetDisplayMode3(false, (int)dispMode, false, true); System.Diagnostics.Debug.Print(view.ScaleDecimal.ToString()); ScaleAppropriately(swDraw, view, 0.8, 2); System.Diagnostics.Debug.Print(view.ScaleDecimal.ToString()); swDraw.ActivateView(view.Name); TurnOffSillyMarks(); } }
/// <summary> /// /// </summary> /// <param name="formats">An array of paths to SolidWorks sheet templates.</param> /// <param name="monochrome">A bool array indicating whether we ought to have ImageMagick convert to 2-bit.</param> public void CreateThumbnails(string[] formats, bool[] monochrome) { bool bRet; double xSize = 2 * .0254; double ySize = 2 * .0254; double xCenter = (xSize / 2); double yCenter = (ySize / 2); string orientation = "*Isometric"; string template = string.Empty; swDwgPaperSizes_e paperSize = swDwgPaperSizes_e.swDwgPapersUserDefined; swDwgTemplates_e drwgTemplate = swDwgTemplates_e.swDwgTemplateCustom; swDisplayMode_e dispMode = swDisplayMode_e.swHIDDEN; for (int i = 0; i < formats.Length; i++) { template = (new FileInfo(formats[i]).Name).Split(new char[] { '.' })[0]; switch (formats[i].ToUpper().Contains("POSTCARD")) { case true: xSize = 7 * 0.0254; ySize = 5 * 0.0254; xCenter = (xSize / 2); yCenter = (ySize / 2); orientation = "*Isometric"; break; case false: xSize = 2 * 0.0254; ySize = 2 * 0.0254; xCenter = (xSize / 2) - Settings.Default.WeirdArbitraryFactor; yCenter = (ySize / 2); orientation = "*Trimetric"; break; default: break; } swModel = (ModelDoc2)swApp.NewDocument(formats[i], (int)paperSize, xSize, ySize); swDraw = (DrawingDoc)swModel; bRet = swDraw.SetupSheet5("Sheet1", (int)paperSize, (int)drwgTemplate, 1, 1, false, template, xSize, ySize, "Default", false); View view = swDraw.DropDrawingViewFromPalette(76, xSize, ySize, 0); swDraw.ActivateView("Drawing View1"); bRet = swModel.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", xSize, ySize, 0, false, 0, null, 0); view = swDraw.CreateDrawViewFromModelView3(sourcePath, orientation, xCenter, yCenter, 0); bRet = view.SetDisplayMode3(false, (int)dispMode, false, true); //view.ScaleDecimal = GetAppropriateScalingFactor(swDraw, view, 0.8, 2); ScaleAppropriately(swDraw, view, 0.9, 2); swDraw.ActivateView(view.Name); TurnOffSillyMarks(); switch (monochrome[i]) { case true: SaveAribaLabel(Settings.Default.AribaPath); break; case false: SaveAsJPG(Settings.Default.JPGPath); break; default: break; } CloseThumbnail(); } }