Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Flipping "on" associate option on drawing views

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
NikelARH4K2
147 Views, 2 Replies

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

Flipping "on" associate option on drawing views

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

2 REPLIES 2
Message 2 of 3
WCrihfield
in reply to: NikelARH4K2

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)

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)

Message 3 of 3
NikelARH4K2
in reply to: WCrihfield

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

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!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report