This is a proposed modification to the API that would make iLogic programming easier. I would like a way to tell if something exists or not prior to adding an object to a list.. Although I started with properties, it would apply to any iterated list like WorkPoints, WorkPlanes, DesignRepresentations, etc. where objects are looked up with the Item() method. For example if there is a line wp = WorkPlanes.Item(“MyPlane”), it would be helpful to first see if it exists otherwise you generate an error. Or prior to calling Workplanes.Add(“MyPlane”) because the MyPlane might exist already, which will throw an error. I think most commonly proposed solution is a try / catch structure but I think this is not very elegant and perhaps expensive in computer cycles. It would be beneficial if the items() functionality on a collection could tell you whether something exists or not as a Boolean. For example, PropertySet has member functions for Add and Delete. Why not Add, Delete and Exists? Here is a forum post where it was first proposed. There is no question that there are workarounds for this. I just felt that if it was written into the base class then all object collections that used Item() would benefit. Forum post about this https://forums.autodesk.com/t5/inventor-programming-ilogic/most-wished-for-api-call-does-this-iproperty-exist/td-p/12670347 It would be of minor benefit for a large number of users. Particularly beginning iLogic or VB.net programmers who get confused why their rule breaks sometimes. Sometimes it will break the second time you use the rule because you added a property/workpoint/object the first time you ran the rule.
Show More