Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 4 down vote accepted

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

dblx, dbly = pTextSymbol.GetTextSize(pDisplay.hDC, pDisplay.DisplayTransformation, txt)
share|improve this answer
Thank you so much, Jason. I have learned something new today. Happy New Year! – celticflute Jan 10 '11 at 4:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.