By Wayne Brill
If you are using AddAttributeClass() an error: “Generic failure to execute operation with the provided arguments” occurs if the description property is not set for the McadAttributeField objects that are added to the McadAttributeFields collection that is passed into AddAttributeClass().
The documentation does not state that the Description property has to be set when AddAttributeClass() is called. Here is an excerpt from the AutoCAD Mechanical ActiveX and VBA reference:
IMcadAttributeField::Description Property
Remarks
This property is a String.
Setting or changing the field description only has an effect when the McadAttributeField is used to define an attribute class.
Here is a VB.NET example that avoids the error:
<CommandMethod("AttTest")> _
Public Sub McadAttTest()
Dim acadApp As AcadApplication =
Autodesk.AutoCAD.ApplicationServices.
Application.AcadApplication
Dim AcadMApp As AcadmAuto.AcadmApplication
AcadMApp = acadApp.GetInterfaceObject _
("AcadmAuto.AcadmApplication.2")
Dim mcadUtil As McadUtility =
AcadMApp.ActiveDocument.Utility
Dim attFields As McadAttributeFields =
mcadUtil.CreateCollection _
(McadCollectionType.mcAttributeFields)
Dim attField As McadAttributeField =
mcadUtil.CreateAttributeField()
attField.Name = "InnerDiameter"
attField.FieldType = McadFieldType.mcDouble
' If this is not set an error occurs
' when AddAttributeClass() is called
attField.Description = "Some description"
attFields.Add(attField)
AcadMApp.AddAttributeClass _
("myAttributeClass", attFields)
End Sub