Weird error, issue with updating iProperties

Weird error, issue with updating iProperties

Preston_Reed
Advocate Advocate
411 Views
1 Reply
Message 1 of 2

Weird error, issue with updating iProperties

Preston_Reed
Advocate
Advocate

Hello, so i have been using a snippet of code to replace designer name, project & date based off of form entry on multiple configurators for a while.  But today i cant get it to work on this particular sub assembly.  The issue has to do with which ever part is first in the tree.  If the first item is suppressed, no matter which part, it will run no issue, if the first part isnt suppressed it errors out...  Any help would be appreciated, thank you

 

It errors out on line iProperties.Value(oOccurrence.Name, "Project", "Project") = _

 

 

'Goes through all parts & subassemblies and replaces the Project based on form inputs
Sub iPropPartsProject
	
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'Iterate through all Of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef)  
	
		'create iprop with default Value
		iProperties.Value("Project", "Project") = Project
		'write to component iprops
		iProperties.Value(oOccurrence.Name, "Project", "Project") = _
		iProperties.Value("Project", "Project")
		
	On Error Resume Next
Next

End Sub

 

inventor help 1-11.gif

0 Likes
412 Views
1 Reply
Reply (1)
Message 2 of 2

A.Acheson
Mentor
Mentor

Try it with a Try Catch Statement. You can also put a logger in the catch to see which iproperties are not changed. 

 

'Goes through all parts & subassemblies and replaces the Project based on form inputs
Sub iPropPartsProject
	
	Dim oAsmCompDef As AssemblyComponentDefinition
	oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
	
	'create iprop with default Value in Main Assembly
	iProperties.Value("Project", "Project") = Project
	
	'Iterate through all Of the occurrences
	Dim oOccurrence As ComponentOccurrence
	For Each oOccurrence In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef)  
		
		Try
			'write to component iprops
			iProperties.Value(oOccurrence.Name, "Project", "Project") = iProperties.Value("Project", "Project")
		Catch
			Logger.Info("Failed to Set iproperty in : " & oOccurrence.Name)
		End Try
			
	Next

End Sub

and you can avoid content center parts with this

	If oOccurrence.Definition.Document.IsModifiable Then
			'Do Something as document is writable
		End If

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes