1 Reply Latest reply on Jan 30, 2015 12:01 PM by Keith Rice

    Replace text in a macro

    Rick Donnellon

      Below is a line from a macro posted by Deepak Gupta, thanks to Deepak for a great macro.

       

      This macro works great, but I have to make one change. The "SW-File Name" sometimes has a "_" in it that I need to change to a "/". I changed the "/" to a "_" in the file name for obvious reasons but now I need to change it back to a "/" in the Description property. I am hoping I can do it in this line of code? Any help would be appreciated.

       

      swModel.CustomInfo("Description") = "ELBOW, NPT TO TUBE, " & "$PRP:" + Chr(34) + "SW-File Name" + Chr(34)

        • Re: Replace text in a macro
          Keith Rice

          My understanding is that if you had a part called "my_part.SLDPRT", you would want it to appear in your custom properties as "my/part" or "my/part.SLDPRT"? (Would be nice to know if you wanted the file extension.)

           

          For starters, I would seriously question whether it is a good idea to be using an data management scheme that regards the desired file name as different from the actual file name. Even assuming that there's a good reason to do this, it will create a lot of extra work for you in the API. I can write a macro for you that will replace the underscore with a forward slash, but then if you ever change the file name, you'd have to reopen the part and rerun the macro. So is your organization intending on reopening the part and running this macro every single time the file name changes? You can see how this would create a lot of administrative overhead.

           

          If this isn't what you're looking to accomplish, I'd encourage you to edit your original question to make your needs a little clearer, and then I'll re-edit this post to help you better.

           

          Keith

          SolidWorks API Tutorials