6 Replies Latest reply on Dec 29, 2015 10:45 AM by Josh Brady

    To show Custom Property Dialogue Box through api

    Mr Omkar Deshpande

      Hi,

         I am writing a code in which, i want to give user to the access to the custom property dialogue box. I used

      Application.SldWorks.RunCommand swCommands_File_Summaryinfo, ""

      It will throw the custom property window through API.However, macro doesn't wait till user updates the value and press 'OK'.

      How can i achieve it??

      Thanks in advance

      Omkar

        • Re: To show Custom Property Dialogue Box through api
          Deepak Gupta

          You can try using Click OK notify event.

          • Re: To show Custom Property Dialogue Box through api
            Josh Brady

            RunCommand isn't really a good way to write macros.  It's exactly equivalent to the user activating the command from the interface.  You can't monitor what happens next.  There is no practical way that I know of to achieve what you're asking.  You may be able to do some fancy Windows API stuff, but that's not a good idea.  You would be better off creating your own UserForm and accessing custom properties with it.  Either that, or separate your macro into two macros and have your user run the second after closing the custom properties dialog.

              • Re: To show Custom Property Dialogue Box through api
                Mr Omkar Deshpande

                My actual requirement is to allow user to select the dimensions which are to be attached in the custom properties. Now there are n number of parts and i have automated rest of the things (i.e. opening/closing parts, calculating part numbers etc). Dimension selection remains manual as there is no logic.

                 

                I even considered using my own userform instead of Custom Property window, but the real problem is, to allow the dimension selection, form has to be 'modeless'; and hence, macro doesn't wait until user selection.

                 

                I will modify my question as "How to pause the macro while a modeless form is open?"

                 

                Thanks a lot for reply

                  • Re: To show Custom Property Dialogue Box through api
                    Josh Brady

                    You may need to reconsider the structure/arrangement of your code.

                     

                    If the form is modeless, then once the form is visible it will not go away until the user or some code closes it.  So, you just make your code end at the point where you want the user to do something.  Then you have a couple of options. 

                     

                    The easiest option is that you give the user a button on the form to click after they have selected the dimensions.  The remaining code to do what you need done goes in that button's click event.

                     

                    The next option (which is more complicated but makes for fewer clicks by the user) is to register for the UserSelectionPostNotify event.  Then SW will tell you when the user makes any selection.  You have to then verify with your code that the current set of selections matches the required selection set to continue with your code.

                • Re: To show Custom Property Dialogue Box through api
                  Digvijay Taunk

                  you can keep it running in loop until user selection. to track it use GetSelectionObjectCount.

                  like this:

                    Do Until SelMgr.GetSelectedObjectCount2(0) <> 0
                              MsgBox("NOt Found")
                              System.Threading.Thread.Sleep(500)
                          Loop
                          MsgBox("Found")
                  

                   

                  Also you can use sleep to wait some time until next rotation of loop. To get specific type of user selection use "GetSelectedObjectType3" in line 1