We currently convert more than 10,000 .sldprt file to .ipt. This is an old library of part from SW. All is done by Autodesk Inventor Task scheduler. But Now we need to manually override the Mass with the custom iproperty. Any tool to do this? Inventor BOM could be an usefull tool but it can't override MASS, we absolutely need to open 10,000 part one by one to doing this :(. Will the the only way to do this be a macro to run in batch? If a macro is available it could be useful.
Thanks
Solved! Go to Solution.
Solved by ckeveryga. Go to Solution.
This rule will update the mass for every part in an assembly and subassemblies.
Class ThisRule Dim oAsmDoc As Document Public Sub Main() oAsmDoc = ThisApplication.ActiveDocument If oAsmDoc.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Return End If Call TraverseAssembly(oAsmDoc.ComponentDefinition.Occurrences) MessageBox.Show("All weights updated.", "iLogic") End Sub Private Sub TraverseAssembly(Occurrences As ComponentOccurrences) Dim oOcc As ComponentOccurrence Dim dblMass As Double Dim strMassProp As String For Each oOcc In Occurrences oDocType = oOcc.DefinitionDocumentType Select Case oDocType Case kAssemblyDocumentObject Call TraverseAssembly(oOcc.SubOccurrences) Case kPartDocumentObject Dim oCustomPropSet As PropertySet oCustomPropSet = oOcc.Definition.Document.PropertySets("Inventor User Defined Properties") 'Check for/create property Try strMassProp = oCustomPropSet.Item("MASSE").Value oOcc.MassProperties.Mass = Convert.ToDouble(strMassProp) / 2.20462 'convert to lbs Catch ex As Exception MessageBox.Show("No MASSE property.", oOcc.Definition.Document.displayname) End Try End Select Next End Sub End Class
Warning: if the MASSE property is not in the part, a message box will show up! (to remove, comment the message box in the catch)
Hope this works for you.
Thanks you so much for your help!!
All works fine and simply create a dummy assembly with all my 10,000 files to proceed! 🙂
Can't find what you're looking for? Ask the community or share your knowledge.