ilogic check if drawing file is open

ilogic check if drawing file is open

Anonymous
Not applicable
1,200 Views
2 Replies
Message 1 of 3

ilogic check if drawing file is open

Anonymous
Not applicable

Good Day,

 

Does anyone her know how to check if a drawing file is open from an assembly rule?

If it is open to switch to the drawing.

If it is not open to open the drawing and switch to it.

 

Thanks.

0 Likes
Accepted solutions (1)
1,201 Views
2 Replies
Replies (2)
Message 2 of 3

dutt.thakar
Collaborator
Collaborator
Accepted solution

@Anonymous 

 

Can you try this rule and see if this works?

 

In this code, I am assuming you have the same names for drawing and its corresponding part/assembly file and they are located in the same path.

 

Dim oApp As Inventor.Application = ThisApplication
Dim oDoc As Document = oApp.ActiveDocument
ThisName = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName)
For Each Doc In oApp.Documents
	Dim oDC As Document = Doc
	If oDC.DocumentType = DocumentTypeEnum.kDrawingDocumentObject And System.IO.Path.GetFileNameWithoutExtension(oDC.FullFileName) = ThisName
			oDC.Activate
	Else If System.IO.Path.GetFileNameWithoutExtension(oDC.FullFileName) <> ThisName
			Dim str As String = (System.IO.Path.GetDirectoryName(oDoc.FullDocumentName) & "\" & ThisName & ".dwg")
			oApp.Documents.Open(str, True)
	End If
Next
	

 Hope this will help you.

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
Message 3 of 3

Anonymous
Not applicable

It worked like a charm thank you @dutt.thakar 

0 Likes