Reputation: 343
When I get element type, I can't ask if element is Class:
var theElement as EA.Element;
theElement = Repository.GetTreeSelectedObject();
If (theElement.Type=="Class"){}
I get error "Object was expected". Also tried to create string variable, but didnt work... Any idea? Thanks.
Upvotes: 1
Views: 162
Reputation: 13750
TreeSelectedObject()
does not necessarily return an EA.Element
.
It could be EA.Diagram
, EA.Package
, EA.Attribute
,...
You should first check whether the returned object is not null.
Then you can use theElement.ObjectType
to distinguish between the different object types
See also http://www.sparxsystems.com/enterprise_architect_user_guide/13.5/automation/objecttypeenum.html
Upvotes: 2