Alinoz Posted July 21, 2018 Share Posted July 21, 2018 Hi all, I'm a newbie to Vectorworks and Vectorscript, just started using it 5 days ago & I'm hooked. I'm trying to add a simple option with a script and then assign a keyboard shortcut to rotate the selected object 90 degrees around an axis. I know how to add the script to a menu and assign a keyboard shortcut. I used one of the scripts from here called Move to Origin, and it works a treat. What I need help with is getting the script correct. This is what I have and it does not work. I'm trying to rotate the selected object 90 degrees around the X axis. PROCEDURE Rotate90onX; VAR hnd : HANDLE; BEGIN SetRot3D(hnd,90,0,0,0,0,0); END; RUN(Rotate90onX); Any help or advice would be much appreciated. Thanks Al Quote Link to comment
michaelk Posted July 22, 2018 Share Posted July 22, 2018 You're close! Try this: PROCEDURE Rotate90onX; VAR hnd : HANDLE; BEGIN hnd := FSActLayer; SetRot3D(hnd,90,0,0,0,0,0); END; RUN(Rotate90onX); You were missing the step of assigning an object in the drawing to the handle variable. FSActLayer is First Selected Active Layer. Very useful when developing scripts. Handle is assigned to the first object that is selected. Be aware that SetRot3D doesn't rotate the object 90º in the X axis. It sets the X axis rotation to be 90º. To rotate the object 90º from it's current orientation, I think you want Set3DRot. Happy Scripting. Quote Link to comment
Alinoz Posted July 22, 2018 Author Share Posted July 22, 2018 Thanks so much for the super quick reply Michael! I did get SetRot3D and Set3DRot mixed up. You assumed correctly, that I want to be able to rotate the selected object 90º from it's current orientation. Is it a complex one to write using the Set3DRot? Are there any simple examples of this, without doing extrusions etc? I got lost on the example at http://developer.vectorworks.net/index.php/VS:SetRot3D Thanks very much for your time 🙂 Quote Link to comment
michaelk Posted July 22, 2018 Share Posted July 22, 2018 It's very simple. Just change the function to Set3DRot. Use the same arguments you already have and it works. Just did a test. The script I posted works on extrusions, 3D symbols, EAPs, sweeps, etc. The first 3 arguments are angles of rotation to be added to the current rotation of the object. The next 3 are the x,y,z coordinates for a point in space through which the axes for the rotation(s) will occur. In your example, the object will rotate positive 90º around the X axis. NOT (necessarily) the center of the object. If you want to rotate around the center of the object you first have to define three variables (type Real), find the center of the object and assign those variables to be those values and use the variables in the argument for Set3DRot. (or maybe use the top, bottom, left, and right bounds to calculate the center? Not sure. But's it's always daytime for some VS genius around the world and I'm sure they will have a better idea) Not sure if that helps. Keep posting back until we answer it in a way this is useful 🙂 Quote Link to comment
Alinoz Posted July 22, 2018 Author Share Posted July 22, 2018 Thanks again Michael, I've had an 18 hr day and I'm going cross-eyed. I'll have a look in the next couple of days. I definitely want it to rotate around the center of the object too. It might be a bit too complex for me this early in my Vectorworks journey. Kind regards, Al Quote Link to comment
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.