I need to input the description manually into our PDM system until we get some scripting written. Does anyone know how I can copy the "Description" custom property of a model into the windows clipboard? This would allow me to 1. Open a model 2. Run the macro 3. Paste the description in the description field in PDM card.
We use Smarteam for PDM, but we are waiting on the next upgrade which should have new scripting to transfer the description automatically.
Just off the top of my head try this. In Windoze Explorer right click on the file, go to properties, go to custom tab, click on "description" in properties box, right click in value and select all, copy, then paste. Yes I now it's a lot of clicking but at least you don't have to open every file. Hope it helps.
Create a user form with a text box add code to the user form so it will extract the description and put it in the text box say it is Textbox1 add these lines
TextBox1.SelStart = 0 TextBox1.SelLength = TextBox1.TextLength TextBox1.Copy End
Here is some code I had lying around it was for a different purpose but it is similar
Private Sub UserForm_Initialize() 'code created by Corey Scheich Dim ThisSheet As SldWorks.Sheet Dim ThisView As SldWorks.View Dim ThisViewName As String Dim ModelName As String Dim ThisModel As SldWorks.ModelDoc2 Dim Description As String Dim CustomInfoNms() As String Dim Count As Long Dim swDrw As SldWorks.DrawingDoc Dim swApp As SldWorks.SldWorks
Set swApp = Application.SldWorks Set swDrw = swApp.ActiveDoc
Set ThisSheet = swDrw.GetCurrentSheet ThisViewName = ThisSheet.CustomPropertyView Set ThisView = swDrw.GetFirstView
Do While Not ThisView Is Nothing If ThisViewName = ThisView.Name Then Exit Do End If Set ThisView = ThisView.GetNextView Loop
If ThisView Is Nothing Then Set ThisView = swDrw.GetFirstView ModelName = ThisView.GetReferencedModelName While ModelName = "" And Not ThisView Is Nothing Set ThisView = ThisView.GetNextView If ThisView Is Nothing Then Exit Sub ModelName = ThisView.GetReferencedModelName Wend If ThisView Is Nothing Then Exit Sub End If Set ThisModel = swApp.GetOpenDocumentByName(ModelName)
CustomInfoNms = ThisModel.GetCustomInfoNames2("") Count = 0 Description = "" For Count = 0 To UBound(CustomInfoNms) If VBA.LCase(CustomInfoNms(Count)) = "description" Then Description = ThisModel.GetCustomInfoValue("", CustomInfoNms(Count)) Exit For End If Next
UserForm1.TextBox1 = Description TextBox1.SelStart = 0 TextBox1.SelLength = TextBox1.TextLength TextBox1.Copy End End Sub
I just tested this and it works You have to create a form named Userform1 and a text box named TextBox1
The first user form and textbox you create should be named this by default
then in the code for the userform add the code above you will never see the form when the code runs
Oh yeah that code is meant to be used from a drawing. You will have to strip it to use it from the model. Or edit it to check wether it is in a drawing or a model when you run it.
PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.