yl2000 Posted April 29, 2009 Posted April 29, 2009 Hi, I am writing code that opens AutoCAD application and does some drawings. The problem I have here, is that every time I run my code it opens a new AutoCAD window: public bool bStartAutoCAD() { AutoCAD.AcadApplication ACADApp = new AcadApplication(); m_ACADApp.Visible = bVisible; ...... //do my drawings //leave autocad open } For some reason, I have to leave the autocad open at the end of the code. so after a while there are many AutoCAD window open. I want to modify my code so that, at the beginning of the code, it checks if there is an AutoCAD window open, if so, just brings up that one and doesn't start a new application. Anyone has some idea how to do this? Thanks! Quote
wannabe Posted May 2, 2009 Posted May 2, 2009 What about having one AcadApplication that is "ref" paremeterised? public bool bStartAutoCAD(ref AutoCADApplication ACADApp) { if(ACADApp == null) ACADApp = new AcadApplication(); //Do your drawings //Leave AutoCAD open } So, if it isn't null, it won't start a new application; but you'll need to empower with focus yourself. Have you contemplated making two distinct modules?: One for instantiation of an application and another to perform the automation? Hope this helps. Quote
yl2000 Posted May 4, 2009 Author Posted May 4, 2009 Thanks, wannabe. Yes, your suggestion helped! I appreciate! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.