6 Replies Latest reply on Jan 15, 2014 1:29 PM by Keith Rice

    Extract part of a File Name into custom properties using equations

    Thomas Malinski

      I am trying to use an equation with code to extract the last 6 characters of a part filename (ignoring the extension) and passing them to a custom property named "DetailNo" A typical file name would be Widget_DT_101.sldprt. I need the "DT_101" passed to the "DetailNo" property

       

      I found sample code which was posted in an older thread. I copied it into an equation using the equation editor macro recommended and it works fine. However, it passes the entire filename to the property, I modified it subtly to work with my "DetailNo" property.

       

      I am looking for some help to update the code so it simply extracts the last 6 characters regardless of how long the file name is.

       

      "FileNameDetailNo"= part.Extension.CustomPropertyManager("").Set("D" & "e" & "t" & "a" & "i" & "l" & "N" & "o", Right(Replace(part.GetTitle, ".sldprt", "", 1, , 1), Len(Replace(part.GetTitle, ".sldprt", "", 1, , 1)) - InStrRev(Replace(part.GetTitle, ".sldprt", "", 1, -1, 1), ".")))

       

      Any help is greatly appreciated

      Tom Malinski