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
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.
Great suggestion from Deepak regarding the master file. Take a look at the methods below as they might be handy and significantly improve the performance of your macro:
2012 SOLIDWORKS API Help - Parameter Method (IModelDoc2)
2012 SOLIDWORKS API Help - SetSystemValue3 Method (IDimension)
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.
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?
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.
Thanks for the explanation - never heard it laid out that way.
Looks Good !!!
Retrieving data ...