ilogic Component is active - pattern

ilogic Component is active - pattern

michealweather
Enthusiast Enthusiast
1,776 Views
9 Replies
Message 1 of 10

ilogic Component is active - pattern

michealweather
Enthusiast
Enthusiast

Hi, 

 

I have an assembly with various parts. I'm using ilogic to suppress specific components depending on my chosen product. I'm using Forms to choose between products. I have used the component pattern to pattern the part; however, when I use the "component is active" feature in the code, it comes up as an error? Any Ideas why? Zip files are attached.

 

I want the code to make the pattern component when I pick "PPC104", and then make the part & pattern suppressed when I choose another product. 

 

I'm using inventor version 2023

 

 

 

michealweather_0-1658300908610.png

michealweather_1-1658301019912.png

 

 

0 Likes
Accepted solutions (1)
1,777 Views
9 Replies
Replies (9)
Message 2 of 10

WCrihfield
Mentor
Mentor
Accepted solution

Hi @michealweather.  There is actually a different iLogic snippet for working with component patterns than there is for working with single components, when it comes to the 'IsActive()' function.  The keyword for that other snippet is "Patterns" (without the quotes).

Here is an example of using this other snippet to control a component pattern:

'Suppressed is a ReadOnly property of the pattern, so you can't directly change that
'the Suppress & Unsuppress are 'methods / Sub routines'
'using IsActive = True is the same as using Unsuppress
'using IsActive = False is the same as using Suppress

'to Suppress a component pattern, you can use this:
If Patterns.Item("MyPattern1:1").Pattern.Suppressed = False Then
	Patterns.Item("MyPattern1:1").Pattern.Suppress
End If
'or to Un-Suppress a component pattern, you can use this:
If Patterns.Item("MyPattern1:1").Pattern.Suppressed = True Then
	Patterns.Item("MyPattern1:1").Pattern.Unsuppress
End If

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS :bulb: or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 10

parth_moradiya
Contributor
Contributor

Hi,

What if I want to supress/Unsuppress Component Pattern 1:1's Element:1 and so on. 

Thanks

0 Likes
Message 4 of 10

WCrihfield
Mentor
Mentor

Hi @parth_moradiya.  I think the same iLogic snippet tool can also be used for that, by taking it a little further.  However, we usually can not suppress the 'first' element in a any pattern, because that element is usually the 'input' element that all the other elements in that pattern are a copy of.  We can usually suppress other elements in a pattern, but not the first one.  And if the element is the input to a dependent pattern, then suppressing it may also suppress the pattern that is dependent on it.

Here is an example iLogic code using that snippet to suppress one element in a pattern.

Patterns.Item("Component Pattern 1:1").Element("Element:2").Suppressed = True

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 10

parth_moradiya
Contributor
Contributor

Hi,

thank you very much. it is working fine.

 

is there any way  for Element 1 to suppress/unsuppress?

0 Likes
Message 6 of 10

parth_moradiya
Contributor
Contributor

And also I just want to know is there any way to supress/unsupress the folders in assembly model browser as shown in pic named 2Locks and 3Locks. thanks.

0 Likes
Message 7 of 10

WCrihfield
Mentor
Mentor

Hi @parth_moradiya.  As I said before, we can not suppress the first element in a pattern.  However, we can do something similar, such as suppress the assembly component that is within that element, or turn the visibility of that assembly component within that element off.  I have done something like that before.

Here is a similar example line of code to suppress just the first assembly component from within the first element in an assembly component pattern.

Patterns.Item("MY PATTERN").Element("Element:1").Occurrences.Item(1).Suppress

...and here is another similar example line of code to only turn its visibility off, instead of suppress it.

Patterns.Item("Z-POST PATTERN").Element("Element:1").Occurrences.Item(1).Visible = False

Suppressing an entire browser folder full of stuff is a whole other different, complicated matter.  Whether or not we can suppress all the contents of that folder may depend on what all is in that folder.  This task would likely need to include obtaining a reference to the main BrowserNodes collection for the Document, then getting the 'Model' one, then its top node, then finding that one specific BrowserFolder amongst all its top level nodes.  Then selecting it by code.  Then finding the ControlDefinition for suppressing multiple items in an assembly, then execute that command.  It can be done, and there are examples like that here on this forum that can be found with some searching.  I have likely been involved in a few discussions in the area of navigating the model browser tree, and bundling assembly components into browser folders, but I do not have an already existing example code to share for suppressing a folder.  Below is a link to one such forum response, but that example may look a bit more complicated than what you had in mind, and could likely be simplified quite a bit for your needs.

https://forums.autodesk.com/t5/inventor-programming-ilogic/read-browser-folder-name-if-re-then-suppr... 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 8 of 10

WCrihfield
Mentor
Mentor

@parth_moradiya 

Here is another, simpler example you can play around with.  It may show a warning dialog though, depending on your settings.

Sub Main
	Dim oDoc As Inventor.Document = ThisDoc.Document
	Dim oSS As Inventor.SelectSet = oDoc.SelectSet
	Dim oCDs As ControlDefinitions = ThisApplication.CommandManager.ControlDefinitions
	Dim oCD As ControlDefinition = oCDs.Item("AssemblyCompSuppressionCtxCmd")
	Dim oPane As Inventor.BrowserPane = GetModelBrowserPane(oDoc)
	Dim oTopFolders As BrowserFoldersEnumerator = oPane.TopNode.BrowserFolders
	For Each oBFolder As Inventor.BrowserFolder In oTopFolders
		If oBFolder.Name = "2Lock" Then
			oSS.Clear
			oSS.Select(oBFolder)
			oCD.Execute2(False)
		End If
	Next oBFolder
End Sub

Function GetModelBrowserPane(oDoc As Inventor.Document) As Inventor.BrowserPane
	For Each oPane As Inventor.BrowserPane In oDoc.BrowserPanes
		If oPane.BuiltIn And oPane.TreeBrowser And _
		(oPane.InternalName = "AmBrowserArrangement" Or _
		oPane.InternalName = "DlHierarchy" Or _
		oPane.InternalName = "PmDefault") Then Return oPane
	Next
	Return Nothing
End Function

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 9 of 10

parth_moradiya
Contributor
Contributor

Hi, It is working fine. Thanks

0 Likes
Message 10 of 10

parth_moradiya
Contributor
Contributor
 

Patterns.Item("MY PATTERN").Element("Element:1").Occurrences.Item(1).Suppress

By using this code I am able to supress the element components but constraints are still there. is there any way to suppress the associated constraints as well with the components? Thanks

0 Likes