Suppressing Views in an .idw

Suppressing Views in an .idw

ASchlaack
Collaborator Collaborator
870 Views
8 Replies
Message 1 of 9

Suppressing Views in an .idw

ASchlaack
Collaborator
Collaborator

I'm currently running a rule:

 

If Parameter("15-1-0000.iam.Length_1") <= 60 Then
	ActiveSheet.View("VIEW69").View.Suppressed = True

End If

 *that's not the whole rule but it's enough to get the point...

 

 

 But unless I'm on the sheet that view is on (Sheet 15) I get this error:

 

Capture.PNG

 

How can I change the rule to work no matter what sheet I'm on when the rule is fired?

Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
0 Likes
Accepted solutions (1)
871 Views
8 Replies
Replies (8)
Message 2 of 9

bretrick30
Advocate
Advocate

The code you are using will only access the views on the Active Sheet.  To do what you are looking for, you will need to loop through the sheets and the views on each sheet to find the one you want to suppress.

 

SyntaxEditor Code Snippet

oDoc = ThisDoc.Document
Dim oSheet As Sheet

For Each oSheet In oDoc.Sheets
    Dim oView As DrawingView
    For Each oView In oSheet.DrawingViews    
        If oView.Name = "VIEW69" Then
            oView.Suppressed = True
        End If    
    Next
Next

 

Using this you can also suppress any other views by either doing an if statement with an Or:

 

SyntaxEditor Code Snippet

If oView.Name = "VIEW69" Or oView.Name = "VIEW70" Or oView.Name = "VIEW71" Then
    oView.Suppressed = True
End If    


Or by doing a Select Case:

 

SyntaxEditor Code Snippet

Select Case oView.Name
    Case "VIEW69","VIEW70","VIEW71"
        oView.Suppressed = True

End Select

 

 

Message 3 of 9

ASchlaack
Collaborator
Collaborator
I'd like to do the case one, how do I program in the varibles? Right now they are If then statements.
Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
0 Likes
Message 4 of 9

bretrick30
Advocate
Advocate

You can put the whole loop inside of an If Statement.  I'm assuming you will want an else to that if statement for when the value is not less than or equal to 60 it will turn those views back on.

 

SyntaxEditor Code Snippet

oDoc = ThisDoc.Document
Dim oSheet As Sheet

If Parameter("15-1-0000.iam.Length_1") <= 60 Then
    For Each oSheet In oDoc.Sheets
        Dim oView As DrawingView
        For Each oView In oSheet.DrawingViews    
            Select Case oView.Name
                Case "VIEW69","VIEW70","VIEW71"
                    oView.Suppressed = True
            End Select
        Next
    Next
Else
    For Each oSheet In oDoc.Sheets
        Dim oView As DrawingView
        For Each oView In oSheet.DrawingViews    
            Select Case oView.Name
                Case "VIEW69","VIEW70","VIEW71"
                    oView.Suppressed = False
            End Select
        Next
    Next
End If
0 Likes
Message 5 of 9

ASchlaack
Collaborator
Collaborator

Well without trying to be too complicated, I have 4 varibles...

 

If Parameter("15-1-0000.iam.Length_1") <= 60 Then

Else If Parameter("15-1-0000.iam.Length_1") > 60 in And Parameter("15-1-0000.iam.Length_1") <= 120 in Then

Else If Parameter("15-1-0000.iam.Length_1") > 120 in And Parameter("15-1-0000.iam.Length_1") <= 180 in Then

Else If Parameter("15-1-0000.iam.Length_1") > 180 in Then

 And I have 12 different things that get supressed and unsurpressed at different times... I don't want to make you have to do huge amounts of work for me but could you show me how I can do the else if using cases if that's possible please?

Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
0 Likes
Message 6 of 9

bretrick30
Advocate
Advocate

 

 

SyntaxEditor Code Snippet

SyntaxEditor Code Snippet
Select Case Parameter("15-1-0000.iam.Length_1")
    Case 60 To 120
        'Enter Code Here
    Case 121 To 180
        'Enter Code Here
    Case >180
        'Enter Code Here
    Case Else
        'This will be when it is under 60
'If it will never be under 60 you dont have to use this. I like having all cases covered. End Select
0 Likes
Message 7 of 9

