Message 1 of 2
Set Virtual Component Material - INV 2015

Not applicable
01-08-2016
09:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm creating some virtual components and trying to set the material property for each one. It either doesn't work, the property value doesn't change, or it crashes with an "unspecifed error". The interesting part is; I can set any iProperty and even create custom iProperties but, cannot set the material. What can I do to resolve this issue.
Thanks,
Eric....
public bool SetVirtualCompMaterial(ComponentOccurrence _occ, string _matlName) { // Validate the occurrence is virtual. if (!(_occ.Definition is VirtualComponentDefinition)) return false; // Set a reference to the virtual component definition VirtualComponentDefinition _vCompDef = (VirtualComponentDefinition) _occ.Definition; // Return if the virtual component definition is null. if (_vCompDef == null) return false; // Set a reference to the material asset. Asset _materialAsset = _getMaterialAsset(_matlName); // Return if the material asset cannot be set. if (_materialAsset != null) { try { _vCompDef.Material.Name = _materialAsset.DisplayName; return true; } catch (Exception) { return false; } } // Assign the material from the provided string // because a material in the assets wasn't found. try { _vCompDef.Material.Name = _matlName;} catch (Exception) { return false; } return true; }