Flipping "on" associate option on drawing views

NikelARH4K2
Contributor
Contributor

Flipping "on" associate option on drawing views

NikelARH4K2
Contributor
Contributor

Hello,

 

I am trying to update a massive packet of drawing and view reps all need to be updated. Does anyone have a piece of code that will go through a drawing and flip on the "Associate" option and hit "OK" on every view on the current open idw?

It would save so much time for me rather than doing it manually

 

thank you

0 Likes
Reply
Accepted solutions (1)
151 Views
2 Replies
Replies (2)

WCrihfield
Mentor
Mentor
Accepted solution

Hi @NikelARH4K2.  Give this iLogic rule a try for that task.

Sub Main
	If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Return
	Dim oDDoc As DrawingDocument = ThisDoc.Document
	Dim oSheets As Inventor.Sheets = oDDoc.Sheets
	For Each oSheet As Inventor.Sheet In oSheets
		Dim oViews As DrawingViews = oSheet.DrawingViews
		If oViews.Count = 0 Then Continue For
		For Each oView As DrawingView In oViews
			If oView.DesignViewAssociative = False Then
				Try
					oView.SetDesignViewRepresentation(oView.DesignViewRepresentation, True)
				Catch
					Logger.Error("Error setting DVR as Associative in view named:  " & oView.Name)
				End Try
			End If
		Next 'oView
		oSheet.Update
	Next 'oSheet
	oDDoc.Update
End Sub

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)

NikelARH4K2
Contributor
Contributor

That works beautifully thank you! i am going to tweak it to update all sheet before running the sub because if you dont Inventor crashes on my end

 

but once i update all the sheets it does exactly what i needed

 

thank you!

0 Likes