API help, automatic generation of 1/8" pipe

Discussion in 'SolidWorks' started by SW Monkey, May 27, 2004.

  1. SW Monkey

    SW Monkey Guest

    Im just starting to get into writing API, so ANY help would be
    appreciated :).

    I am trying to create a macro that automatically generates different
    sizes/schedules of pipe. What statement can I use to create the
    sketch profile, Fully defined, and extrude to desired lenght.

    Below is the code I currently have. It doesnt fully define the
    sketch, since the center of the pipe sketch isnt create on the origin
    of the part, plus it doesnt define the OD. The OD also doesnt come
    out correctly, it should be .405.

    If ComboBox1 = ".125 (.405 OD)" Then

    Dim Radius As Double
    Dim Depth As Double
    Radius = 0.405 / 2 * 0.0254
    Depth = 2 * 0.0254
    swModel.CreateCircleByRadius2 0.05 * 0.0254 + Radius, 0.05 *
    0.0254 + Radius, 0, Radius
    swModel.SketchOffset2 0.068 * 0.0254, 0, 1
    swModel.ViewZoomtofit2
    Set swFeatMgr = swModel.FeatureManager
    swFeatMgr.FeatureExtrusion True, False, True, 0, 0, Depth, 0,
    False, False, False, False, 0, 0, 0, 0, 0, 0, False, False, False
    swModel.ViewZoomtofit2
    End If
     
    SW Monkey, May 27, 2004
    #1
  2. I actually created a macro for exactly that a few months ago. E-mail me and
    I will send you th full thing and you can make changes to it as you desire
    or just use it as a reference. After you hit the button a form comes up
    with drop downs for Schedule and size and it shows the id and od that it is
    going to create then you type in the length in inches and hit Make tube. I
    created it quickly and with the schedules and sizes we use and I could find
    info on, So you may have to add some to fit your needs.

    Regards,

    Corey
     
    Corey Scheich, May 27, 2004
    #2
  3. Oooo, oooo, me too, please - email on the way.

    I can see this being useful for things other than just pipe that have a
    similar structure.

    WT
     
    Wayne Tiffany, May 27, 2004
    #3
  4. I have one for Square and rectangular tubing also. I am adding some notes
    to it I have been a bad programmer.

    Corey
     
    Corey Scheich, May 27, 2004
    #4
  5. At my company, we auto generate almost all of our piping parts (pipe,
    flanges, heads, etc.). While having a program to draw the part is
    nice, it can become cumbersome to write and a little slow for more
    complicated parts (like flanges). What we do is we have a part
    template for each kind of part (e.g. there's one for each style of
    flange that we use), and the parts are constructed in SolidWorks using
    linked dimensions and equations where possible to minimize the actual
    number of dimensions that are changed. Then when you tell the program
    you want a 4" standard pipe, or a 3" 300# raised face flange, it opens
    the correct part template file, changes the needed dimensions (which
    is easy with ModelDoc2->Parameter and the dimension name), and saves
    the part with the appropriate name. The other nice thing about this
    is that all the faces are named consistently for mating, which makes
    swapping out parts really easy.

    Jonathan Anderson

    To email me, include my first name in the email.
    And my last day here for a while is Friday, but if you really want to
    ask me a question after then email me at jlanderson at gmx dot net.
     
    Jonathan Anderson, May 27, 2004
    #5
  6. The other nice thing about this
    Funny I had actually thought about adding this but I didn't feel like doing
    it yesterday, maybe in the future.
     
    Corey Scheich, May 28, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.