To start, I am pretty new to iLogic. I am trying to create a iLogic rule that will suppress sheet 8 when the part number contains an "H". I want the sheet suppressed so I need to exclude both from printing & counting.
The "H" code is for an additional drill operation. If the part number does not contain the "H" I do not need the drawing sheet to be part of the package. The Part No is found in the iProperties Custom tab as shown
This is what I have but it returns "Line 1: End of statement expected."
If iProperties.Value("Custom", "PART NO") Contains("H") Then ThisDrawing.Sheet("Sheet:8").Sheet.ExcludeFromPrinting = True ThisDrawing.Sheet("Sheet:8").Sheet.ExcludeFromCount = True End If
I saw another post that requested Sheet Suppression be added to Inventor as an option. It looks like it died due to a lack of votes.
Thanks in advance
Solved! Go to Solution.
Solved by staszakg. Go to Solution.
Solved by WCrihfield. Go to Solution.
Solved by FINET_Laurent. Go to Solution.
Morning,
Maybe this does the job?
Dim oPartName As String = iProperties.Value("Custom", "PART NO") If oPartName.Contains("H") Then ThisDrawing.Sheet("Sheet:8").Sheet.ExcludeFromPrinting = True ThisDrawing.Sheet("Sheet:8").Sheet.ExcludeFromCount = True Else ThisDrawing.Sheet("Sheet:8").Sheet.ExcludeFromPrinting = False ThisDrawing.Sheet("Sheet:8").Sheet.ExcludeFromCount = False End If
Regards,
FINET L.
If this post solved your question, please kindly mark it as "Solution"
If this post helped out in any way to solve your question, please drop a "Like"
You may try the below code. Since it's accessing the file name itself so you don't have to care for iProperties of each part!
If it solves your purpose then please accept it as a solution.
Regards,
Bhavik
Dim oDrawingDoc As DrawingDocument oDrawingDoc = ThisApplication.ActiveDocument Dim oSheets As Sheets oSheets = oDrawingDoc.Sheets Dim oViews As DrawingViews Dim oView As DrawingView Dim oSheet As Sheet For Each oSheet In oSheets oViews = oSheet.DrawingViews For Each oView In oViews Dim oModelDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument Dim oViewModelName As String = oModelDoc.DisplayName.ToString If oViewModelName.Contains("H") Then oSheet.ExcludeFromPrinting = True oSheet.ExcludeFromCount = True Else oSheet.ExcludeFromPrinting = False oSheet.ExcludeFromCount = False End If Next Next
In your original post, the (iProperties.Value("Custom", "PART NO")) is understood as an Object, instead of a string, so you just needed to convert it to a string by either adding ".ToString" a the end of it or by enclosing it within the CStr() method. Then you were missing the "." just before the Contains() method. Although my code doesn't do anything differently than @FINET_Laurent 's code, it shows you two possible options for using the iProperty.Value() directly, as you were trying to do in your original code. And it gets the sheet the natural way, instead of through the iManagedSheet route, and sets it to a variable, to help reduce code needed within the If...Then statement.
Just another couple of variations of how it can be done, for educational purposes.
Dim oS8 As Sheet = ThisDrawing.Document.Sheets.Item("Sheet:8")
If CStr(iProperties.Value("Custom", "PART NO")).Contains("H") Then
oS8.ExcludeFromPrinting = True
oS8.ExcludeFromCount = True
Else
oS8.ExcludeFromPrinting = False
oS8.ExcludeFromCount = False
End If
or
Dim oS8 As Sheet = ThisDrawing.Document.Sheets.Item("Sheet:8")
If iProperties.Value("Custom", "PART NO").ToString.Contains("H") Then
oS8.ExcludeFromPrinting = True
oS8.ExcludeFromCount = True
Else
oS8.ExcludeFromPrinting = False
oS8.ExcludeFromCount = False
End If
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.
Wesley Crihfield
(Not an Autodesk Employee)
Thank you all for your help. It works perfectly.
Can't find what you're looking for? Ask the community or share your knowledge.