3 Replies Latest reply on Nov 8, 2018 8:00 AM by Deepak Gupta

    grab folder name that part is saved in from drawing?

    Mike Flanders

      You guys helped me with this code to add a custom property in my model of the folder name it is saved in, the below code works great. I actually pasted this into a sequence were it deletes dangling equations, prompts the save as screen & then creates the custom property. It is a very cool sequence. What I was wondering is if somehow we could add this folder name into the custom properties from the drawing itself. A lot of these parts I dont run any of these macro sequences to develop these cutting tools and I have the customer name on the blueprints pulled from this custom property. If I had a macro button in my drawings I could just hit the button and let the macro look at the parent view and basically run this code below to get it to add the custom property to the model from within the drawing. Does this make any sense??

       

       

      Set swApp = Application.SldWorks

          Set swModel = swApp.ActiveDoc

       

       

       

          ' Is a drawing document active?

       

       

          If swModel Is Nothing Then

          swApp.SendMsgToUser2 "A part/assy document must be open and the active document.", swMbWarning, swMbOk

          Exit Sub

          End If

       

       

      ' Is it a drawing document?

          If swModel.GetType = SwConst.swDocDRAWING Then

          swApp.SendMsgToUser2 "A part/assy document must be open and the active document.", swMbWarning, swMbOk

          Exit Sub

          End If

         

           Set cusPropMgr = swModel.Extension.CustomPropertyManager("")

          

           sFileName = Left(swModel.GetPathName, InStrRev(swModel.GetPathName, "\") - 1)

           sFileName = Mid(sFileName, InStrRev(sFileName, "\") + 1)

          

           cusPropMgr.Add3 "Folder Name", 30, sFileName, 1

       

       

       

       

       

      End Sub