Google
Web AutoCADTutorials.blogspot.com

Monday, October 24, 2005

Custom Button: Viewport UCS Rotation

Español | Deutsche | Français | Italiano | Português

Have you ever tried to rotate the UCS in a viewport? It takes at least three commands, and if you if you don't rotate it correctly the first time, it takes more than 6. This obviously wastes time. Let's make a new button to do this. Right click any toolbar and choose customize. On the left, choose user defined, then on the right, drag an instance of User Defined Button to your toolbar. Click the blank button you just created. Change the name and description to something you will recognize.

Now let's work on the code for the button.
^C^C clears any command you may be in when you activate a button and we will use it in our button today. One important thing to know is that semicolon means enter. We will invoke the UCS command by adding _ucs to our code. So far this is what you should have:

^C^C_ucs

We want AutoCAD to start computing our command so we add a semicolon after it. If you were to input _ucs into the command line you would get a few options. The answer we want to give is _z. Now I personally use the z axis because in my line of work, up is up and down is down and that's because of gravity. Others may need another default axis to work from. Now our code is:

^C^C_ucs;_z

We need to add another semicolon after \z to invoke the selection. Now it will want to ask us how far we should rotate. We may not always want the same amount so will tell it to ask for an angle by using the \ command. The backslash will pause our code and wait for user input. After the user has input the rotation we have to give it a few more parameters to update our view. These are part of those "at least three" command I spoke of earlier. Now your code should look like this:

^C^C_ucs;_z;\_plan;Current;

Very important!! Be sure to add a semicolon after "Current" in order to compute the final result. All you need now is an icon to finish off your new button. There is a suitable one included that has a rotation arrow with a z and ucs at the bottom. Apply, and close. Now, two things I have learned about this button.

1. You must activate the viewport before clicking the button.
2. To use the button again you must deactivate and then reactivate the viewport.

If anyone knows how to fix this, please let me know. I use this button almost daily and it is one of my favorites, right up there with Layer Un-isolate.

1 Comments:

Anonymous Gavin Clinch said...

In AutoCAD 2002 it is not necessary to deactivate and reactivate the viewport.

6:02 AM  

Post a Comment

Links to this post:

Create a Link

<< Home