Saturday 2 March 2019

ArcObjects ITextSymbol.GetTextSize in Python: How do I define two input variables that get populated by the method?


I am using Python 2.6 and ArcObjects in ArcGIS 10.0 to build and draw, among other things, graphic text on the current display. At one point I need to use the ITextSymbol.GetTextSize method. In a function called BuildSignGraphic() have the following:


def BuildSignGraphic(pFeature, annoFC):
.
.
pTextSymbol.GetTextSize(pDisplay.hDC, pDisplay.DisplayTransformation, txt, dblX, dblY)
.
.


When I run my code I get a name error:


NameError: global name 'dblX' is not defined


In VB.NET, the dblX variable would be explicitly declared, but Python doesn't do this. Because the dblX and dblY variables are input and get populated by the method, how do I go about defining these two variables so that Python can recognize them? This is an uncommon syntax for a method in ArcObjects, but I think it does occur elsewhere in ArcObjects.


Thanks in advance for the assistance.


Cheers, Ti



Answer



Out params behave differently in comtypes, they come in the return value of the call:


dblx, dbly = pTextSymbol.GetTextSize(pDisplay.hDC, pDisplay.DisplayTransformation, txt)

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...