Exemplo n.º 1
0
 /// <summary>
 /// Pass a double to sleep for fractions of a second. (0.1 sleeps for around 1/10 second)
 ///
 /// Do not use this method where accurate time is important. Accuracy will get worse with values of many seconds.
 /// </summary>
 /// <param name="seconds"></param>
 public static void WinSleep(double seconds)
 {
     // Handle very very short
     if (seconds < 0.002)
     {
         WinMacros.WinSleepShort(2);
     }
     else if (seconds <= 1)
     {
         WinMacros.WinSleepShort((int)(seconds * 1000));
     }
     else
     {
         WinMacros.WinSleepLong((int)(seconds * 100));
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Takes a screenshot of the document
        /// </summary>
        /// <param name="documentToWork"></param>
        /// <param name="locationToSaveImage"></param>
        /// <param name="setWhiteBg"></param>
        /// <param name="orbitToIso"></param>
        public static void ScreenShot(this Document documentToWork, string locationToSaveImage, bool setWhiteBg = false, bool orbitToIso = false)
        {
            Inventor.Application invObj           = (Inventor.Application)documentToWork.Parent;
            string             userColorScheme    = "";
            BackgroundTypeEnum userBackgroundType = BackgroundTypeEnum.kGradientBackgroundType;

            documentToWork.ZoomExtents();

            if (orbitToIso)
            {
                documentToWork.OrbitToIsoFrontRightTop();
            }

            invObj.WindowState = Inventor.WindowsSizeEnum.kMaximize;

            if (setWhiteBg)
            {
                // Save current color scheme info
                userColorScheme    = invObj.GetActiveColorSchemeName();
                userBackgroundType = invObj.GetActiveColorSchemeBackground();

                // Set white BG color scheme
                invObj.SetActiveColorScheme("Sky");
                invObj.ColorSchemes.BackgroundType = Inventor.BackgroundTypeEnum.kImageBackgroundType;
                WinMacros.WinSleep(1);
            }

            // Take screenshot
            invObj.ActiveDocument.SaveAs(locationToSaveImage, true);

            if (setWhiteBg)
            {
                // Restore original theme info
                invObj.ColorSchemes[userColorScheme].Activate();
                invObj.ColorSchemes.BackgroundType = userBackgroundType;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Pass int seconds to sleep a number of seconds.
 ///
 /// Do not use this method where accurate time is important. Accuracy will get worse with values of many seconds.
 /// </summary>
 /// <param name="seconds"></param>
 public static void WinSleep(int seconds)
 {
     WinMacros.WinSleepLong(seconds);
 }