Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

ILogic rule for loop/iterate through all open documents

tobias
Collaborator

ILogic rule for loop/iterate through all open documents

tobias
Collaborator
Collaborator

Hi,

 

I would like to have an iLogic rule which applies a certain command on all open drawings (idw's) and sheets.

 

In this specific case, my command as the folowing:

 

doc = ThisDoc.Document
		For Each oSheet In doc.Sheets
			For Each oView In oSheet.DrawingViews
				oView.ViewJustification = kCenteredViewJustification

 

Thanks

Tobias
The Netherlands
Inventor Pro 2025, Vault Pro 2025, AutoCad Electrical 2025.

If a response answers your question, please use ACCEPT SOLUTION to assist other users later.
0 Likes
Reply
Accepted solutions (1)
359 Views
3 Replies
Replies (3)

Andrii_Humeniuk
Advisor
Advisor
Accepted solution

Hi @tobias . This iLogic rule searches for all open .idw files and executes your sample code (lines 6-10).

Sub main
	Dim oInvApp As Inventor.Application = ThisApplication
	For i As Integer = 1 To oInvApp.Documents.Count
		Dim oDoc As Document = oInvApp.Documents(i)
		If System.IO.Path.GetExtension(oDoc.FullFileName) <> ".idw" Then Continue For
		For Each oSheet In oDoc.Sheets
			For Each oView In oSheet.DrawingViews
				oView.ViewJustification = kCenteredViewJustification
			Next
		Next
	Next i
End Sub

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

tobias
Collaborator
Collaborator

Thanks @Andrii_Humeniuk,

 

I had a couple of test drawings and the rule worked perfect.

But on some drawings (Checked out Vault drawings) I receive following error:

 

tobias_0-1696577129173.png

 

Any idea?

Tobias
The Netherlands
Inventor Pro 2025, Vault Pro 2025, AutoCad Electrical 2025.

If a response answers your question, please use ACCEPT SOLUTION to assist other users later.
0 Likes

tobias
Collaborator
Collaborator

I will make a new post for this.

 

Thanks again @Andrii_Humeniuk !

Tobias
The Netherlands
Inventor Pro 2025, Vault Pro 2025, AutoCad Electrical 2025.

If a response answers your question, please use ACCEPT SOLUTION to assist other users later.