7 Replies Latest reply on Sep 26, 2016 7:01 AM by John Stoltzfus

    my first macro program

    Ezz Elden Elaraby

      my first macro program  i hope give me your opinion in code

      i want to know how I think about a new program

      procedure that must be followed for the design of the program

      Do you prefer to use macro or not and why

      sorry for my bad English




        • Re: my first macro program
          Deepak Gupta

          Nice start but all dimensions are unconstrained which is not good. Also you can add codes for starting the new part instead of having user start the new part. This would ensure that it would not model in any open existing part.


          If I were to make a similar thing, I would make a master file and then use DriveWorksXpress (a free add-in in SOLIDWORKS since 2008) for automation or new models. It would be much simpler to use and customize.


          You can also use the macro to open the master file, create a copy with desired name in desired location and update that file based on inputs.


          Keep coding and keep learning.

          • Re: my first macro program
            Peter De Vlieger

            Very nice but on a side note you might want to include adjusting the angle of the bolt holes.

            I know it's easier to position one hole at 0° and then do the circular pattern but the correct way doesn't ever have a hole at 0°.


            this is wrong

            this is right.

              • Re: my first macro program
                Josh Brady

                Can you please explain why you shouldn't have a hole at 0°?  That's a new one on me.  The part is axisymmetric.  Who cares where the hole is?

                  • Re: my first macro program
                    Peter De Vlieger



                    Several reasons but it comes down that for one you do want all to be uniform considering rotation but most importantly because valves and other in-line equipment are designed so that if a bolt hole is at 0° and the pipe is horizontal then the valve stem wouldn't be able to be put straight up (or any 90° variation). Nor would a filter element be able to be at 180° nor a readout display of an instrument be on a parallel or perpendicular angle to the ground. In short, if the upper most two bolts aren't level, no matter the amount of holes you have, then the flange hasn't been mounted correctly.



                    The actual mechanical reason why way back when this became the norm will have to do with load bearing, as far as I recall. Think of it this way, in the case of 4 bolts the lower two take the stress of downward forces that will pull the bolt. If you do it wrongly, you only have one at the bottom taking the brunt of the burden which in turn could lead to higher risk of that one deforming/seizing. No doubt some one more knowledgeable then me can correct me on it if I'm wrong.


                    No matter what norms you follow, be they American, European, Japanese... they all state that having the bolts holes straddle the pipe is the standard. There can be reasons for not following it but without a special cause (or client asking) one doesn't deviate from it.

                • Re: my first macro program
                  Christian Chu

                  Looks Good !!!