AnsweredAssumed Answered

Add Attribute to Macro Feature face in VB.NET

Question asked by Cody Kirsch on Feb 19, 2018
Latest reply on Mar 8, 2018 by Cody Kirsch

I have a multi body macro feature that I need to add attributes to each body, and some of the faces and edges. I am able to add the attributes to all the bodies but not to any edges or faces. When I set a Entity equal to a face or edge, IEntity::Select4 returns false. If I pause code and manually select the face in the graphics area and use SelectionManager::GetSelectedObject6 to get the face and set the Entity equal the face the attribute gets added. At first I thought it might be an issue with body objects the program has are not the same as what are in the bodies folder but if that were the case then the attributes for the bodies should also fail. All of the code I am using for this macro feature is being moved over from a VBA macro and this portion of the VBA macro feature does work so I'm not sure what the issue is.


Sample Code:

swAttributeDef = swApp.DefineAttribute(AttDefName)

swAttributeDef.AddParameter(ParamName, swParamTypeString, 0, 0)



vFace  = swBody.GetFaces

For i = 0 To UBound(vFace)

     swFace = vFace(i)

     ID = swFace.GetFaceId

     If ID <> iFaceID Then

          wEntity = swFace

          'swEnt = swSelectionMgr.GetSelectedObject6(1, -1)  -> if the program is paused here and I select a face the attribute is added.

          swAttribute = AttDeff.CreateInstance5(swModel, swEntity , AttName, 0, swAllConfiguration)

          swParameter = swAttribute.GetParameter(ParamName)

          swParameter.SetStringValue2(ParamValue, swAllConfiguration, vbEmpty)

     End If

Next i