macro in vba

macro in vba

Anonymous
Not applicable
525 Views
5 Replies
Message 1 of 6

macro in vba

Anonymous
Not applicable
Hello everyone,
I have been experimenting with VBA and I am trying to take one of my extensive macros and convert it into VBA code. I have been told not to use the sendcommand option but I cannot find another way. All I am trying to do is have a button act just like the macro but I eventually need to create folders and copy dxfs to a new folder so I think converting the macro to VBA code first would be a better idea. The macro prompts the user to enter a number onto the object, scales the object , and finally dxfout. I appreciate all advice.

Here is my macro.

^C^C-LAYER;FREEZE;ENGRAVING;;XPLODE;ALL;;;;ALL;XPLODE;ALL;;;;ALL;-LAYER;T;ENGRAVING;LO;0;LO;ETCH;;ERASE;ALL;;-LAYER;U;0;U;ETCH;;-PURGE;ALL;;N;-LAYER;SET;ETCH;;DT;STYLE;STANDARD;\14;90;SCALE;all;;0,0;.03937;z;e;DXFOUT; ;
0 Likes
526 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Okay, lets make sure I understand what you're doing:

freeze the Engraving layer
explode everything else
thaw the Engraving layer
lock the zero layer
lock the Etch layer
erase everything that's not on the zero layer or Etch layer
unlock the zero layer
unlock the Etch layer
purge everything
set the current layer to Etch
[ At this point, the only items in the dwg are on the zero and Etch layers.]
put a dtext (user clicks on location) 14 units high at 90 degrees rotation
[ I don't see where you allow for the actual textstring.]
scale everything on the zero and Etch layers down from metric size to imperial size
zoom extents
dxfout

I'm only running this in my head, but when you issue the DT command, then pick the point, it sets the size to 14 and rotation to 90, but it doesn't wait for a string input, nor does it give a default string input - it goes straight to scale, which would probably choke it from there, because it's expecting some string value for the DT. Am I missing something?
0 Likes
Message 3 of 6

Anonymous
Not applicable
There is a backslash after "Standard" that allows the user to enter text and then the macro continues on.
0 Likes
Message 4 of 6

Anonymous
Not applicable
I ran that part of the code thru my AutoCAD (2008) and when it hits the backslash it's asking for the insertion point. I click on the screen, and it continues to make the height 14 units, and the rotation 90 degrees. After that, I see the word SCALE on my screen, and it's waiting for me to do something.

Does your text style Standard have a default height?
0 Likes
Message 5 of 6

Anonymous
Not applicable
Stevie,

It's probably because I'm still stuck with 2000i. Is there some general way to run a sequence of commands in VBA? I am somewhat familiar with coding and it seems like it shoud be easy. Thanks for the help.
0 Likes
Message 6 of 6

Anonymous
Not applicable
I haven't done much vba with 2000i - I got into vba when we went to 2006.

Before 2006, I was a big script guy - still am for some stuff.

This may be going the long way around (I'm sure someone will let me know 🙂 but I could see writing a script.

Most of the script could be pre-written, up to the point where you input the textstring.

The vba would ask for the textstring, finish the script, and run it.

If this is something you'd want to try, let me know. I'm sure there are different ways to do this, but this is one way that I understand. Hopefully others will chime in with good ideas. There's an abundance of knowledge on this message board.
0 Likes