Message 1 of 5
ilogic to change drawing custom iproperty in each drawing inside assembly file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I was wondering if someon can help me out with the following problem.
I have a custom iproperty Executieklass
I want to change this from 1 to 2 or from 2 to 1.
I want to choose this inside an assembly that it searches each drawing and opens it and changes the iproperty and closes it again.
I have a working rule to open the drawings but for some reason it's not chaning the iproperty.
My code below.
Sub Main() ' Get the active assembly. Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument Dim IPJ As String Dim IPJ_Name As String Dim IPJ_Path As String Dim FNamePos As Long 'set a reference to the FileLocations object. IPJ = ThisApplication.FileLocations.FileLocationsFile 'get the location of the last backslash seperator FNamePos = InStrRev(IPJ, "\", -1) 'get the project file name with the file extension IPJ_Name = Right(IPJ, Len(IPJ) - FNamePos) 'get the project name (without extension) IPJ_ShortName = Left(IPJ_Name, Len(IPJ_Name) - 4) 'get the path of the folder containing the project file IPJ_Folder_Location = Left(IPJ, Len(IPJ) - Len(IPJ_Name)) Dim newPath As String = IPJ_Folder_Location oDisplayName = oAsmDoc.DisplayName & ".dwg" Dim oDrwPath As String oDrwPath = newPath + "5. DWG & IDW\" ' Get all of the referenced documents. Dim oRefDocs As DocumentsEnumerator oRefDocs = oAsmDoc.AllReferencedDocuments ' Iterate through the list of documents. Dim oRefDoc As Document For Each oRefDoc In oRefDocs 'Dim oDrwName As String = oRefDoc.ReferencedDocumentDescriptor.ReferencedDocument.Displayname oDisplayName = oRefDoc.DisplayName & ".dwg" Dim fList = System.IO.Directory.GetFileSystemEntries(oDrwPath, "*.dwg",System.IO.SearchOption.AllDirectories).Where(Function(X) X.Contains(oDisplayName)) If fList(0) <> String.Empty Then Dim oDrwDoc As DrawingDocument oDrwDoc = ThisApplication.Documents.Open(fList(0), True) If iProperties.Value("Custom", "Executieklass") = "" Or iProperties.Value("Custom", "Executieklass") = "1" Then iProperties.Value("Custom", "Executieklass") = "2" Else End If Call oDrwDoc.Close Else MessageBox.Show(oDrwFile +" - Drawing is unavailable ") End If Next End Sub