Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
JhoelForshav
in reply to: amarcoc

Hi @amarcoc 

Regarding saving the state:

I thought I'd use the features attributes to store a simple boolean value in it for it's suppressed state.

For some reason though I couldn't create an attribute with boolean value, so i had to make it a string. I don't know why because I think it should work with ValueTypeEnum.kBooleanType.

 

Anyways,

this rule stores a string "True"/"False" as an attribute in the feature:

For Each oFeature As PartFeature In ThisDoc.Document.ComponentDefinition.Features
	If oFeature.Name.Contains("DXF") = False Then
		Dim oAttributeSet As AttributeSet
		Dim oAttribute As Inventor.Attribute
		If oFeature.AttributeSets.NameIsUsed("SuppressedInfo")
			oAttributeSet = oFeature.AttributeSets.Item("SuppressedInfo")
			Try
				oAttribute = oAttributeSet.Item("Suppressed")
				oAttribute.Value = If (oFeature.Suppressed, "True", "False")
			Catch
				If oAttributeSet Is Nothing Then MsgBox("hejhejhej")
				oAttribute = oAttributeSet.Add("Suppressed", ValueTypeEnum.kStringType, If (oFeature.Suppressed, "True", "False"))
			End Try
		Else
			oAttributeSet = oFeature.AttributeSets.Add("SuppressedInfo")
			oAttribute = oAttributeSet.Add("Suppressed", ValueTypeEnum.kStringType, If (oFeature.Suppressed, "True", "False"))
		End If
		oFeature.Suppressed = True
	End If
Next

Then to restore the features use this rule:

For Each oFeature As PartFeature In ThisDoc.Document.ComponentDefinition.Features
	If oFeature.AttributeSets.NameIsUsed("SuppressedInfo")
		Try
			Dim oSuppressed As String = oFeature.AttributeSets.Item("SuppressedInfo").Item("Suppressed").Value
			oFeature.Suppressed = If (oSuppressed = "True", True, False)
		Catch
		End Try
	End If
Next

Hope it helps :slightly_smiling_face:

 

EDIT: I forgot to add your UpperCase improvement. Don't forget to add it to the code again :winking_face: