SolidWorks EPDM secondary development entry (4)

Source: Internet
Author: User

Today I made an example of updating the file variables. It took a while to get it out. Paste the code.

File before variable change


Create a class library in VS and add the following method

''' <Summary> ''' obtain the file ''' </summary> ''' <param name = "files"> all added files </param>'' '<param name = "SetName"> BOM entry name </param> ''' <remarks> </remarks> Public Sub GetFiles (ByRef files () as EdmListFile, ByVal SetName As String) lst. createListEx (SetName, 0, cols) 'calls the method in IEdmBatchListing2 and adds the file lst. getFiles (files) 'Get all files in 'end Sub ''' <summary> ''' Update file information''' </summary> ''' <param name = "vName"> variable name </param> ''' <param name = "value"> variable value </param> ''' <remarks> </remarks> Public Sub BatchUpdateFileVariable (ByVal vName As String, byVal value As Object) Dim varMgr As IEdmVariableMgr5 'defines the variable Object varMgr = vault Dim var As IEdmVariable5 var = varMgr. getVariable (vName) 'gets the Dim Upate As IEdmBatchUpdate2 variable corresponding to vName, and defines the update object Upate = vault. createUtility (EdmUtility. edmUtil_BatchUpdate) Dim files () As EdmListFile = Nothing GetFiles (files, "") 'get the file For Each efile As EdmListFile In files Dim file As IEdmFile8 = vault. getObject (EdmObjectType. edmObject_File, efile. mlFileID) If Not file. isLocked Then file. lockFile (efile. mlFolderID, 0) End If Upate. setVar (efile. mlFileID, var. ID, value, "", 1) 'Add the content to be updated Next Dim Errors () As EdmBatchError2 = Nothing Dim errcount As Integer = Upate. commitUpdate (Errors) 'submit and catch Errors If errcount> 0 Then MsgBox ("error") Else MsgBox ("updated successfully") End If End Sub
Then create a form. before changing the variable, read the file (written in SolidWorks EPDM secondary development entry (1) and add a button.
The button code is as follows:
Try Finfo. batchUpdateFileVariable ("Project No.", "A395") 'calls the background update function Finfo. batchUpdateFileVariable ("project name", "SolidWorks") Catch ex As Exception MsgBox (ex. message) End Try the changed file variable below


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.