As mentioned in other threads and elsewhere, it's possible to create your winforms dialogs etc in VS or Sharpdevelop so you have a nice ide to place and arrange controls with. Just compile the class lib and import it into your Ipy module.
You then need to derive from it and add your event handlers and change properties as required.
Here's a quick example based on Daniel's count layers demo.
import sys
sys.path.append('C:\\Program Files\\AutoCAD 2009')
sys.path.append('D:\\_Dev\\IPyCADv1.1\\IPyCADv1.1\\bin\\Debug')
sys.path.append('C:\\DCS_3D\\ipyscripts')
import clr
clr.AddReferenceToFile('acdbmgd.dll')
clr.AddReferenceToFile('acmgd.dll')
clr.AddReferenceToFile('IpyForm.dll')
from IpyForm import *
import Autodesk.AutoCAD.DatabaseServices as dbs
import Autodesk.AutoCAD.ApplicationServices.Application as app
class My_form(IpyForm):
def __init__(self):
IpyForm.__init__(self)
self.Text = "IronPython Demo"
self.Controls["label1"].Text = "Wow it's Python"
self.Controls["label2"].Text = "0"
self.Controls["button1"].Text = "Count Layers"
self.Controls["button2"].Text = "Close"
self.Controls["button1"].Click += self.lay_click
self.Controls["button2"].Click += self.close_click
def count_layers(self):
try:
db = dbs.HostApplicationServices.WorkingDatabase
print db.ToString()
tm = db.TransactionManager
tr = tm.StartTransaction()
ltbl = tm.GetObject(db.LayerTableId, dbs.OpenMode.ForRead, False)
i = 0
for layer in ltbl:
i = i + 1
tr.Commit()
tr.Dispose()
return i
except:
tr.Dispose()
print "error"
def close_click(self,*args):
self.Close()
def lay_click(self,*args):
self.Controls["label2"].Text = str(self.count_layers())
my_form = My_form()
app.ShowModalDialog(my_form)
And the piccy of the form as designed in VS2005