Hello!
I have a problem with a macro I wrote, which I believe probably has a very simple solution that I am overlooking due to inexperience with VBA.
My script starts by prompting the user to select a point in the currently active drawing using this line of code:
Location_Dist = ThisDrawing.Utility.GetPoint(, "Select distribution point: ")
This works perfectly when the code is executed from the VBA editor using the Run (F5) key, but it returns an error immediately when run from a custom button within AutoCAD.
The button I created calls the script using the following command:
^C^C_.-vbarun;"MyModule.DistributionScript";
This reaches the script perfectly as proven by a stop-point in the code, it always reaches the "Sub DistributionScript" line. However, as soon as it reaches the user input line I pasted above, it returns the following error:
I suspect the error is related to AutoCAD completely skipping over the user input part by not allowing the user any time to pick a point, thus returning an error due to empty/non-existing user input. Other scripts that require no user input run just fine using the same button code.
Am I calling the Macro in the wrong way? Am I asking for user input in the wrong way? Any help is greatly appreciated!
Regards
Solved! Go to Solution.
hi,
i tested and it looks correct. Problem will be somewhere else. I got this error only if i push key after running macro... so it throws this type of exception and it is correct
Thanks for your reply.
While that didn't really help me solve the issue, I did find this when looking around for similar pieces of code. Adding the following code fixed my problem entirely:
ThisDrawing.Utility.InitializeUserInput 1
I just put this before the line asking for user input, and voilá. Problem solved.
This line disable only null user input. Question is how this input get there if you only run this macro.... but important is that problem was solved:)
Can't find what you're looking for? Ask the community or share your knowledge.