open all idw from assambly

open all idw from assambly

sjoerd.van.der.eerden
Contributor Contributor
381 Views
4 Replies
Message 1 of 5

open all idw from assambly

sjoerd.van.der.eerden
Contributor
Contributor

Hi, I was wondering if it is possible to open all the idw files from an assambly?

I know it is possible for parts but I dont know how to do it for idw files. 

 

'Define the open document
Dim oDoc As Document
oDoc = ThisDoc.Document  
'Look at all of the files referenced in the open document
Dim docFile As Document
For Each docFile In oDoc.AllReferencedDocuments                
'open the indexed file
'true opens the file normaly
'false opens the file programatically without generating the graphics
ThisApplication.Documents.Open(docFile.FullFileName, True) 
Next

 

this code opens all the parts in an assambly.  

0 Likes
Accepted solutions (1)
382 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor
Accepted solution

Hi @sjoerd.van.der.eerden.  Unfortunately there usually is not a direct link (or reference) from model files to a drawing document in which they may be featured in a view.  This 'link' is usually only discoverable if both the model and drawing are open at the same time.  If you had Vault, you might be able to get around this limitation.  So, the next best way to open all drawings that may be associated with the model files being referenced within an assembly, is if there is a consistent file storage & file naming convention that can be predicted, because we would basically need to open the drawings by guessing what path they are stored at, and what nave they have been given.  One common scenario is to save the drawing file with the same name as the model file, and store it in the same place as the model file.  If this is the case, then a simple iLogic rule like the following may work for you.

Dim oDoc As Document = ThisDoc.Document
For Each oRefDoc As Document In oDoc.AllReferencedDocuments
	Dim oDrawFile As String = System.IO.Path.ChangeExtension(oRefDoc.FullFileName, ".idw")
	If Not System.IO.File.Exists(oDrawFile) Then Continue For
	Dim oDrawDoc As DrawingDocument = ThisApplication.Documents.Open(oDrawFile, True)
Next

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 5

Dev_rim
Advocate
Advocate

Hi There,

It's possible to filter referenced documents by type and open them.

But there is one thing I can't understand, what condition you need open them normally and what condition without generating graphics.

Here is the code that checks every referenced document, opens them. If they are Drawing files, it will open them visible, If they are some other kind of document, they will be opened invisible (at background).

 

Sub main()
Dim odoc As Document
Set odoc = ThisApplication.ActiveDocument
Dim doc As Document
For Each doc In odoc.ReferencedDocuments
    If doc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
        Call ThisApplication.Documents.Open(doc.FullFileName, True)
    Else
        Call ThisApplication.Documents.Open(doc.FullFileName, False)
    End If
Next
End Sub

 

I hope it helps.

 

Best Regards

Devrim

If my answer is solved your problem, please mark it as Solution

Freundliche Grüße / Kind Regards
0 Likes
Message 4 of 5

sjoerd.van.der.eerden
Contributor
Contributor

inventor says that the set instruction no longer availeble is. 

 

0 Likes
Message 5 of 5

sjoerd.van.der.eerden
Contributor
Contributor

thanks, this works great.

0 Likes