3 Replies Latest reply on Nov 15, 2018 1:57 PM by Todd Carpenter

    Get an entity from an attribute

    Todd Carpenter

      I'm following along with the C# example to add an attribute and then find it.  I've modified it a bit to add it to a selected drawing point.  This all works - or at least SolidWorks says it does.  I can find the added attribute no problem, but I can't seem to get the entity associated with the attribute.  This always seems to produce a null:

       

      Entity swPt2 = (Entity)swAtt.GetEntity2();
      

       

      Any ideas on what I'm doing wrong?  I did check the entity state on the attribute, and they all return false (meaning their valid) as the API documentation suggested, but I can't seem to figure this out.  I've it in various ways as well:

       

      SketchPoint swPt2 = (SketchPoint)swAtt.GetEntity2();
      SketchPoint swPt2 = (SketchPoint)swAtt.GetEntity();
      Entity swPt2= (Entity)swAtt.GetEntity();
      

       

      They all return a null SketchPoint or Entity.  What am I missing?

       

      Thanks