4 Replies Latest reply on Jul 7, 2014 10:23 AM by Todd Bennett

    Bounding box of all parts in an assembly?

    Todd Bennett

      Is there any way to open an imported assembly and extract the bounding box parameters to custom properties (x-dim, y-dim, z-dim) - without opening each part?

       

      I have a wonderful macro written by Hugo Pires.  The problem is, it  only does one part at a time and has more bells and whistles than I need.  It also has some issues with SW2014.

       

      Thank you,

      Todd

        • Re: Bounding box of all parts in an assembly?
          Todd Bennett

          Instead of opening each part from the assembly, I made a macro to go through a directory and open each SLDPRT.

          Then it creates a property for X, Y, and Z lengths, where X is always the longest dimension and Z is always the shortest.

          Next it changes the color of the part based on its thickness (Z dimension).

          After that, it creates a coordinate system at the corner, oriented appropriately.

          Finally, it exports an IGES file using the new coordinate system.

           

          It would have been nice to have beeen able to do this from the assembly, but that process seems  buggy using VBA - especially when you get several hundred parts and dozens of subassembly layers.

           

          I'd post it, but I don't know how.  At any rate, it could use some refining.

            • Re: Bounding box of all parts in an assembly?
              IMRAN JAGIRDAR

              Hi Bennett,

              Please provide the macro that computes the bounding box for each component in an assembly.

                • Re: Bounding box of all parts in an assembly?
                  Todd Bennett

                  I haven't had time to check in in a while.  I post what I made when I get back to the office.

                  • Re: Bounding box of all parts in an assembly?
                    Todd Bennett

                    Note:

                    I'm certain this could be cleaned up; I am not a programmer.

                    I have almost no error checking.

                    If you improve this, please share your improvements.

                     

                    How this works:

                     

                    1) Put your assembly and part files (or copies) in one specific directory.

                      I) Only files in this directory will be modified.

                      II) All SLDPRT files in this directory will be modified.

                         a) A new coordinate system will be added at X,Y,Z

                         b) Part colors will be changed according to thickness (smallest dimension).

                            i) The smallest dimension is always "Z".

                            ii) The largest dimension is always "X".

                            iii) If a thickness doesn't fit the list, the part will be black.

                      III) Exported files will be saved to this directory.

                     

                    2) Open SolidWorks.

                     

                    3) Run "ModifyParts.swp"

                     

                    4) Browse to the folder location in step 1.

                     

                    5) Choose whether you want to additionally export all parts as...

                      I) Iges

                      II) Step

                      III) Parasolid

                      IV) SAT

                     

                    6) Choose whether you want to additionally change the units of all parts to...

                      I) Millimeters

                      II) Inches

                     

                    7) Hit the Run button.