Simple iLogic rule not working? (feature suppession)

Simple iLogic rule not working? (feature suppession)

chris
Advisor Advisor
321 Views
3 Replies
Message 1 of 4

Simple iLogic rule not working? (feature suppession)

chris
Advisor
Advisor

Okay, I have an assembly that features an orientation parameter (LH/RH).

I also have a set of parts (4 columns), each of which contains welded tabs at 3 different locations along their height (Bottom, Middle, and Top)

When the Orientation is set to "LH" Columns 1&3, will have their Bottom, Middle, and Top tabs at locations (1&2) suppressed, whereas columns 2&4 will have their tabs (Bottom, Middle, and Top), at locations 1&4 suppressed... (see image)

Of course, when the Orientation is set to "RH" Columns 1&3 switch to tab locations 1&4 being suppressed, whereas Columns 2&4 switch to tab locations 1&4 being suppressed.

 

For some reason, my code is just not working.

 

Note: Each of the features in each of the columns is a separate solid body

chris_0-1693956861601.png

chris_1-1693956967151.png

 

 

0 Likes
322 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

Hi @chris.  I am not sure if what I am about to suggest may be the cause of your problems or not, but it often is when suppressing/un-suppressing a repeating list of things is involved.  If any one of those features depends on any of the other features, then they will need to be suppressed or un-suppressed in the correct order to avoid errors, and that order will most likely need to be reversed on the two sides (LR or RH).  What I mean is, you will likely need to suppress them in the opposite order that you un-suppress them.  What happens is, if you suppress a feature that some other feature depends on, it will throw an error before it gets to the line where it suppresses that other feature that depended on it...or the other way around.  If you un-suppress a feature that depends on another feature, but that other feature has not been un-suppressed yet, it will throw an error before it gets to the line where that other feature gets un-suppressed.  Just a possibility.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

william
Advocate
Advocate

@chris Further to what WCrihfield suggested. It should be faster to add the features to be suppressed/unsuppressed to a collection and suppress/unsupress the collection.
This should also help with the issues around feature dependencies when suppressing features one at a time. 

 

'https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/performance-issue-when-supressing-many-features-in-part-document/td-p/11853994
'https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/more-efficient-way-to-suppress-unsuppress-features/m-p/12127891#M155640
Sub Main
Dim oSupressFeatures As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim oUnsupressFeatures As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection

CreateFeatureCollection(oSupressFeatures, oUnsupressFeatures, "LH SEEN", "Suppressed")
CreateFeatureCollection(oSupressFeatures, oUnsupressFeatures, "RH SEEN", "Active")

SetFeatureState(oSupressFeatures, oUnsupressFeatures)

End Sub

Sub CreateFeatureCollection(oSupressFeatures As ObjectCollection, oUnsupressFeatures As ObjectCollection, Searchterm As String, State As String)
Dim oDoc As PartDocument = ThisDoc.Document
Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition

For Each oFeat As PartFeature In oCompDef.Features
	If oFeat.Name.Contains(Searchterm) Then
		If oFeat.Suppressed = True And State = "Active" Then
			oUnsupressFeatures.Add(oFeat)
		Else If oFeat.Suppressed = False And State = "Suppressed" Then
			oSupressFeatures.Add(oFeat)
		End If
	End If
Next


End Sub


Sub SetFeatureState(oSupressFeatures As ObjectCollection, oUnsupressFeatures As ObjectCollection)
Dim oDoc As PartDocument = ThisDoc.Document
Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition

Try
	oCompDef.SuppressFeatures(oSupressFeatures)
	oSupressFeatures.Clear
Catch
	Logger.Error("Error suppressing features")
End Try

Try
	oCompDef.UnsuppressFeatures(oUnsupressFeatures)
	oUnsupressFeatures.Clear
Catch
	Logger.Error("Error unsuppressing features")
End Try

End Sub

 

Message 4 of 4

chris
Advisor
Advisor

@william @WCrihfield  Okay  I took a break from this for a couple of days, got back into it after lunch, and noticed that one of the parameters in the master part I used to copy save as for the columns had the parameter spelled out "Left Hand" / "right Hand" instead of everything else being "LH" / "RH", updated the parameter name everything works perfectly now... It's little things like that, that ...LOL Thank you guys fro checking back on me!

0 Likes