Open all idw in an assembly from assembly.

Open all idw in an assembly from assembly.

gma
Advocate Advocate
1,738 Views
8 Replies
Message 1 of 9

Open all idw in an assembly from assembly.

gma
Advocate
Advocate

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

 

0 Likes
1,739 Views
8 Replies
Replies (8)
Message 2 of 9

bradeneuropeArthur
Mentor
Mentor

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 & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
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:
My 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 !


 


EESignature

0 Likes
Message 3 of 9

gma
Advocate
Advocate

Yes, exactly ... And if it's possible to sort all released parts off, it will be nice.

0 Likes
Message 4 of 9

Anonymous
Not applicable

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

 

0 Likes
Message 5 of 9

gma
Advocate
Advocate

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.

0 Likes
Message 6 of 9

Anonymous
Not applicable

Where do You set status? In part/assembly iproperties or in drawing iproperties?

0 Likes
Message 7 of 9

gma
Advocate
Advocate

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

0 Likes
Message 8 of 9

Anonymous
Not applicable

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
Message 9 of 9

ts2.cad3
Enthusiast
Enthusiast

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)