Jump to content
GVRT

Rotating a symbol around it's insertion point

Recommended Posts

I’m using VW2017 with Spotlight and I use the ‘rotate left 90 degrees’ command as a keyboard shortcut a lot.
 
I’d like symbols to automatically rotate around their insertion point but mine don’t when I’ve got a label legend applied to them. When the label legend is applied the symbol rotates around the centre point of the symbol and the legend combined instead. 
 
I've explored using a vectorscript to help here but haven't got enough knowledge to make it work. I've noticed when I insert a locus on top of the insertion point and highlight both the symbol and the locus, the symbol will rotate around the locus. Could a script: insert locus on insertion point, rotate left 90degs, delete locus
 
Many thanks in advance!
 
Edited by GVRT

Share this post


Link to post

I feel your pain.

 

If you were scripting it, you wouldn't have to even go as far as adding the locus and whatnot.  The script would simply get a handle to the object, get the coordinates of the object (which would be the insertion point), then use HRotate(90) to rotate the object 90˚ counter-clockwise about that point.


 

PROCEDURE RotateObject;

h : HANDLE;
sx,sy : REAL;

BEGIN;
   h:= FSActLayer;
   GetSymLoc(h,sx,sy);
   HRotate(h,sx,sy,90);
END;
Run(RotateObject);

At one point, when keyboard commands actually worked reliably, i had mapped a version of this script with 5˚  increments to my scroll wheel, so I could select a fixture and rotate it using the scroll wheel.  

Share this post


Link to post

Hi Sam,

 

Thank you for this. I just tried running this script but it comes up with the errors shown in the attached image. Apologies I have no knowledge of scripting!

 

Many thanks in advance for your help.

error.png

Share this post


Link to post

Sam

 

I love that idea of using the scroll wheel to rotate by 5º!!!  Might have to steal that. :-)

 

GVRT

 

Try this one.  It's the same idea as Sam's, but it works when you have multiple instruments selected.

 

 

Rotate Instruments.vwx

Share this post


Link to post

Sam's script is missing the statement VAR

 

If you add VAR on its own line like this:

 

PROCEDURE RotateObject;
VAR
h : HANDLE;
sx,sy : REAL;

BEGIN;
   h:= FSActLayer;
   GetSymLoc(h,sx,sy);
   HRotate(h,sx,sy,90);
END;
Run(RotateObject);

 

 

that should make it work.

Share this post


Link to post

Thank you everyone. Both scripts work now.

 

Michael, your one is brilliant for working on multiple symbols. 

 

I have no idea why rotating around the insertion point when label legends are applied isn't default in VW anyway!

  • Like 1

Share this post


Link to post
18 hours ago, GVRT said:

I have no idea why rotating around the insertion point when label legends are applied isn't default in VW anyway!

 

Guys - I can't even get this to work in a simple manner.

 

On reading this thread, I thought I would have a look for any answers to help @GVRTand came across the the following glitch (or feature?).

 

To establish an insertion point for a simple symbol looks easy....

 

59ad1dcdbda5a_SymbolInsertion.png.062aafdf23ce9665a5d517fe6f95f5fc.png

 

