Weldment Material in VBA?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm having a problem with Weldments Material. I have a Userform with a combobox/dropdown list thing, which is populated with material assets (their displaynames) taken from Application.ActiveMaterialLibrary.MaterialAssets. The user can choose the active component's material from this list. Once the combobox changes, I apply the materialasset to the active edit document this way:
oDoc.ActiveMaterial = ThisApplication.ActiveMaterialLibrary.MaterialAssets.Item(strMat)
(where Mat is the string from the combobox)
This seems to work fine: it also automatically copies the selected material to the part's local materials.
The problem is, when I try to do the same on a weldment component, applying the MaterialAsset onto the WeldBeadMaterial:
oDoc.ComponentDefinition.WeldBeadMaterial = ThisApplication.ActiveMaterialLibrary.MaterialAssets.Item(strMat)
This always fails. It doesn't automatically copy the material either.
When I do a copy and then apply the copied material, then it works:
oDoc.ComponentDefinition.WeldBeadMaterial = ThisApplication.ActiveMaterialLibrary.MaterialAssets.Item(strMat).CopyTo(oDoc, True)
So the question is, why it doesn't work on a WeldBeadMaterial the same way as it does on ActiveMaterial in the case of a partdocument?
Or if the last (working) code is the correct way, then should I do it the same way in the partdocuments' case?
Thanks for any clarifications.