Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Suppress/Unsuppress Rule?

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
DeerSpotter
1386 Views, 8 Replies

Suppress/Unsuppress Rule?

I see everywhere that there is a Suppress Features Rule, but cannot find any suppress parts rules?

 

This is my dilemma here:

 

I want to be able to create a rule that when a .iam is opened; I can select in a list box

 

ex.

 

part1

part2

part3

 

When i select one of those, the rule will suppress everything else.

 

Image and video hosting by TinyPic
..........................................................................................................................
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
..........................................................................................................................


See My LinkedIn Profile
8 REPLIES 8
Message 2 of 9
mcgyvr
in reply to: DeerSpotter

What is the purpose of this functionality? I only as becase there might be a better way to accomplish your goal..

Maybe LOD..maybe design view rep..maybe iassemblies



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 3 of 9
mrattray
in reply to: DeerSpotter

I'm not sure what you're looking for. We need more information.
Mike (not Matt) Rattray

Message 4 of 9

Hi m.teleguz1,

 

You didn't mention iLogic, but from your use of the words "Rule"  and "List Box" I'm assuming you were looking for an iLogic solution.

 

You can use Component.IsActive(Name:1) = False to suppress in iLogic.  Here's a quick example that requires the user to select a component, and then it creates a LOD named after the selected component, and then it suppresses everything else.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

'get currently selected component
Dim oOccurrence as ComponentOccurrence
Try
  oOccurrence = ThisDoc.Document.SelectSet.Item(1)
Catch
  MessageBox.Show("Please select a component to replace before running this rule.", "iLogic")
  Return
End Try

'- - - - - - - - - - - - - - - - - - - - - - - - -
'Format selected occurence name for LOD name
'remove the colon from the occurence and replaces with underscore
Dim fixedText As String = Replace(oOccurrence.Name, ":", "_")

'- - - - - - - - - - - - - - - - - - - - - - - - -
'setup LOD
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAsmDoc.ComponentDefinition

'activate the Master LOD so we can read in the names of all the components
oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations("Master").Activate
InventorVb.DocumentUpdate(False)

'define an arraylist to hold the list of  LOD rep names
Dim NameList As New ArrayList()

'define LOD rep
Dim oLODRep As LevelOfDetailRepresentation

'Look at the LOD reps in the assembly
For Each oLODRep In oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations
'set the list of names to the array list
NameList.add(oLODRep.Name)
Next

'check for an iLogic LOD rep and create it if not found
If Not NameList.Contains(fixedText  & " LOD") Then
    'create iLogic LOD
    oLODRep = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Add(fixedText  & " LOD")
    oLODRep.Activate
Else
oLODRep.Activate
End If

'- - - - - - - - - - - - - - - - - - - - - - - - -
'suppress components
For Each oOcc In oAsmCompDef.Occurrences
    'check for and skip virtual components
    '(in case a virtual component trips things up)
    If Not TypeOf oOcc.Definition Is VirtualComponentDefinition Then
        'Suppress all other components except the one that was selected
        If oOcc.Name <> oOccurrence.Name Then
        Component.IsActive(oOcc.Name) = False
        Else
        End If
    Else
    End If    
Next

'zoom all
ThisApplication.ActiveView.Fit

 

Message 5 of 9
DeerSpotter
in reply to: mrattray

I have a lot of these Parker Fittings that i need to put into Content Center. 

 

Instead of publishing these fittings up individiually I am putting them all in one assembly. Making a little mini Content Center 🙂

Based on the information picked it will activate one fitting and supress all the rest and then shoot the .ipt properties to the assembly so we can still use it in the BOM. 

 

I havent figured out how to pass that info yet 😕

 

Thanks Curtis! 

Image and video hosting by TinyPic
..........................................................................................................................
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
..........................................................................................................................


See My LinkedIn Profile
Message 6 of 9

this right here would be enough in my world. But is it possible for list box? 

