0 Replies Latest reply on Nov 7, 2017 3:33 AM by Jana Fischer

    Issues with IConfigurationManager.SetConfigurationParams

    Jana Fischer

      I created this thread to collect issues regarding the method IConfigurationManager.SetConfigurationParams, in hope of convincing the SolidWorks API team to fix these bugs. If anyone has experienced other issues with this method or its sibling IConfiguration.SetParameters, please leave a note together with models and macros reproducing the issue.

       

      Note: This thread is NOT for discussing workarounds or alternatives to the above method(s). Its sole purpose is to collect issues with it/them.

       

      These issues are currently (as of 3rd Nov 2017) collected in

      SPR 1018580 : Few issues regarding the method IConfigurationManager::SetConfigurationParams.

       

      Note: This is the display pane (it is needed to reproduce some of the issues below):

      displayPane.png

       

      1. Increasing the number of pattern instances does not work:

      --------------------------------------------------------------------------------

       

      If we have a dimension that is a pattern instance number, and we increase that number via SetConfigurationParams, SolidWorks does not create the new components correctly. To reproduce this, open the assembly "example1.sldasm" and the macro "issue1.swp" and

       

      - expand the display pane,

      - expand the assembly "mid1^example" and the pattern "LocalLPattern1",

      - run the macro.

       

      In the display pane we can see that something went wrong: The two new components do not have any symbols for the appearance (marked red). If we click inside the marked area, SolidWorks crashes.

      corruptedComponents.png

       

      If we save the file after running the macro, close and reopen it, the newly created components are gone.

       

      I want to mention another strange behaviour of the display pane. To reproduce it, first close SolidWorks and reopen it. Reopen "example1.sldasm" and macro "issue1.swp" and then

      - collapse the display pane,

      - run the macro,

      - expand the display pane.

       

      Now the display pane does not show any symbols, and if we move/resize it, it "stutters".

      displayPaneStuttering.png

       

      Reproduced with: SolidWorks2016 SP5.0, SolidWorks2017 SP1.0.

       

       

      2. Changing dimensions in some models lets the display pane "stutter":

      ----------------------------------------------------------------------------------------------

       

      In most models I tried, SetConfigurationParams works ok when setting "ordinary" dimensions (which is: not pattern instance numbers).

       

      For some models however, the stuttering display pane issue occurs as well. The reason might be that these models were created in older SolidWorks versions, but I don't know if this is a general rule. My example (example2.sldasm) was created with SolidWorks 2012 (and saved in SolidWorks2016), and the problem occurs. When I built a new model from scratch in SolidWorks2016 similar to that one, the problem did not occur.

       

      To reproduce, open "example2.sldasm" and the macro "issue2.swp" and

      - collapse or expand the display pane (does not matter which)

      - run the macro,

      - (expand the display pane if necessary) resize the display pane.

       

      Reproduced with: SolidWorks2016 SP5.0, SolidWorks2017 SP1.0.

       

       

      3. Permanent information loss when suppressing components:

      ----------------------------------------------------------------------------------

       

      First I changed a pattern instance number via IDimension.SetValue3 and then used SetConfigurationParams to suppress a component. After this, information sometimes gets lost. This information includes:

       

      - the ID of components (IComponent2.GetID) -> -1 is returned.

      - the name of the referenced configuration of components (IComponent2.ReferencedConfiguration) -> "" is returned.

      - the data that says if a component is a pattern instance (IComponent2.IsPatternInstance) -> False is returned.

      - the persistent ID of components (ModelDocExtension.GetPersistReference3) -> null/Empty is returned.

       

      Because I could not reproduce this issue 100% of the time, I wrote a macro that runs the following things in a loop:

       

      - reload file

      - change pattern instance number via IDimension.SetValue3

      - change suppression state of a component via SetConfigurationParams

      - do EditRebuild and ForceRebuild

       

      until either a component has an ID of -1 or the loop ran 20 times.

       

      To reproduce, open "example1.sldasm" and "issue3.swp" and run the macro. Inspect the immediate window.

      You will notice that the output can differ from run to run: Sometimes just one component has lost information, sometimes several components. The number of runs necessary until a data loss occurs can also differ.

       

      It is important to note that this data loss is permanent in the sense that even a ForceRebuild does not restore the data. The only way I found to restore the data was to close and reopen the file (with or without saving).

       

      Reproduced with: SolidWorks2016 SP5.0, SolidWorks2017 SP1.0.

       

       

      4. Component loses its children - only in API, not in GUI:

      --------------------------------------------------------------------------

       

      In an assembly with 3 levels of nestedness, if a suppressed component of level 2 is unsuppressed via SetConfigurationParams, its children cannot be retrieved via API.

       

      To reproduce, open "example4.sldasm" and "issue4.swp". Run the macro. Inspect the immediate window. It will show the suppression state and the children of component "assy2^assy1_example3-1" before and after this component was resolved. After it was resolved, it should show 4 child components but it does not show any.

       

      Running the macro several times will toggle the suppression state of the component between suppressed and resolved. It will still not show any children no matter what the suppression state is.

       

      If the user selects one of the children of "assy2^assy1_example3-1" once via GUI, from then on it is possible to retrieve the children. So whenever the macro is run again after that, the immediate window will show all children correctly (as long as the file is not closed and reopened).

       

      Reproduced with: SolidWorks2016 SP5.0, SolidWorks2017 SP2.0.

       

      5. Permanent informaton loss when changing configurations of components:

      -----------------------------------------------------------------------------------------------------

       

      This is similar to issue 3 regarding the nature of the data loss (GetID will return -1, ReferencedConfiguration will return "" and so on, this cannot be repaired by ForceRebuild). It occurs when

      1. a top-level component, "comp", is resolved with either SetConfigurationParams or SetSuppression2 and

      2. a child of comp, "child", gets its configuration changed with SetConfigurationParams.

      It seems that only children of "child" are affected by data loss.

       

      To reproduce, open "example5.sldasm" and macro "issue5.swp". This macro is similar to "issue3.swp" in that it runs in a loop until data loss occurs. The number of loops needed and the number of components affected varies from run to run.

       

      Reproduced with: SolidWorks2016 SP5.0, SolidWorks2017 SP2.0.

       

      6. Dimension change when hole feature gets suppressed - only in API, not in GUI:

      ----------------------------------------------------------------------------------------------------------

       

      Suppressing a hole feature can lead to a changed dimension of a sketch belonging to that feature. To reproduce, open "example6.sldasm" and macro "issue6.swp" and run the macro. It outputs the dimension value of a certain dimension of sketch10 before and after the suppression (it changes from 19 to 20).

       

      It makes no sense that the dimension changes since the board has a width of 19mm, not 20. Also, this dimension change does not occur if the suppression is set with IFeature.SetSuppression2. In GUI, the change cannot be seen (except when the dimension is opened in the property manager).

       

      Reproduced with: SolidWorks2016 SP5.0, SolidWorks2017 SP2.0.

       

       

      7. Changing a dimension can make it invalid and leave a missing reference:

      -----------------------------------------------------------------------------------------------------

       

      I could not reproduce this issue with a newly-built model, so I assume that it is file-specific. Check "example7.sldasm": There is an extrude feature "Basis-Linear austragen" in part1 which has its Direction1 set to "Blind" and its dimension D1 set to 600.00mm. If we change this dimension via SetConfigurationParams (use "issue7.swp") to something else, the Direction1 will switch to "Up to Surface" but leave the required surface reference open, resulting in a missing reference. Also, the dimension will be gone.

       

      Using IDimension.SetValue3 does not produce this issue and sets the dimension correctly.

       

      If the extrude feature is edited before running the macro (click "Edit Feature", then click "ok" - no need to change any settings), SetConfigurationParams works as expected. I assume that this editing cleans up a possibly dirty state of the feature. It seems that SetValue3 does this cleaning as well, but SetConfigurationParams does not (which it should do since the API programmer can't see the dirty state, so can't react on it).

       

      Reproduced with: SolidWorks2016 SP5.0, SolidWorks2017 SP2.0.

       

      8. Component inside folder loses its children - only in API, not in GUI:

      --------------------------------------------------------------------------

       

      In an assembly with 3 levels of nestedness, if a folder that contains a component of level 2 is unsuppressed via SetConfigurationParams, the children of the component cannot be retrieved via API.

       

      To reproduce, open "example8.sldasm" and "issue8.swp". Run the macro. Inspect the immediate window. It will show the number of child components of component "midAssy^example8-1/subAssy^midAssy_example8-1" after the folder was resolved. It should list 2 children but it does not show any.

       

      If you comment out the section marked with "version that makes child components vanish" and uncomment the section "version that works" (and reload the assembly and run the macro again), you can see that this time the component has 2 children, as expected.

       

      Reproduced with: SolidWorks2017 SP4.1.