Suppress members of a pattern

Suppress members of a pattern

Anonymous
Not applicable
791 Views
13 Replies
Message 1 of 14

Suppress members of a pattern

Anonymous
Not applicable

I have a situation where I suppress all members of a pattern if  the Length of assembly is less than a certain number.  This works fine.  However, when I no longer need the items suppressed,  only the first member is un-suppressed.  The number of occurrences changes, but I would like un-suppress all of them.

 

Else If Length>=18 And Length < 24 Then
Component.IsActive("ReturnSpanner")=False

Else If Length >= 24 Then
Component.IsActive("ReturnSpanner")=True

 

When changing back from short assembly to long, only the first occurrence is un-suppressed

 

Suppress.PNG

 

 

 

 

 

792 Views
13 Replies
Replies (13)
Message 2 of 14

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @Anonymous,

 

In the mentioned assembly, "S-1101-110 xxx: 3" and "S-1101-110 xxx:4" might be dependent on "ReturnSpanner" by mate relation. Because of this, on suppressing "ReturnSpanner", "S-1101-110 xxx:3" and "S-1101-110 xxx:4" will be suppressed.

 

But on unsuppressing "ReturnSpanner", "S-1101-110 xxx:3" and "S-1101-110 xxx:4" will not be unsuppressed. Due to reason that, "ReturnSpanner" is independent of both parts.

 

Alternatively, members of pattern can be suppressed by the following iLogic code.

 

Sub Main()

    Dim oAssy As AssemblyDocument
    oAssy = ThisApplication.ActiveDocument

    Dim oDef As AssemblyComponentDefinition
    oDef = oAssy.ComponentDefinition
	
	Else If Length>=18 And Length < 24 Then
		Suppress_Pattern_Elements(oDef, "ReturnSpanners", False)

	Else If Length >= 24 Then
		Suppress_Pattern_Elements(oDef, "ReturnSpanners", True)    

End Sub

Sub Suppress_Pattern_Elements(ByVal oDef As AssemblyComponentDefinition, ByVal patternName As String, ByVal beSuppressed As Boolean)

    Dim oPattern As RectangularOccurrencePattern
    oPattern = oDef.OccurrencePatterns.Item(patternName)

    For Each oElement As OccurrencePatternElement In oPattern.OccurrencePatternElements
        For Each oComp As ComponentOccurrence In oElement.Occurrences
            If beSuppressed = True Then
                Call oComp.Suppress()
            ElseIf beSuppressed = False Then
                Call oComp.Unsuppress()
            End If
        Next
    Next

End Sub

Please feel free to contact if there is any doubt.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 14

Anonymous
Not applicable

hello Chandra sir

 

 

I need your help i am beginner for auto desk inventor customization.

So please help me sir ,can you send your personal mail id please sir.

 

Thank you
Reagrds
Naveen

 

 

 

Message 4 of 14

Anonymous
Not applicable

hello Chandra sir

 

Sir i am waiting for your positive response.

Message 5 of 14

Anonymous
Not applicable

What questions do you have pertaining to i-Logic?

0 Likes
Message 6 of 14

Anonymous
Not applicable

One thing I have done is instead of eliminating/ Suppressing the Items in your pattern, why not change the Qty of the pattern components to "1" as a starting point then simply increase whenever necessary.  For instance, when I wanted that pattern not only to reduce qty but also be suppressed completely the easiest way I found is to first change the QTY to "1" then suppress the pattern.  This works beautiful in all scenarios I have tried so far.  Sadly I never thought of it until I was trying to make the Code but you can never anticipate all Qty for all situations on complex things so this comes in so handy when you have no clue how many you could need to write code for.  It simply takes away that need for copious amounts of code.  Then you create rules to justify your qty increases as needed, never decrease, only increase from the base qty. of "1".

 

Simple "If Then" code would work just as shown by the others.

 

Let me know if you need me to explain more or demonstrate.  Good luck.

 

Please feel free to contact if there is any doubt.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,

Message 7 of 14

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @Anonymous,

 

Your suggestions is also nice.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 8 of 14

Anonymous
Not applicable

@chandra.shekar.g Definitely appreciated yours as well.  Sometimes, when you have defined quantity your approach is as feasible as any.  But sometimes it is just easier to start from 1 and build up that way no need to write any code for instances.  I simply have form to increase qty manually but could also write code for it if there are defining parameters to utilize.  

0 Likes
Message 9 of 14

Anonymous
Not applicable
Did you get it figure out?
0 Likes
Message 10 of 14

Anonymous
Not applicable

Hi ron.king6

 

 

Good morning

 

Regarding my post, in attached image having part A &  part B  one assembly file.
Part B having two holes but unfortunately designer miss the hole feature in Part A to assemble the two parts.

 

 

please tell me the logic code to detect or show the error message if mate part not having the hole feature & please find the attached images.

 

 

 

Thanks,

Naveen

0 Likes
Message 11 of 14

JaneFan
Autodesk
Autodesk

Hi @Anonymous,

 

Hope following code snippets can give you some clue:

 

SyntaxEditor Code Snippet

Sub Main()
	Dim oAssyDoc As AssemblyDocument 
	oAssyDoc = ThisDoc.Document 
	
	Dim oOcc As ComponentOccurrence 
	For Each oOcc In oAssyDoc.ComponentDefinition.Occurrences 
		MessageBox.Show("Hole Count of component " & oOcc.name & " is: " & HoleFeatCount(oOcc.definition.document))
		If HoleFeatCount(oOcc.definition.document) = 0 Then 
			MessageBox.Show("Part " & oOcc.name & " has No Hole Feature", "Error")
		End If 
	Next
End Sub

Function HoleFeatCount(oDoc As PartDocument) As Integer  
	HoleFeatCount = 0

	Dim oHole As HoleFeature 
	For Each oHole In oDoc.ComponentDefinition.Features.HoleFeatures
	    If oHole.Suppressed = False Then 
	    	HoleFeatCount = HoleFeatCount + 1
	    End If 
	Next 
End Function

 




Jane Fan
Inventor/Fusion QA Engineer
Message 12 of 14

Anonymous
Not applicable

Wow that is fancy!  I would approach it much simpler ways but it is a good way to do it if you know how to expand on this logic, which is probably impossible for a beginner.

0 Likes
Message 13 of 14

Anonymous
Not applicable

Hello Experts

Please modify the above code as per my requirement.

In our assembly heaving 10 to 15 parts in single assembly file

1) user will open the Assembly file 

2) run the macro

3) user will select two parts in assembly

4) macro will count the holes in mate area(highlighted in red co lour) explained in below image.1.JPG

I need Macro will consider holes present in mate area & count the holes .

 

Thank you
Reagrds
Naveen

 

 

0 Likes
Message 14 of 14

Anonymous
Not applicable

Have you ever thought about making a skeleton model of this and configuring the changes in the Assembly that way?  Using forms and Rules to change the features of the parts instead of replacing them, I believe this would simplify things for you.

0 Likes