Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Open all idw in an assembly from assembly.

8 REPLIES 8
Reply
Message 1 of 9
gma
Advocate
1017 Views, 8 Replies

Open all idw in an assembly from assembly.

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

 

8 REPLIES 8
Message 2 of 9
bradeneuropeArthur
in reply to: gma

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 !

Message 3 of 9
gma
Advocate
in reply to: bradeneuropeArthur

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

Message 4 of 9
tomasz.dabrowskiUGC2B
in reply to: gma

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

 

Message 5 of 9
gma
Advocate
in reply to: tomasz.dabrowskiUGC2B

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.

Message 6 of 9
tomasz.dabrowskiUGC2B
in reply to: gma

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

Message 7 of 9
gma
Advocate
in reply to: tomasz.dabrowskiUGC2B

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

Message 8 of 9
tomasz.dabrowskiUGC2B
in reply to: gma

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
in reply to: gma

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)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report