I have code that makes use of the DTransform3d.FromRotationAroundLine method. In previous versions this worked as expected but in the latest release of the SDK this does not seem to work, the rotation origin defaults to 0,0,0 regardless of what is passed into the FromRotationAroundLine method.
Has anyone else come across this issue?
I’ve tested it in version 10.10.20.048 of the SDK and I couldn’t find any issue with DTransform3d.FromRotationAroundLine method.
The code below uses the method to rotate a vertical line(cyan) [starting at (32.5, 20, 15) and ending at (32.5,20,35)] around another line(red) [starting at(5,10,10) and ending at (60,30,35)] by positive 90 degrees (the two lines are not perpendicular respect to each other). The resulting line(magenta) is [(27.59668,25.55589,21.34259)-(40.67220,10.74019,24.42901)]
I've used an arbitrary line as rotating axis but using X axis (1,0,0) or Y axis(0,1,0) or Z axis(0,0,1) the method works fine as well.
public void RotationTest()
//Line where trasnform will be applied
DSegment3d segment = new DSegment3d(32.5 * _uorPerMeter, 20 * _uorPerMeter, 15 * _uorPerMeter, 32.5 * _uorPerMeter, 20 * _uorPerMeter, 35 * _uorPerMeter);
LineElement lineToRotate = new LineElement(_dgnModel, null, segment);
//Line representing an arbitrary axis
DSegment3d lineToRotateAround = new DSegment3d(5 * _uorPerMeter, 10 * _uorPerMeter, 10 * _uorPerMeter, 60 * _uorPerMeter, 30 * _uorPerMeter, 35 * _uorPerMeter);
LineElement axisLine = new LineElement(_dgnModel, null, lineToRotateAround);
//Get the vector representing lineToRotateAround
DVector3d axisToRotateAround = DVector3d.FromXYZ((60 - 5) * _uorPerMeter, (30 - 10) * _uorPerMeter, (35 - 10) * _uorPerMeter);
//Point the vector passes through - midpoint of the lineToRotateAround = intersection point between the two segments
//As the point is located in lineToRotate only rotation will be performed.
DPoint3d pointOnLine = DPoint3d.FromXYZ(32.5 * _uorPerMeter, 20 * _uorPerMeter, 22.5 * _uorPerMeter);
//Rotate with SDK method
DTransform3d transform = DTransform3d.FromRotationAroundLine(pointOnLine, axisToRotateAround, Angle.FromDegrees(90));
if (transform == null)
TransformInfo tInfo = new TransformInfo(transform);
if (tInfo == null)
//Apply transform to lineToRotate.
//Get the rotated Segment to check rotation
DSegment3d rotatedSegment = new DSegment3d();
The result can be seem below (FIG 1)
Fig 2 shows a line element (cyan) rotated by different angles around the same line (or axis) but using different points along the line. To achieve this you need to translate the element to rotate to the point where the rotation should occur, and then apply the rotation. If not translated the method will apply both rotation and translation at same time and the result will be different.