(Just to make clear - they were dashed lines before I did a screen capture

 

----------------------

Edit - I've just seen that should of course say leftmost part of the symbol (doh!!)

----------------------

 

Either this is..

  • My ineptitude :) - And someone will point this out to me. (gently does it!)
  • Vectorworks problem :( - And this is a known issue..
  • Vectorworks new issue (can't believe this really, as someone else will have raised it and I haven't seen anything on this forum)
  • I need new glasses.B|

 

 

Sorry to jump on this thread BTW, but it seemed appropriate.

Edited by Gadzooks

Share this post


Link to post

Gadzooks,

   With the Symbol Insertion tool selected, make sure your symbol insertion mode is set to "Insertion Point" (fourth button in its group). It can be toggled, intentionally or inadvertently, by pressing the "O" key when the Symbol Insertion tool is active.

 

59ad6b369d2cd_SymInsertionMode.png.8b645892f606340eacd4607ca75162f7.png 

 

HTH,

Raymond

  • Like 1

Share this post


Link to post

Thanks - rookie mistake then. Or more likely I'll convince myself I was in too much of a rush.

 

I believe (of my earlier options) it's the new glasses then. 

 

B| Thanks again.

Share this post


Link to post

I amy be late to the party, but I posted a script in  2015 (originally in 2008 and 2010) that rotates  Symbols and PIOs around their insertion point.  Here is the 2015 post.

 

 

Share this post


Link to post

Thanks Pat, that is brilliant. I especially like that it can distinguish between symbols and other objects. 

 

Is it easy to make it rotate the objects by a set amount without the dialogue box?

 

Many thanks

Share this post


Link to post

Very easy to change.

 

Change the line that reads

 

R1:=RealDialog('Enter the amount to rotate each object by','90.0');

 

to something like

 

R1:=45;

 

make sure the line ends with a semicolon  ( ; )  [No that is not a smiley face, just trying to show the character] ;-)  [That one is a smiley face using a semicolon]

  • Like 1

Share this post


Link to post

Thanks again Pat. One more question and then I'll leave you alone!

 

With the version I've just made that rotates 45degs, is it possible for the symbol to stay selected so I don't have to keep on re-selecting the symbol to rotate it multiple times?

 

Many thanks

Share this post


Link to post

I don't have time to test right now, but try deleting or commenting out (enclose the line in curly braces/parentheses {}  ) the line that reads.

 

				SetDSelect(FSActLayer);

 

That should leave all of the selected objects still selected.

 

Pat

Share this post


Link to post

Thanks Pat, that works a treat :)

 

The only thing your script still doesn't do, that Michael's does (who posted at the top of this thread) is rotating multiple symbols at once. Could that be incorporated into your super-script?!

 

Michael's script quoted below:

 

Quote


Procedure InstrumentTurnLeft;
{Badly scripted by Michael Klaers}
{Select  instrument(s).  Run the script.  
All the instruments will keep their insertion points and rotate left 90º}

 


VAR
    
    SymbolHandle                : Handle;                 
    
    CurrentAngle, xLoc, yLoc     : Real;

  PROCEDURE RotateIt(SymbolHandle:HANDLE);

    BEGIN
    
    GetSymLoc(SymbolHandle, xLoc, yLoc);
    CurrentAngle := HAngle(SymbolHandle);
    HRotate(SymbolHandle, xLoc, yLoc, 90);
    
    END;

BEGIN
       ForEachObject (RotateIt,((SEL=TRUE)));
END;

 

RUN(InstrumentTurnLeft);

 

Share this post


Link to post

GVRT

 

It's really funny that you're asking Pat if his script can do something mine does.  He probably taught me how to do it.  :-)

 

In my script you can also change the amount of spin by changing the 90 in the line

 

    HRotate(SymbolHandle, xLoc, yLoc, 90);

 

to whatever you want.

 


 

Share this post


Link to post

Ha - I'm unaware of hierarchy!

 

The bit that's really clever about Pat's script is that it can tell between a symbol and an object that isn't a symbol. That's why I'm using his at the moment. However, as I said, Pat's doesn't work like yours when multiple symbols are highlighted.

 

I'm aware this isn't just a script order factory so I very much appreciate your guy's help.

Share this post


Link to post

Oh, but it IS a "script order factory", and the chefs are lined up at their keyboards. You'd be amazed what you can get with a "please" and "thank you" around here. Right Pat? and Mike? and Wasn'tISam?  This place isn't even the right place. If you want some real attention try posting questions in the VectorScript or Python fora.  ;-)

 

Raymond

  • Like 1

Share this post


Link to post

:D:D:D:D:D

 

