Author Topic: Consistency In Execution in Stand Alone VB Express 2008 appliaction - Acad2011  (Read 1783 times)

0 Members and 1 Guest are viewing this topic.

NirantarVidyarthee

  • Guest
Hello,

I am developing a stand-alone application using VB Express 2008 and AutoCAD 2011 with following steps.

10. Open a dialog box and collect information from the user.

20. Open AutoCAD in the background and open an existing drawing and save it with different name.

30. Fill in data in the drawing and close it.

40. Open another drawing (in the same AutoCAD instance) and save it with different name.

50. Create some geometry in the drawing and close it.

60. Close AutoCAD.

70. Close the application.

But I am unable to achieve any consistency in the execution.

Sometimes program does not run at all.

Sometimes, only first drawing is created. Sometimes only second drawing is created.

When I execute the program in debug mode the program always executes successfully.

When I run it on another computer (where VB Express is not loaded), program runs successfully only first time. But When I rerun the program it does not execute.
 
I am not an experienced programmer. So I may be missing simple tricks and techiques.

Please suggest me ways to make my program robust so that it runs successfully every time ond on any computer that has AutoCAD 2011.

Even trivial suggestions are welcome (since I may be missing something very simple). I will cross-check and let you know if I have already implemented that suggestion or the result of implementing that suggestion.

Since the program runs successfully while debugging, I have every reason to believe that there are no syntax errors.

This is a winforms application with a sub main that displays the first form.

- Nirantar Vidyarthee

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Welcome to theSwamp Nirantar.

That sounds like an interesting project.
I don't work with VB (can read)  but there are a few people here who may be able to help.

You may need to post some code before you get the sort of help you want.


Regards
Kerry

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

n.yuan

  • Bull Frog
  • Posts: 348
Here is my opinion:

1. Using stand-alone EXE to automate AutoCAD is hardly a good solution in many situation (maybe, unless the task is very simple), considering you are limited to use COM API only. And also considering you need to have AutoCAD installed, you can have almost the same UI and user experience to run the process inside AutoCAD, which is a lot faster and you have more choice of programming API (namely, you can use Acad's .NET API).

2. If you insists doing out-process automation, do not try to hide AutoCAD instance as invisible to cheat yourself that AutoCAD is running "in backgroud". In term of software, "running in backgroud" usually mean running in another thread. In your case, even AutoCAD instance is invisible, it is not iin another thread, itr is still hold your EXE app waiting each call to AutoCAD to be completed. AutoCAD is a very complicated desktop app, there is many chances that AutoCAD would be held and wait for user input. ot to mention that our code to automate AutoCAD very likely causes one of these chances. That is probably the reason your app behaves so inconsistently. Have you checked in Task Manager to see if you have running AutoCAD session(s) stuck in memory? IMO, you'd better to explicitly to set AutoCAD instance visible (at least before your app is thoroughly debugged - well, who can clain his/her app is thoroughly debugged and completely bug-free?), so that you can actually see what is happening with AutoCAD when your code is running.

3. If your task is only manipulate drawing data as you described, you can use Object DBX, so that the drawing is not actually opened in AutoCAD editor visibly, these would eliminate some possible AutoCAD poping up warnings/messages and reduce the chances that AutoCAD stopd for user interaction. Ideally, you could lisence RealDwg to manipulate drawing data without the need of installing AutoCAD, if the development can justify the prohibitive lisence fee.