1 Reply Latest reply on Dec 18, 2015 9:22 AM by John Alexander


    Wanchai Hannarong

      Why my macro i call gettype for part it returen 0

        • Re: gettype
          John Alexander

          I believe there are several objects that provide getType methods - which are you calling it from?


          I''ll assume you are trying to get the type of model document.

          2012 SOLIDWORKS API Help - GetType Method (IModelDoc2)


          Notice the return value is a swDocumentTypes_e: 2012 SOLIDWORKS API Help - swDocumentTypes_e Enumeration


          This is just an enumeration that the solidworks library defines; basically like assigning integers to variables but more memory efficient because it (should) be handled during compilation rather than run-time.




          If you are troubleshooting something, it can be helpful to set up select case routines for printing the type to the immediate window.


          select case swModel.getType

               case swDocNONE

                    debug.print "swDocNONE"

               case swDocPART

                    debug.print "swDocPART"

               case swDocASSEMBLY

                    debug.print "swDocASSEMBLY"

          end select