- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @d_eckel. You are correct. That appears to be a mistake. The following line of code in Line 10:
ElseIf oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
...should have been changed to be like this:
ElseIf oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
My original code was just for use in parts, because they are the only place where materials matters to me. I added the other stuff for assemblies to the code yesterday, just before posting it on the forum. I tested the final code on a couple parts at that time, but not on any assembly yet before posting it.
I actually had multiple different similar rules locally that I had used for similar purposes before, each doing things a bit differently, and generating different feedback, in different formats. I sort of gathered together some of the best stuff from all of them into one rule, to provide the most information. After I corrected that one line of code that you mentioned, I also changed a couple other minor things that helped it work better. Just inside the custom Sub routine named "CollectMaterialAssetData", I commented out that first line of code that adds "Material Report:", because in this example, we are already adding a header line within the 'Sub Main' area. Then down within the custom Sub routine named "CollectAssetValueData", where it is dealing with a 'kAssetValueTypeChoice', I added " = {}" after those two lines of code declaring Array type variables, as a way to assign them an initial value. That fixed the error it was handling (and logging) at that point.
After making these changes, I tried the corrected code on a regular assembly, and it only returned information about the default virtual component material, then I tried it on a weldment type assembly, and it returned data about both the virtual component material, and the weld bead material, as expected, without any errors.
I attached the corrected and updated code as a text file for you to review again.
Wesley Crihfield
(Not an Autodesk Employee)