is there a way to find all Browser notes that does not show the partnumber ?

is there a way to find all Browser notes that does not show the partnumber ?

Darkforce_the_ilogic_guy
Advisor Advisor
124 Views
6 Replies
Message 1 of 7

is there a way to find all Browser notes that does not show the partnumber ?

Darkforce_the_ilogic_guy
Advisor
Advisor

is there a way to find all Browser notes that does not show the part number ? we are more then 10 uses, that Create our model in a full version og inventor.  But We have one use that only have Access to an Read Only.. He need the browsernotes to Always show the current part number. But for some reason there is always some form time to time some that show the wrong number... I try a lot of ilogic code to try to fix this on save... but for some reason some still seens to happen. Is there a easy way to fix this .. So it 100 % of the time show the part number for our read only user ?

Darkforce_the_ilogic_guy_0-1758174867133.png

 

0 Likes
125 Views
6 Replies
Replies (6)
Message 2 of 7

marcin_otręba
Advisor
Advisor

check this ilogic to reset name to be equal to part number:

Dim ass As AssemblyDocument = ThisDoc.Document
For Each occ As ComponentOccurrence In ass.ComponentDefinition.Occurrences
	If Split(occ.Name, ":")(0) <> occ.Definition.Document.propertysets(3)("Part Number").value Then 
	occ.Name = ""
	If Split(occ.Name, ":")(0) <> occ.Definition.Document.propertysets(3)("Part Number").value Then 
	Dim doc As PartDocument = occ.Definition.Document
	doc.DisplayName = doc.propertysets(3)("Part Number").value
	occ.Name = ""
	End If 
	End If 
Next

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 3 of 7

WCrihfield
Mentor
Mentor

Why not just use the built-in Rename Browser Nodes tool for that?

We can put a copy of that tool button out in the 'User Commands' panel of the ribbon if we want to make it more convenient to use.

One of its options is to reset all component occurrence browser nodes to their Part Number.

WCrihfield_0-1758203881208.png

WCrihfield_1-1758204000371.png

WCrihfield_2-1758204012082.png

 

 

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 7

marcin_otręba
Advisor
Advisor

@WCrihfield you can imagine addin for saving and replacing occurrences in assembly for example wchich should check that names and correct it  do it after replacing part... you cant trust that end user will click that button.

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

Message 5 of 7

WCrihfield
Mentor
Mentor

Good point.  Just mentioning the simplest things first, before potentially the most complex ones.  Since he mentioned that he was already using iLogic tools to help solve this issue, but they were not working so far, I kind of wanted more details before suggesting more iLogic, but did not include the questions I had in mind, due to other distractions.  It would have been nice if the existing example code(s) he was using were posted here, maybe as attached text files, that way we could review them, instead of shooting in the dark.  Maybe the code he has is OK, but just not being ran often enough or when needed.  Or maybe his codes are throwing errors or skipping past errors that need to be dealt with instead of ignored.  Since there had not been any mention about them using 'design copy' or 'save & replace' strategies so far, so I did not want to assume anything quite yet, but just wanted more information to go on.

By the way, I think the block of code you posted could also potentially throw errors in certain situations.  For example, if any of the components were suppressed, then the third line of code would throw an error, because it can not access the definition of a suppressed component.  Also if any of the components represented ModelState members, it likely would not allow editing their document DisplayName property value...at least not until the factory document version was obtained/used, or similar counter measures for dealing with ModelStates.

Since the iLogic Event Triggers dialog only offers a limited set of events, and are not always the most efficient to use, a custom add-in may be the way to go here, as long as everyone on the team who has 'edit' rights had that add-in in place.  We do not really know yet what is going on which is causing the components to not be named as their part numbers, so determining which events to monitor and react to is still needed.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 7

marcin_otręba
Advisor
Advisor

sure, the code should be updated to have some error handling  using simplest on error resume next, try catch  or checking occurrence supression state, but i think he will manage to do it..

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 7 of 7

Darkforce_the_ilogic_guy
Advisor
Advisor

built-in Rename Browser Nodes ? well that easy people forget 😁 and the user that need it more then any other  only have a read only version of inventor.  I have try many ways to do this ...I din´t type in my post but I have a exceptions in my code...but my problem is that in at make it reset all the browsernote it will take too long .. if i try to make some form of check well all ways i have try so far seens to miss some of them for no good reason i can find ... I didt find some that help a lillte .. by making our read only user use he BOM function and save hen a few click to dobble check his work.  

 

My code run on save 🙂

'this my current code