Image and video hosting by TinyPic
..........................................................................................................................
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
..........................................................................................................................


See My LinkedIn Profile
Message 7 of 9

why wouldnt this work? 

oOccurrence = ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager.LevelofDetailRepresentations("DetailOFRepresentation").Activate
Image and video hosting by TinyPic
..........................................................................................................................
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
..........................................................................................................................


See My LinkedIn Profile
Message 8 of 9

Hi m.teleguz1,

 

Here is a version with a list box.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Imports System.Diagnostics
Imports System.Collections.Generic

Sub Main
StartRule:
  Dim partsList As Dictionary(Of String, Document) = AllPartsList()
  For Each name As String In partsList.Keys
  Next
  If (partsList.Count = 0) Then Return
  Dim partNames as New List(Of String)(partsList.Keys)
  
'present list box
  Dim partNameSelected As String = InputListBox("Select a component.", partNames, partNames(0), "Select Component",  "Components")
  If String.IsNullOrEmpty(partNameSelected) Then Return
'get document from selected name
  Dim partSelected As Document = partsList(partNameSelected)
  Dim oPartDoc As Inventor.PartDocument = partSelected
  
'- - - - - - - - - - - - - - - - - - - - - - - - -
'Format selected component name for LOD name 
'remove the colon from the name and replace with underscore
Dim fixedText As String = Replace(partNameSelected, ":", "_")

'- - - - - - - - - - - - - - - - - - - - - - - - -
'setup LOD 
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAsmDoc.ComponentDefinition

'activate the Master LOD so we can read in the names of all the components
oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations("Master").Activate
InventorVb.DocumentUpdate(False)

'define an arraylist to hold the list of  LOD rep names
Dim NameList As New ArrayList()

'define LOD rep 
Dim oLODRep As LevelOfDetailRepresentation

'Look at the LOD reps in the assembly
For Each oLODRep In oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations
'set the list of names to the array list
NameList.add(oLODRep.Name)
Next

'check for an iLogic LOD rep and create it if not found
If Not NameList.Contains(fixedText & " LOD") Then
    'create iLogic LOD 
    oLODRep = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Add(fixedText & " LOD") 
    oLODRep.Activate
Else 
oLODRep.Activate
End If

'- - - - - - - - - - - - - - - - - - - - - - - - -
'suppress components
For Each oOcc In oAsmCompDef.Occurrences
    'check for and skip virtual components
    '(in case a virtual component trips things up)
    If Not TypeOf oOcc.Definition Is VirtualComponentDefinition Then
        'Suppress all other components except the one that was selected
        If oOcc.Name <> partNameSelected Then
        Component.IsActive(oOcc.Name) = False
        Else 
        End If
    Else
    End If    
Next

'zoom all
ThisApplication.ActiveView.Fit
  End Sub

'- - - - - - - - - - - - - - - - - - - - - - - - -
'set up component list
Function AllPartsList() As Dictionary(Of String, Document)
	Dim oAsmDoc As AssemblyDocument
	oAsmDoc = ThisApplication.ActiveDocument
	Dim oAsmCompDef As AssemblyComponentDefinition
	oAsmCompDef = oAsmDoc.ComponentDefinition
  	Dim partsList As New Dictionary(Of String, Document)
  	For Each oOcc In oAsmCompDef.Occurrences
    	'check for and skip virtual components
    	'(in case a virtual component trips things up)
   	If Not TypeOf oOcc.Definition Is VirtualComponentDefinition Then
    	Dim partName As String = oOcc.Name 
	partsList(partName) = doc
    	Else
    	End If    
	Next
  	Return partsList
End Function  

 

Message 9 of 9

This works great, but it does take forever to do it. The one from before was a lot faster. This code goes through and it looks like it runs for each part in the list. But thank you! 

Image and video hosting by TinyPic
..........................................................................................................................
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
..........................................................................................................................


See My LinkedIn Profile

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report