Hello,
I am looking for an iLogic code, that can open all idw in an assmembly, and save and close the idw again.
It is when i take a copy design of an assembly og do some few change.... I need to update the new idw's.
And if it possible to deselect all released drawings it will be nice.
Thank in advance
Regards
Gosta
Do you mean.
From the assembly you would like to open all drawings that are related to the Parts and Subassemblies within the assembly, correct?
Regards,
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Yes, exactly ... And if it's possible to sort all released parts off, it will be nice.
I don't know if I understand correctly, but here is some code.
First it checks if a file with the same name but "idw" extension exist (I assume that drawings are in the same folder).
Then it checks if this drawing has status set to "relased" (I assume that you set this in drawing iproperties). If so, it skips saving document.
Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim subDoc As Document
Dim drawingDoc As DrawingDocument
Dim oFileName As String
For Each subDoc In oDoc.AllReferencedDocuments
oFileName = Left(subDoc.FullFileName, Len(subDoc.FullFileName) - 4) & ".idw"
If System.IO.File.Exists(oFileName) Then
drawingDoc = ThisApplication.Documents.Open(oFileName,False)
If drawingDoc.PropertySets.Item("Design Tracking Properties").Item("Design Status").Value = 3 Then
drawingDoc.Close(True)
Else
drawingDoc.Save
drawingDoc.Close(True)
End If
End If
Next
Yes, it works
But it is possible to sort Released files before opening / closing. Thinking it might save a lot of time that it does not open a released idw and then closes again. For me, a released part / ass = released idw.
I only need to open the idw in work in progress.
Where do You set status? In part/assembly iproperties or in drawing iproperties?
Both locations...
When I release a part, it makes a step file or dxf file (flatpattern). And when i release an idw it makes pdf
Ok, so now I check the status in part or assembly, before opening drawing.
Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim subDoc As Document
Dim drawingDoc As DrawingDocument
Dim oFileName As String
For Each subDoc In oDoc.AllReferencedDocuments
If subDoc.PropertySets.Item("Design Tracking Properties").Item("Design Status").Value <> 3 Then
oFileName = Left(subDoc.FullFileName, Len(subDoc.FullFileName) - 4) & ".idw"
If System.IO.File.Exists(oFileName) Then
drawingDoc = ThisApplication.Documents.Open(oFileName,False)
drawingDoc.Save
drawingDoc.Close(True)
End If
End If
Next
This work for me:
If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then MessageBox.Show("Please run this rule from the assembly file.", "iLogic") Exit Sub End If 'define the active document as an assembly file Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4) 'get user input RUsure = MessageBox.Show ( _ "QUESTA MACROI APRIR� TUTTI GLI IDW SE ESISTENTI." _ & vbLf & "This rule expects that the drawing file shares the same name and location as the component." _ & vbLf & " " _ & vbLf & "SEI SICURO DI VOLER PROCEDERE?" _ & vbLf & "CI VORR� UN PO'.", "iLogic - Batch OPEN IDW ",MessageBoxButtons.YesNo) If RUsure = vbNo Then Return Else End If Dim oDocument As Document = ThisApplication.ActiveDocument Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism ' Create a NameValueMap object Dim oOptions As NameValueMap oOptions = ThisApplication.TransientObjects.CreateNameValueMap ' Create a DataMedium object Dim oDataMedium As DataMedium oDataMedium = ThisApplication.TransientObjects.CreateDataMedium ' Check whether the translator has 'SaveCopyAs' options'get target folder path oFolder = oPath & "\" & "Export" 'Check for the folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If '- - - - - - - - - - - - -'- - - - - - - - - - - - -Component PDF Drawings - - - - - - - - - - - -'look at the files referenced by the assembly Dim oRefDocs As DocumentsEnumerator oRefDocs = oAsmDoc.AllReferencedDocuments Dim oRefDoc As Document Dim drawingDoc As DrawingDocument 'work the the drawing files for the referenced models'this expects that the model has a drawing of the same path and name For Each oRefDoc In oRefDocs idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "idw" 'check to see that the model has a drawing of the same path and name If(System.IO.File.Exists(idwPathName))=True Then '____Open and append to an existing text file_______ Try ThisDoc.Launch(idwPathName) Catch End Try Dim oAppend As System.IO.StreamWriter oFile = ThisDoc.PathAndFileName(False) & ".txt" oAppend = IO.File.AppendText(oFile) oAppend.WriteLine(oRefDoc.FullDocumentName) oAppend.Flush() oAppend.Close() Else 'If the model has no drawing of the same path and name - do nothing End If Next '- - - - - - - - - - - - - ThisDoc.Launch(oFile)