'Reset Browsernote that dont show the partnummer
Sub Main()
	
	Dim doc = ThisApplication.ActiveDocument
	Dim sDocumentSubType As String = doc.SubType
	
	Try
		'debug("Start ilogic: RenameBrowsernoteAll")
		Logger.Info("Start ilogic: RenameBrowsernoteAll")
		
		oDoc = ThisDoc.Document
		Dim oPane As BrowserPane
		Dim oTopNode As BrowserNode
		
			If oDoc.DocumentType = kPartDocumentObject
				oPane = oDoc.BrowserPanes.Item("PmDefault")
			Else 'kAssemblyDocumentObject or 
					oPane = oDoc.BrowserPanes.Item("Model")
			End If
			
				oTopNode = oPane.TopNode
			
			If oTopNode.BrowserNodeDefinition.Label <> System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName) Then
				oDoc.DisplayName = "" 'System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName)
			End If 
	
	Catch
		debug("RenameBrowsernoteALL ilogic code fail for unknown reason")
	End Try
If sDocumentSubType = "{E60F81E1-49B3-11D0-93C3-7E0706000000}" Or sDocumentSubType = "{28EC8354-9024-440F-A8A2-0E0E55D635B0}" Then ' = "assembly"''

If(doc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value = iProperties.Value("Project", "Part Number")) Then

Assembly

Else 
	
	Logger.Info("This is not the Aktive Doc - End Code")
	
Exit Sub


End If

End If

'debug("End ilogic: RenameBrowsernoteAll")
Logger.Info("End ilogic: RenameBrowsernoteAll")

End Sub

Public Sub debug(txt As String)
        Trace.WriteLine("NTI : " & txt)
End Sub


Sub Assembly()
	Logger.Info("Change Browsernotes Assembly", filename)
	
	Dim oAsmDoc As AssemblyDocument
	oAsmDoc = ThisApplication.ActiveDocument

	If (ThisDoc.Document.DisplayName = oAsmDoc.DisplayName) Then
	
	
	Else
		Logger.Info("Don´t run - End Code", filename)

		Exit Sub
	End If
	

Dim oRefDocs As DocumentsEnumerator
oRefDocs = oAsmDoc.AllReferencedDocuments
Dim oRefDoc As Document
 
For Each oRefDoc In oRefDocs
	
	Try
	
	
	Catch
		
		
		Try
			
			If oRefDoc.DisplayName <> oRefDoc.PropertySets("Design Tracking Properties").Item("Part Number").Value Then
				
				Logger.Info("All need To be true " & (Left(oRefDoc.PropertySets("Design Tracking Properties").Item("Part Number").Value,9) <> "Zero Line").ToString & " " &  (Left(oRefDoc.PropertySets("Design Tracking Properties").Item("Part Number").Value,9) <> "Zero line").ToString & " " & (Left(oRefDoc.PropertySets("Design Tracking Properties").Item("Part Number").Value,15) <> "Control cabinet").ToString, filename)
	
					If Left(oRefDoc.DisplayName,9) <> "Zero Line" And Left(oRefDoc.DisplayName,9) <> "Zero line" And Left(oRefDoc.DisplayName,15) <> "Control cabinet"   Then
					oRefDoc.DisplayName = "" 
					End If
	
				
			End If 
		
		Catch
			
		End Try
	
	End Try

Next
Dim asm As AssemblyDocument = ThisDoc.Document
ResetOccurrenceNames(asm.ComponentDefinition.Occurrences)

End Sub

Sub ResetOccurrenceNames(occurrences As Object)
	
	Try
	For Each occ As ComponentOccurrence In occurrences
		Dim dispName = occ.ReferencedDocumentDescriptor.DisplayName
		
		'start
		Dim oPartDoc As Document
    oPartDoc = occ.Definition.Document
    Dim partNumber As String
    partNumber = iProperties.Value(oPartDoc, "Project", "Part Number")
		'end
		
		
		Dim length = Len(partNumber) -4
		
		If Not occ.Name.StartsWith(Left(dispName,length)) Then
		Logger.Info(occ.Name.StartsWith(Left(dispName,length)), "2")
If(Left(occ.Name, 9)) <> "Zero Line" And (Left(occ.Name, 9)) <> "Zero line" And (Left(occ.Name, 15)) <> "Control cabinet" Then
		occ.Name = ""
	End If 
		Logger.Info("Reset browsernote", filename)
		
		Else
			If Left(occ.Name.ToString, Len(dispName)) = dispName Then
			
			Else
			Logger.Info(occ.Name.StartsWith(Left(dispName,length)) & " 2" , "2")

			Logger.Info("Browser Note " & occ.Name, filename)
If (Left(occ.Name, 9)) <> "Zero Line" And (Left(occ.Name, 9)) <> "Zero line" And (Left(occ.Name, 15)) <> "Control cabinet" Then
			occ.Name = ""
			
		End If 
		
		End If
	End If 
		'ResetOccurrenceNames(occ.SubOccurrences)
	Next
	Catch
		Logger.Info("somthing fail "   , filename)

	End Try
End Sub

 

0 Likes