This article is most applicable to STK 11 or earlier users. For STK 12.1 and later users, AGI recommends using the STK Python API. The STK Python API provides the same "intellisense" capability as comtypes with the simplified casting capability of win32com. For more information on this interface, see STK API for Python.
Comtypes vs. win32com for STK Python programming
When trying to run some of the Python integration code examples and connecting to STK using the win32com or comtypes methods, you may run into an AttributeError.
In Python, there are two main ways you can connect to an external application: using comtypes and using win32com. From the above error, it appears that the user was using comtypes.
The benefit of comtypes is that you get intellisense; the tab enables you to see the next available properties and methods. However, it requires casting between interfaces to get access to different sets of properties and methods. The win32com method doesn't require casting, but you don't get intellisense. The code snippets in the STK Programming Help are written mainly with win32com, but using comtypes is typically the preferred method.
In the error case shown above, there is a facility, which is an STK object (IAgSTKObject) in general but is specifically a facility (IAgFacility). The default interface passed back when you create something in comtypes is the more generic interface, in this case IAgSTKObject. You need to use the QueryInterface method to switch to the IAgFacility to get access to the AssignGeodetic method.
# Cast fac into an IAgFacility called facObj
facObj = fac.QueryInterface(STKObjects.IAgFacility)
facObj.Position.AssignGeodetic(lat,lon,alt);