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: 

Sheet Supression based on text

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
staszakg
584 Views, 4 Replies

Sheet Supression based on text

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

Inventor Pro 2019 - 64 Bit
Vault Pro 2019
Intel Xenon CPU-E5-1650v3 @ 3.50 GHz
NVIDIA Quadro K2200
Windows 7 Pro (SP1)
Labels (1)
4 REPLIES 4
Message 2 of 5
FINET_Laurent
in reply to: staszakg

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"

@LinkedIn     @JohnCockerill

Message 3 of 5
bhavik4244
in reply to: staszakg

 

@staszakg 

 

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

LinkedIn 

 

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

 


Bhavik Suthar
Message 4 of 5
WCrihfield
in reply to: staszakg

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

EESignature

(Not an Autodesk Employee)

Message 5 of 5
staszakg
in reply to: staszakg

Thank you all for your help. It works perfectly.

Inventor Pro 2019 - 64 Bit
Vault Pro 2019
Intel Xenon CPU-E5-1650v3 @ 3.50 GHz
NVIDIA Quadro K2200
Windows 7 Pro (SP1)

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report