Dynamo for Civil 3D. How to rotate a block on an axis XZ

Good days!
How to rotate a block on an axis XZ using Dynamo for Civil 3D?


Rotate.dwg (924.0 KB)

Hi @durasovartyom

I don’t think there is any node to rotate on axis XZ but you can do with python by using Matrix3d.Rotation method through providing the proper rotation angle, rotation axis, and rotation base point to it and feed the matrix instance to the TransformBy method of the entity of concern:

obj.TransformBy(Matrix3d.Rotation(angle/57.2958,Vector3d(x,y,z),Point3d(x,y,z)))

6 Likes

Thank you very much!
Please attach the file .dyn to your answer…

Hi,
With only the Dynamo nodes I got this script for the rotation of a blockreference type object.


Is it good for you?

3 Likes


как вариант

2 Likes

Thank you all very much!

Hi, I did my script from your code, and that result I have, the block has changed a position in another direction

Чертеж1.dwg (1014.2 KB)

For a good result always put your blocks at the point of origin 0,0,0.
Use the solution proposed by Mikhail_Kozlov because it is better than mine.

Thank you very much for the advice

Have you tried the node BlockReference.ByCoordinateSystem.
In your case you would have to make a rotation of your intial coordinate system with CoordinateSystem.Rotate and then use this new coordinate system as reference for your block…

image

1 Like

Hi all,
I hope you are doing well regarding the rotation of the Blocks! I am new to Dynamo and am trying to create a script that allows me to rotate the block around its reference point (360) without making a replica of the original block!? Any suggestions or tips regarding this?
Thank you very much, and I wish you a nice weekend
Kindly regards
Salwan