ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
TSTony Szuta04/03/2009
Hello,

I am having a bit of trouble getting the Document Manager to add or set custom properties to a list of parts that I have. The list of parts is actually a datagridview. The document manager can extract and display the properties just fine from my datagridview list. When it comes to writing them, nothing happens. I do not have the documents open, nor is SolidWorks running. Can you please take a look a snippet of my code and possibly tell me what is wrong? I have included "Imports SwDocumentMgr" at the very top of my code.

VB.NET Code

 


Const swDmKey = "MyswDmKeyGoesHere"
Dim swDocMgr As SwDMApplication
Dim swDoc As SwDMDocument3
Dim nretval As Long
Dim classfac As SwDMClassFactory
Dim x, rowX As Integer
Dim Prefix As String
Dim LaserName As String
Dim v As Object

classfac = CreateObject("SwDocumentMgr.SwDMClassFactory")
swDocMgr = classfac.GetApplication(swDmKey)
Prefix = InputBox("Please Enter Prefix")

For x = 1 To DataGridView1.RowCount - 1
LaserStatus.Text = "Updating: " & (DataGridView1.Item(3, rowX).Value)
StatusStrip1.Refresh()
LaserName = Prefix & "_" & DataGridView1.Item(1, rowX).Value
MsgBox(DataGridView1.Item(1, rowX).Value)
swDoc = swDocMgr.GetDocument(DataGridView1.Item(3, rowX).Value, SwDmDocumentType.swDmDocumentPart, True, nretval)
v = swDoc.GetCustomPropertyNames
swDoc.AddCustomProperty("LaserNo", SwDmCustomInfoType.swDmCustomInfoText, LaserName)
swDoc.SetCustomProperty("LaserNo", LaserName)
swDoc.CloseDoc()
rowX = rowX + 1
Next x

Thank you in advance for your help!