Is there a way to access the drawing file linked to a part/assembly?

Is there a way to access the drawing file linked to a part/assembly?

ilona_roch
Observer Observer
235 Views
1 Reply
Message 1 of 2

Is there a way to access the drawing file linked to a part/assembly?

ilona_roch
Observer
Observer

Can I access the feature shown in the picture below thrugh the Inventor API?

From the drawing i can access the referenced parts with Document.ReferencedDocuments(), but I cant find a way to do it in reverse.

0 Likes
Accepted solutions (1)
236 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor
Accepted solution

Hi @ilona_roch.  There is actually no 'Link', or property, or attribute within the part to indicate if that part is being referenced by any drawings or assemblies.  So there is also no full file path or name of a drawing or assembly file that the part may be referenced by.  So, when you use that 'Open Drawing' tool in the right-click menu, it will simply 'try' to find a drawing file within the same folder that this active model file is saved within, and with the same exact file name as the active model file has, but obviously with the drawing file extension.  If one is found, it will open it.  If one is not found, it will usually show the Open File dialog, so that you can manually browse for it.  That's it.  If the drawing file is not saved in the same folder as the model file, or the file name of the drawing is different than the file name of the model file, it will not be able to find the drawing file, so it will not be able to open it either.

 

If all your drawing files are always saved in the same folder, and with the same file name as the model files, then we can do something by code that will simulate what that tool does within the right-click menu, with some code like the following.

 

Dim oDoc As Inventor.Document = ThisApplication.ActiveDocument
If oDoc Is Nothing Then
	Logger.Debug("No Active Document!")
	Return
End If
If (Not TypeOf oDoc Is AssemblyDocument) AndAlso (Not TypeOf oDoc Is PartDocument) Then
	Logger.Debug("Active Document Was Not A Part Or Assembly!")
	Return
End If
If oDoc.FileSaveCounter = 0 Then
	Logger.Debug("Active Document Has Not Been Saved Yet - No File Path Or File Name!")
	Return
End If
Dim sDrawingFile As String = System.IO.Path.ChangeExtension(oDoc.FullFileName, ".idw")
If System.IO.File.Exists(sDrawingFile) Then
	ThisApplication.Documents.Open(sDrawingFile, True)
Else
	Logger.Debug("No Drawing File Was Found For This Model Document!")
End If

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)

0 Likes