05-29-2020
05:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
05-29-2020
05:17 AM
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 ![]()
EDIT: I forgot to add your UpperCase improvement. Don't forget to add it to the code again ![]()
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website