ASchlaack
Collaborator
Collaborator

Thank you for your help so much and I'm sorry to be a pain but since these parts will turn on and off because my length will checnge I'd need to say if it's surpressed or unsupressed in each case correct? I can't get a way to get this to work. Here's my current code that works but only if I'm on the right sheet:

 

If Parameter("15-1-0000.iam.Length_1") <= 60 Then
	ActiveSheet.View("VIEW69").View.Suppressed = True
	ActiveSheet.View("VIEW70").View.Suppressed = True
	ActiveSheet.View("VIEW72").View.Suppressed = True
	ActiveSheet.View("VIEW73").View.Suppressed = True
	
Else If Parameter("15-1-0000.iam.Length_1") > 60 in And Parameter("15-1-0000.iam.Length_1") <= 120 in Then
	ActiveSheet.View("VIEW69").View.Suppressed = False
	ActiveSheet.View("VIEW70").View.Suppressed = False
	ActiveSheet.View("VIEW72").View.Suppressed = True
	ActiveSheet.View("VIEW73").View.Suppressed = True
	
Else If Parameter("15-1-0000.iam.Length_1") > 120 in And Parameter("15-1-0000.iam.Length_1") <= 180 in Then
	ActiveSheet.View("VIEW69").View.Suppressed = True 
	ActiveSheet.View("VIEW70").View.Suppressed = True
	ActiveSheet.View("VIEW72").View.Suppressed = False
	ActiveSheet.View("VIEW73").View.Suppressed = False
	
Else If Parameter("15-1-0000.iam.Length_1") > 180 in Then
	ActiveSheet.View("VIEW69").View.Suppressed = False
	ActiveSheet.View("VIEW70").View.Suppressed = False
	ActiveSheet.View("VIEW72").View.Suppressed = False
	ActiveSheet.View("VIEW73").View.Suppressed = False

End If

 

Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
0 Likes
Message 8 of 9

bretrick30
Advocate
Advocate
Accepted solution

Well, there are a few ways to do this.  I was trying to decide which way would be best.  This one is simplest I think.  

 

SyntaxEditor Code Snippet

oDoc = ThisDoc.Document
Dim oSheet As Sheet
Dim oView As DrawingView

Select Case Parameter("15-1-0000.iam.Length_1")
    Case <= 60
        For Each oSheet In oDoc.Sheets            
            For Each oView In oSheet.DrawingViews        
                Select Case oView.Name
                    Case "VIEW69"
                        oView.Suppressed = True
                    Case "VIEW70"
                        oView.Suppressed = True
                    Case "VIEW72"
                        oView.Suppressed = True
                    Case "VIEW73"
                        oView.Suppressed = True
                End Select
            Next
        Next
    Case <= 120
        For Each oSheet In oDoc.Sheets
            For Each oView In oSheet.DrawingViews        
                Select Case oView.Name
                    Case "VIEW69"
                        oView.Suppressed = False
                    Case "VIEW70"
                        oView.Suppressed = False
                    Case "VIEW72"
                        oView.Suppressed = True
                    Case "VIEW73"
                        oView.Suppressed = True
                End Select
            Next
        Next
    Case <= 180
        For Each oSheet In oDoc.Sheets
            For Each oView In oSheet.DrawingViews        
                Select Case oView.Name
                    Case "VIEW69"
                        oView.Suppressed = True
                    Case "VIEW70"
                        oView.Suppressed = True
                    Case "VIEW72"
                        oView.Suppressed = False
                    Case "VIEW73"
                        oView.Suppressed = False
                End Select
            Next
        Next
    Case > 180
        For Each oSheet In oDoc.Sheets
            For Each oView In oSheet.DrawingViews        
                Select Case oView.Name
                    Case "VIEW69"
                        oView.Suppressed = False
                    Case "VIEW70"
                        oView.Suppressed = False
                    Case "VIEW72"
                        oView.Suppressed = False
                    Case "VIEW73"
                        oView.Suppressed = False
                End Select
            Next
        Next
End Select
Message 9 of 9

ASchlaack
Collaborator
Collaborator

Awesome!! Thank you so much for all of your help!

Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
0 Likes