Raymond's right.  It sort of is a script factory.

 

While there isn't a real hierarchy, in my mind there is a simple two layer hierarchy.  I'm the sole occupant of the lower level :-).  

 

I've found that if you're looking for something simple like this, someone who really enjoys these kind of puzzles will often have already written it, written something close to it, or be able to blast it out quickly.  And if you want to learn how to do it:  Read the documentation, give it a shot, and then ask questions.  

 

Pat, Raymond, Josh, Sam, Sam J, Miguel, and many others have patiently explained the dark art to me.  

 

Scripting in VW can be powerful.  I'm pretty bad at it and I saved hours of work just in the last couple days with simple scripts.

 

In the case of your script it would be pretty easy to put the very clever logic test to check if the selected object is a plug in object or symbol into my script.  I'd have to look more closely at Pat's script to see how to alter his. - I think it already does almost what you want.  Dynamic arrays make my head hurt a little bit.  :P

Share this post


Link to post
3 hours ago, GVRT said:

The only thing your script still doesn't do, that Michael's does (who posted at the top of this thread) is rotating multiple symbols at once. Could that be incorporated into your super-script?!

 

Are you sure? The script was written to specifically rotate all selected object around their individual insertion points.  

 

When I run Michaels script, it seems to group the instruments together and then rotate the whole blob. With mine, the individual instruments stay in place just turn around that point.

 

Raymond and Michael are correct. There are a few of us who are more than happy to work on scripts for kind of specialty tasks just for fun or to prove it can be done. Most of these are not going to be fancy. They are mostly one-trick ponies, and often a little ugly under the hood, but they serve as a kind of learning framework for those who need help understanding the guts of VW. My guess is I have probably posted 100+ scripts and snippets since 2008. I (and others) are usually more than happy to help you with a specific problem. Especially if you appear to be trying to help yourself rather than just looking for a handout.

 

Some of the scripts we tend to do are to improve repetitive actions. Others are to expose things that are not easily accessible through the normal UI.

 

It never hurts to ask. Many times one of us has already done something similar and can give you a solution fairly quickly. Or it just will tickle our fancy or that Pavlovian center in our brain and be something we just have to work on. Can Not Let The Computer Win!

 

You are unlikely to get a huge project for free (if you want a new stair tool you are probably out of luck), but if you want to take on a huge project we will be more than happy to try and point you in the right direction.

 

And if you happen to run into us at the Design Summit or some other event, I don't think any of us would turn down a beer ;-)

  • Like 1

Share this post


Link to post

Hi Pat,

 

I'm using VW2017 and Michael's script rotates multiple symbols around their individual insertion points for me.

 

Your script behaves very strangely with multiple symbols. Sometimes it only rotates one of the selected symbols, sometimes it rotates one of the selected symbols but by double the angle that's specified. 

 

I'm still using your script because it can distinguish between symbols and other objects. The multiple symbol selection would just be the icing on the cake!

 

Thanks :)

 

 

Share this post


Link to post

Raymond, you crack me up.

 

GVRT, attached is an updated version of my scripts with Pat's magic IF/THEN/ELSE statement added stolen to take care of non symbol, non plugin objects.

 

Again, you can change the 90 degrees to whatever you want.

 

Just like Pat said above, most of my scripts are not fancy.  They have work to do and they aren't pretty.  :-)  Because I find writing dialog boxes to be slow going, I usually do something like duplicate this script and make versions that are 5º,  15º, 22.5º, 30º, 45º, 90º left and right.  Put them in a script palette and call it good.

Rotate Instruments update.vwx

Share this post


Link to post
On 9/5/2017 at 4:39 AM, MullinRJ said:

Now it's official. You two are bound by Script-ure.   ;-)

 

59ae6078be040_PMsSOF.png.4793f884dc6200bcc94a05233c3a6d54.png

 

LOL! Nice job Raymond!

However, Mike looks a little pale...

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×