0 Replies Latest reply on May 16, 2017 10:39 AM by Vincent Piazza

    Macro to Traverse Assembly Components and Change Configurations

    Vincent Piazza

      Hello,

       

      TL;DR: Using this code, I need to traverse assembly components and choose a configuration based off of a string search for each config. name instead of an exact match like the link shows.

       

           I need to create a unique assembly and drawing that will vary in size as required by the customer. Each of the parts in this assembly have many configurations that can be selected depending on the required size. I found a solution similar to what I'm looking for here: https://forum.solidworks.com/message/743608

       

           The problem that I am running into is that the configurations of the parts do not share the same naming convention, which means I cannot use an exact match to select the configurations as is done in the solution above. However, the parts do share the same 'size' in their configuration names, which is what I want to use to select the parts' configurations.

       

      For example:

           My assembly has 4 parts in it: a tee, 2 flanges, and a blind flange. Customer puts an order in for a Strainer of size NPS 12. So now I'd like pull that size requirement from an excel file (I already have the code for this) and select the configuration that has "NPS 12" in the configuration name for each of the parts, and then generate the drawing.

       

           Of course a lot more code is required to generate the drawing. I'm just having trouble getting the traversal loop to work with my requirements. I'm thinking using GetConfigurationNames() and then using InStr to search the string for NPS 12 could work, but the compiler is throwing errors when I try to implement that.

       

      Any help would be greatly appreciated!