Skip to main content

ADD NewField Error: TableDef Object has no atribute "NewField"

Hi,
i try to add a new field in IDEA 10.3 via Python:
 
import win32com.client as win32comclient
import os
import sys
idea = win32comclient.Dispatch(dispatch="Idea.IdeaClient")
db = idea.OpenDatabase("File.IMD")
task = db.TableManagement()
field = db.TableDef.NewField()
field.Name ="DIFFERENCE"
field.Description = ""
field.Type = 1
field.Equation = "BALANCE-SUM"
field.Decimals = 2
task.AppendField(field)
task.PerformTask()
 
I get this Error:
 field = db.TableDef.NewFieldAttributeError: 'function' object has no attribute 'NewField'
 
My Solution:
Change the String "field = db.TableDef.NewField()" to:
TDef = db.TableDef()
field=TDef.NewField()

Brian Element Thu, 05/23/2019 - 20:21

Hi Snape,

Sorry for not getting back to you sooner.  I just looked at some of my code and I also split it up into two lines.  Not everything translates exactly.

Brian