Supress folders & sub assembly folders named Reference - not declared warning

Supress folders & sub assembly folders named Reference - not declared warning

andrew_canfield
Collaborator Collaborator
503 Views
5 Replies
Message 1 of 6

Supress folders & sub assembly folders named Reference - not declared warning

andrew_canfield
Collaborator
Collaborator

Hello

 

I've found this which will suppress top level folders:

 

https://adndevblog.typepad.com/manufacturing/2015/05/suppress-folder-in-assembly.html 

 

then this to iterate an assembly:

 

https://modthemachine.typepad.com/my_weblog/assemblies/page/2/ 

 

I  copied this into Visual Studio to clear warnings (think it was VBA)

iterate 1.JPG

 but see this in iLogic:

 

iterate 2.JPG

 

 

the next step would be to run ilogic rule 1 when the iterate finds an assembly? 

 

The aim is to supress an entire tree of folders & sub assembly folders named 'Reference' - may there's another way?

 

Regards

 

Andrew

0 Likes
Accepted solutions (1)
504 Views
5 Replies
Replies (5)
Message 2 of 6

JamieVJohnson2
Collaborator
Collaborator

You have Sub Main, and then TraverseAssemblySample, you took the code of TraverseAssemblySample (including its title) and put it within Sub Main, causing a situation where you have 2 definitions and only 1 ending.  Simply fix by deleting the line TraversAssemblySample.

 

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes
Message 3 of 6

andrew_canfield
Collaborator
Collaborator

I should of used different terminology..

this fixes the problem

 

https://forums.autodesk.com/t5/inventor-customization/ilogic-to-control-lod-in-sub-assemblies/td-p/6...

 

 

0 Likes
Message 4 of 6

andrew_canfield
Collaborator
Collaborator

I'm trying to merge two rules

Set the LOD on each level

Suppress a folder

 

Both work  but i'd like to suppress the folder on each level:

Folder named 'Reference' is supressed:

 

Sub Main()
  Dim oDoc As AssemblyDocument
  oDoc = ThisApplication.ActiveDocument
    
  Dim oPane As BrowserPane
  oPane = oDoc.BrowserPanes("Model")
  
  Dim oTopNode As BrowserNode
  oTopNode = oPane.TopNode
    
  Dim oFolder As BrowserFolder
  oFolder = oTopNode.BrowserFolders.Item("Reference")
  
  Call SuppressFolder(oFolder)
End Sub

' Recursive function as there could be subfolders too
Sub SuppressFolder(oFolder As BrowserFolder)
  Dim oItem As BrowserNode
  For Each oItem In oFolder.BrowserNode.BrowserNodes
    Dim oObj As Object
    oObj = oItem.NativeObject
    
    If TypeOf oObj Is BrowserFolder Then
      Call SuppressFolder(oObj)
    ElseIf TypeOf oObj Is ComponentOccurrence Then
      Dim oOcc As ComponentOccurrence
      oOcc = oObj
      
      If Not oOcc.Suppressed Then Call oOcc.Suppress
    ElseIf TypeOf oObj Is OccurrencePattern Then
      Dim oPatt As OccurrencePattern
      oPatt = oObj
      
      Dim oElem As OccurrencePatternElement
      For Each oElem In oPatt.OccurrencePatternElements
        For Each oOcc In oElem.Occurrences
          If Not oOcc.Suppressed Then Call oOcc.Suppress
        Next
      Next
    End If
  Next
End Sub

all levels are set to 'Simple without ref'

Sub Main()

    Dim oDoc As Document
    oDoc = ThisDoc.Document
    
    Dim oAssyDoc As AssemblyDocument
    oAssyDoc = TryCast(oDoc, AssemblyDocument)
    
    If oAssyDoc Is Nothing Then
        MessageBox.Show("Document not of Assembly Type")
        Exit Sub
    End If
    Try
		oAssyDoc.ComponentDefinition.RepresentationsManager.LevelofDetailRepresentations("Simple without REF").Activate
	Catch
		MessageBox.Show("Unable to find 'Simple without REF' LOD on " & oAssyDoc.DisplayName)
	End Try
	
	Dim oOccs As ComponentOccurrences
	oOccs = oAssyDoc.ComponentDefinition.Occurrences
	
	For Each oOcc As ComponentOccurrence In oOccs
		If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject
			'MessageBox.Show(oOcc.Name)
			iLogicVb.RunRule("Rule3")

			Try
				oOcc.SetLevelOfDetailRepresentation("Simple without REF")
			Catch
				MessageBox.Show("Unable to find 'Simple without REF' LOD on " & oOcc.Name)
			End Try
		End If
	Next
End Sub

Merging the two:

 

No errors but the folder isn't suppressed either.

 

Sub Main()

    Dim oDoc As Document
    oDoc = ThisDoc.Document
    
    Dim oAssyDoc As AssemblyDocument
    oAssyDoc = TryCast(oDoc, AssemblyDocument)
	
	  Dim oPane As BrowserPane
  oPane = oDoc.BrowserPanes("Model")
  
    Dim oTopNode As BrowserNode
  oTopNode = oPane.TopNode
  
    Dim oFolder As BrowserFolder
  oFolder = oTopNode.BrowserFolders.Item("Reference")  
  
    
    If oAssyDoc Is Nothing Then
        MessageBox.Show("Document not of Assembly Type")
        Exit Sub
    End If
    Try
		oAssyDoc.ComponentDefinition.RepresentationsManager.LevelofDetailRepresentations("Simple without REF").Activate
	Catch
		MessageBox.Show("Unable to find 'Simple without REF' LOD on " & oAssyDoc.DisplayName)
	End Try
	
	Dim oOccs As ComponentOccurrences
	oOccs = oAssyDoc.ComponentDefinition.Occurrences
	
	For Each oOcc As ComponentOccurrence In oOccs
		If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject
			'MessageBox.Show(oOcc.Name)
			

			Try
				oOcc.SetLevelOfDetailRepresentation("Simple without REF")
				Call SuppressFolder(oFolder)
			Catch
				MessageBox.Show("Unable to find 'Simple without REF' LOD on " & oOcc.Name)
			End Try
		End If
	Next
End Sub


' Recursive function as there could be subfolders too
Sub SuppressFolder(oFolder As BrowserFolder)
  'Dim oItem As BrowserNode
  
    
    'Dim oFolder As BrowserFolder
  'oFolder = oTopNode.BrowserFolders.Item("Reference")  
  
  For Each oItem In oFolder.BrowserNode.BrowserNodes
    Dim oObj As Object
    oObj = oItem.NativeObject
    
    If TypeOf oObj Is BrowserFolder Then
      Call SuppressFolder(oObj)
    ElseIf TypeOf oObj Is ComponentOccurrence Then
      Dim oOcc As ComponentOccurrence
      oOcc = oObj
      
      If Not oOcc.Suppressed Then Call oOcc.Suppress
    ElseIf TypeOf oObj Is OccurrencePattern Then
      Dim oPatt As OccurrencePattern
      oPatt = oObj
      
      Dim oElem As OccurrencePatternElement
      For Each oElem In oPatt.OccurrencePatternElements
        For Each oOcc In oElem.Occurrences
          If Not oOcc.Suppressed Then Call oOcc.Suppress
        Next
      Next
    End If
	
	MessageBox.Show("76", "Title")

  Next
End Sub

i'll keep trying.

 

Regards

 

Andrew

 

0 Likes
Message 5 of 6

andrew_canfield
Collaborator
Collaborator

saved the assembly & it appears to work - always happens after posting!

 

nope - spoke too soon

 

the lower lever folders will not supress the contents..

0 Likes