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: 

Suppress different drawing views in a for loop?

2 REPLIES 2
Reply
Message 1 of 3
Preston_Reed
283 Views, 2 Replies

Suppress different drawing views in a for loop?

Hello, I am working on a configurator that has various parts that will be optional. I have the model working fine but now I am trying to figure out how to deal with the drawing package (im still pretty new to this).  My plan was to have every part dimensioned and turn off the ones that are not included.  For example, there is a leg kit option, LEG_KIT_12IN & LEG_KIT_6IN.  The leg kits are 2 piece, there is a wrapper and base.  On the piece part drawing I will just have one page for leg kit base and one page for leg kit wrapper.  Each page will have both sets of drawings and then I can just make a simple conditional statement to turn one off. 

 

The issue I am running into is that from my understanding is that I can only use  

ActiveSheet.View("VIEW74").View.Suppressed = True 		'6 IN LK BASE

when the individual page is active, and I am going to have multiple pages.  And you cannot turn individual pages off at all.  So I would need to run a for loop to activate the pages and then make my conditional statements to suppress views.  Can I run different rules for each loop as it moves through the pages?  Or would it be better just to include all the rules in every loop and make it skip over errors once it doesnt find specific views on that page?  Or should I be going about this in a different way.  Any help would be greatly appreciated.   Thank you

 

 

PREED7QR59_0-1645223629717.png -all on (for example)

PREED7QR59_1-1645223663544.png - one on (for example)

 

 

 

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

Hi @Preston_Reed.  There really is not enough details here for me to know what things to check for about sheet, or what to check about each view, so I just created a very basic alternative iLogic rule code with an example of a loop of all sheets and all views on each sheet, with a couple basic things about each.  You will likely have to change a lot about this code to suit whatever your needs are, but this is just another main approach.

Dim oDDoc As DrawingDocument = ThisDoc.Document
For Each oSheet As Sheet In oDDoc.Sheets
	oSheetName = oSheet.Name.Split(":")(0) 'the part before ":"
	oSheetNumber = oSheet.Name.Split(":")(1) 'the part after ":"
	'check other stuff about the sheet here if needed
	For Each oView As DrawingView In oSheet.DrawingViews
		'check stuff about the oView object here if needed
		If oView.Name = "VIEW1" Then
			'if you want to suppress the view
			If Not oView.Suppressed Then
				oView.Suppressed = True
			End If
		End If
	Next
Next

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 3
Preston_Reed
in reply to: WCrihfield

Hey @WCrihfield thank you very much for the reply.  I think you helped quite a bit.  I will be messing with it more this week but it seems to be working how I envisioned so far.  This isnt done but its a glimpse of what Im doing.  Ill give more updates later this week and ask more questions if needed.  

 

Sub MAIN
	ViewsOnOff
End Sub

Sub ViewsOnOff()

	On Error Resume Next

	Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
	Dim oSheet As Sheet

	i = 1

	For Each oSheet In oDrawDoc.Sheets

	i = i+1

	ThisApplication.ActiveDocument.Sheets.Item(i).Activate
	
	ActiveSheet.View("VIEW74").View.Suppressed = False 					'6 IN LK BASE
	ActiveSheet.View("VIEW75").View.Suppressed = False 					'6 IN LK BASE
	
	ActiveSheet.View("VIEW88").View.Suppressed = True					'12 IN LK BASE
	ActiveSheet.View("VIEW89").View.Suppressed = True					'12 IN LK BASE
Next

'If i = 26 & LEG_KIT_6IN = True Then
	
'	ActiveSheet.View("VIEW74").View.Suppressed = False 					'6 IN LK BASE
'	ActiveSheet.View("VIEW75").View.Suppressed = False 					'6 IN LK BASE
	
'	ActiveSheet.View("VIEW88").View.Suppressed = True					'12 IN LK BASE
'	ActiveSheet.View("VIEW89").View.Suppressed = True					'12 IN LK BASE
	
'End If 

End Sub

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

Post to forums  

Autodesk Design & Make Report