ASSEMBLING PART CONFIGURATIONS WITH MACROS

Discussion in 'SolidWorks' started by Ariel, May 1, 2006.

  1. Ariel

    Ariel Guest

    I have created thausand of configurations out of a single SW part
    driven by a design table. Now I would like to automate the process of
    inserting those part configurations into a assembly file by running a
    macro.
    Is it possible?
    I will appreciate your advice.
    regards,
    Ariel
     
    Ariel, May 1, 2006
    #1
  2. Ariel

    TOP Guest

    Some of the access to configuration control of components in an
    assembly are limited. This may be one of those areas.

    Try recording a macro and see what you get.
     
    TOP, May 1, 2006
    #2
  3. Ariel

    Ariel Guest

    I recorded a macro as Mr. TOP suggested, I inserted 3 different
    configurations and saved the steps, however the result was not very
    happy, the macro inserts the same configuration 3 times, Does it mean
    that SW API can not control part configurations?
    Please let me know what you think.
    Ariel
     
    Ariel, May 1, 2006
    #3
  4. Ariel

    Mr. Who Guest

    FYI - I believe that parts with thousands of configurations can lead to
    very bad performance in large assemblies. I don't know off the top of
    my head, but maybe someone with more experience can chime in.

    As for adding the configuration. The API you want is:
    retval = AssemblyDoc.AddComponent4 ( compName, configName, x, y, z)

    See that the second parameter is configName. Just specify that and the
    proper configuration will be inserted.
     
    Mr. Who, May 1, 2006
    #4
  5. Ariel

    TOP Guest

    That is the limitation. It's been around since 2003 and probably
    before. As Mr. Who said, multi-config parts in a large assembly can
    slow things down.
     
    TOP, May 1, 2006
    #5
  6. Ariel

    Ariel Guest

    I am looking for a person who is able to write the above mentioned
    macro.
    If you are interested please let me know. then we can discuss about the
    specifics...
    Ariel
     
    Ariel, May 3, 2006
    #6
  7. Ariel

    Ben Eadie Guest

    Is this a size thing (i.e. diameter of a shaft changes to the receptacle
    hole)? Do you have 2006? If yes to both then lookup smart components,
    you may be able to do this yourself.

    Ben
     
    Ben Eadie, May 3, 2006
    #7
  8. Ariel

    Ariel Guest

    Mr. Who
    I have this litle macro that intents to insert a part configuration
    (#100 as you can see in the macro)
    do you know why it does not work? how do I tell SW to insert the
    configuration number 100??
    I will really appreciate your help!!!!!!!!!!!!Then i will create a
    loop for the macro to insert thousands of configurations, this is my
    ultimate goal.
    Ariel




    Dim swApp As Object
    Dim Part As Object
    Dim SelMgr As Object
    Dim boolstatus As Boolean
    Dim longstatus As Long, longwarnings As Long
    Dim Feature As Object
    Sub main()

    Set swApp = Application.SldWorks

    Set Part = swApp.ActiveDoc
    Set SelMgr = Part.SelectionManager
    AssemblyDoc.AddComponent4
    "K:\47200_20_Fenchurch_St\C_Product\10_Models\10A_Virtual\3dm\2006_03\AD\CW
    UNIT\CW UNIT L2.SLDPRT", 100
    End Sub
     
    Ariel, May 3, 2006
    #8
  9. Ariel

    Ariel Guest

    Mr. Who
    I have this litle macro that intents to insert a part configuration
    (#100 as you can see in the macro)
    do you know why it does not work? how do I tell SW to insert the
    configuration number 100??
    I will really appreciate your help!!!!!!!!!!!!Then i will create a
    loop for the macro to insert thousands of configurations, this is my
    ultimate goal.
    Ariel




    Dim swApp As Object
    Dim Part As Object
    Dim SelMgr As Object
    Dim boolstatus As Boolean
    Dim longstatus As Long, longwarnings As Long
    Dim Feature As Object
    Sub main()

    Set swApp = Application.SldWorks

    Set Part = swApp.ActiveDoc
    Set SelMgr = Part.SelectionManager
    AssemblyDoc.AddComponent4
    "K:\47200_20_Fenchurch_St\C_Product\10_Models\10A_Virtual\3dm\2006_03\AD\CW
    UNIT\CW UNIT L2.SLDPRT", 100
    End Sub
     
    Ariel, May 3, 2006
    #9
  10. Ariel

    Mr. Who Guest

    What you are describing now and what you described earlier are
    different. Initially you said you wanted to insert a part into an
    assembly using a specified configuration.
    "I would like to automate the process of inserting those part
    configurations into a assembly file ."

    Now you are saying that you want to insert a new configuration into a
    part.
    "I have this litle macro that intents to insert a part configuration "

    To insert configuration "100" of a file called "PathToPart.sldprt" at
    the assembly origin you would use:
    AssemblyDoc.AddComponent4 ( compName, configName, x, y, z)
    AssemblyDoc.AddComponent4 "pathToPart.sldprt", "100", 0, 0, 0 (insert
    at origin of assembly)

    To add a configuration to a part called "100" you would use:
    ModelDoc2.AddConfiguration3 ( Name, Comment, AlternateName, Options )
    PartDoc.AddConfiguration3 "100", "", "", 0
     
    Mr. Who, May 3, 2006
    #10
  11. Ariel

    Tin Man Guest

    Ariel,

    Yes it is possible. I have one that I use for fasteners and hardware. I
    also mates them for me too. It was done with API and multiple files
    (each with multiple configurations).

    Ken
     
    Tin Man, May 3, 2006
    #11
  12. Ariel

    Ariel Guest

    Mr Who
    I appreciate your help a lot. It is being really helpful.
    What I need is To insert configuration "100" of a file called
    "PathToPart.sldprt" at
    the assembly, however I do not want to insert the confguration at the
    assembly 0,0,0, the part should be inserted according to its own
    original position, otherwise nothing would work for me.I have thousands
    of windows configurations, each of them has a unique shape and position
    in space since they cover a free-form building curtain-wall.

    Both, the building wireframe I am using as support and the
    configurations share the same 0,0,0...
    Regards,
    Ariel
     
    Ariel, May 4, 2006
    #12
  13. Ariel

    Mr. Who Guest

    Hmmm, so you have lots of windows and need to place them into the
    assembly at specific locations.

    What do you mean by "part should be inserted according to its own
    original position." What data do you have available so that you know
    what x,y,z points to use for inserting the component?
     
    Mr. Who, May 4, 2006
    #13
  14. Ariel

    Ariel Guest

    Mr. who
    I have created a generic window (a part) that has 4 corners. each
    corner position (xyz) is control by a design table, meaning that each
    windows needs 12 values (4 corners*3 values per corner=12). Each of
    thiese corners has 3 dimensioanl contrains related to the 0,0,0. So the
    design table is fill out with rows of 12 numbers that control each
    window corner.
    If I wanted to create the assembly manually, I just would insert each
    configuration one by one (as you can imagine it would a insane task). I
    use insert new componet, then i selectt the part, then i select the
    configuration, and then I click OK, so the configuration flys to the
    right position automatically.

    So the keypoint is to create a macro that takes each window coordinates
    into consideration. May be it could use the design table to drive the
    windows, (i am wondering)
    THANK YOU!!!!
     
    Ariel, May 4, 2006
    #14
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.