Jump to content
Sign in to follow this  
Kevin McAllister

How to rotate an object

Recommended Posts

I've had a lot of trouble getting an object to rotate using the Transform2 or Rotate Nodes. The documentation is confusing about what's needed (angle, vector, point) to make this happen.

In fact, I can consistently get VW to crash using the setup in this file. All you need to do is enter the node and then exit again.

I wish the node descriptions about what's needed were clearer. I've found myself looking at the code and referencing the Vectorworks Developer wiki to try and figure it out. This sort of defeats the purpose of visual scripting.

I also wish any unconnected input showed up as a field in the OIP for a given node (ie. for the Rotate or Transform2 nodes in this case). That way if I wanted to set a constant value or initial value I could set it there but it wouldn't be a field in the Wrapper OIP. I couldn't find an input node that was a hidden input (ie. didn't show up in the OIP)

Any help getting this rotation to work would be appreciated. It seems like it should be a simple thing.

Kevin

Edit, the forum won't let me add a file. Its currently telling me the maximum file size is 1 Byte. I suspect its broken.....

Edited by Kevin McAllister

Share this post


Link to post

Unconnected nodes can't default to input fields unfortunately, since most connections can take multiple input node types. Allowing it to "guess" is too dangerous, but thats just the nature of programming in general.

Documentation is coming, just didn't get wrapped up in time for release. Im head down making materials for it right now as are some of the engineers.

the forum won't let me add a file. Its currently telling me the maximum file size is 1 Byte. I suspect its broken.....

Should be fixed now, please try again and let me know, worked on my end but I have a different permission set.

Share this post


Link to post

For rotating objects, my tutorial actually covers that specifically, it should be done next week. If i can snip out an excerpt before that I will if someone else isnt able to answer here first.

Share this post


Link to post
Unconnected nodes can't default to input fields unfortunately, since most connections can take multiple input node types. Allowing it to "guess" is too dangerous, but thats just the nature of programming in general.

Makes sense. Is there a node for setting a default value then, one that doesn't show up as a field in the OIP (like a user definable Pi type node)?

Documentation is coming, just didn't get wrapped up in time for release. Im head down making materials for it right now as are some of the engineers.

We're all just too excited to wait :-)

Forum upload is working as expected again. Thank you!

I've attached my file. For anyone who downloads it be aware that as soon as you enter and exit the Marionette Object it will crash VW.

Kevin

Share this post


Link to post

I can't duplicate the crash here, but I do see the rotate problem and am fixing it. It is only a problem when rotating a planar object inside of a Marionette object. If you rotate the extrude instead it should work. Please let me know if anyone else is getting a crash with this file. Sorry for the inconvenience.

Share this post


Link to post

Mark I am also getting a crash with this file - however if I convert the marionette object to a wrapper, it works without crashing.

Share this post


Link to post

I actually started by trying to rotate the object after extruding. When I couldn't get that to work I moved the node to rotate the 2d object first. I couldn't get that to work either. That's when I posted here.

Thanks for all of the info. I'll give it another try when I'm back at my computer.

KM

Share this post


Link to post
I can't duplicate the crash here, but I do see the rotate problem and am fixing it. It is only a problem when rotating a planar object inside of a Marionette object. If you rotate the extrude instead it should work. Please let me know if anyone else is getting a crash with this file. Sorry for the inconvenience.

Hi Mark,

There is definitely a bug or two with the Transform2 node. It doesn't seem to respect the anchor point input and always rotates around 0,0. I'm not a programmer but I stripped it right down to the basics for rotation and now its working for what I need.

(I really wish VW treated everything like it was 3d. Fighting against the planar stuff is such a challenge when scripting and makes things so much more complex than they need to be.)

This is what I ended up using:

@Marionette.NodeDefinition

class Params(metaclass = Marionette.OrderedClass):

this = Marionette.Node( 'Transform Modified' )

this.SetDescription( "This node will transform a 2D object or 2D vector")

anchor = Marionette.PortIn( (0, 0), 'anchor' )

anchor.SetDescription('A 2D point to rotate about. If not provided object will rotate around it\'s center')

rotate = Marionette.PortIn( 0, 'angle' )

rotate.SetDescription('A single rotation angle around Z')

input = Marionette.PortIn( vs.Handle(0), 'obj')

input.SetDescription('The 2D object to transform')

output = Marionette.PortOut('obj')

output.SetDescription('The transformed object')

def RunNode(self):

i = self.Params.input.value

r = self.Params.rotate.value

a = self.Params.anchor.value

vs.HRotate(i, a, r)

self.Params.output.value = i

There's some sort of issue with the basic Rotate node as well. I gave up on that one.

Cheers,

Kevin

Edited by Kevin McAllister

Share this post


Link to post

Just use the Vec3 node from input section and you can specify the angle of the rotation.

You rotate them about one of the x,y,z axis and input the angle you need.

The rotate node asks for an angle about a vector.

rVec.SetDescription('It could be a 2D/3D rotation vector or Point2/Point3 in the Input category. Angles are in degrees')

see file

The Transform2 Node works ok in a PC.

This one askes for a specific angle around the Z axis.

rotate.SetDescription('A single rotation angle around Z')

HTH.

Edited by Alan Woodwell

Share this post


Link to post

Be sure your script is not the only one that crashes VW, Personally I record every 5 to 10 actions switching from name V1 to name V2 and keep the VW backup file as well. This way I don’t have to rewrite my title name every 1mn (this is the frequency of crash if the script is wrong somewhere).

About the crash it depends of the mac system version I don't crash the same way in 10.10 and 10.10.5

Share this post


Link to post

Thanks.

What I wanted to try and do was to randomly rotate a set of objest and stack them.

So I needed to created a way to get a list of random outputs to then convert to a Y axis rotation . I was able to use the transform node to accomplish this.

Is there a way to convert a number to a V3 input?

Share this post


Link to post
Why can't I just give it a degree value??

i wish we could specify an angle

You can. I'm not sure if its documented. Use a Point3 node as input into the Ang port and put the angle in the Z value. The only weirdness is the Z field shows up as a dimension instead of degrees depending on your file units setting. I've attached an example file.

Kevin

Edited by Kevin McAllister

Share this post


Link to post

Hello all,

It is frustrating that a number value can't be used as the input of a rotate node, but that is because the rotate node allows you to rotate objects not only two-dimensionally, but also around the x and y axis. Thus you have to specify the axis that you are rotating around with a point3 or vector3 node. In order to create a series of rotation values, use a Point3D node from the Points category and put the angle values into the z input of the Point3D node. (A point3 or vector3 node does not allow inputs from other nodes, only typed in inputs.) Remember though that you need the same amount of objects as rotation values, otherwise it will add the rotation values together.

Share this post


Link to post

Look at this network published by Luis M Ruiz earlier in the forum.

Duplicate & Scale and with a little bit of work you could convert it into making a 3D object and then adding the move in the Z direction.

All the Examples are found here and they are Magic and worthwhile and they give fantastic and simple process (Workflow) examples.

A must for anyone starting out or needing a great reference library.

https://techboard.vectorworks.net/ubbthreads.php?ubb=showflat&Number=217457#Post217457

HTH

Edited by Alan Woodwell

Share this post


Link to post

(A point3 or vector3 node does not allow inputs from other nodes, only typed in inputs.)

HI, Agree, I normally will control the rotation in the OIP so I name the Vec3 node and it shows up and I can rotate in any of the 3 Vectors. See Endless file attached.

If within a network then its simple a matter of using the rotate to get the orientation of a specific item as needed.

See Caster-02 file for rotating within network.

HTH

Edited by Alan Woodwell

Share this post


Link to post

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

 

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.

×
×
  • Create New...