Rotate ViewSection using a transforms view direction

Rotate ViewSection using a transforms view direction

Anonymous
Not applicable
3,079 Views
3 Replies
Message 1 of 4

Rotate ViewSection using a transforms view direction

Anonymous
Not applicable

Hi, I am creating a ViewScetion from a bounding Box, I used the below code to get a transform working, however I would like the section orientation to be at 90 degrees to what it is at the moment. Currently the view section cut is ok, it cuts in plan and the view section marker is visible however i'd like it rotated in plan view by pi/2.

cheers,

 

 This is how i get the view direction currently!

//TRANSFORM - set 
Transform trans = Transform.Identity;

//ORIGIN - set
XYZ farPt = boundbox.Max;
trans.Origin = farPt;

//VIEW DIRECTION
trans.BasisX = -XYZ.BasisX;
trans.BasisY = XYZ.BasisZ;
trans.BasisZ = XYZ.BasisY;


sectionbox.Transform = trans;

0 Likes
Accepted solutions (1)
3,080 Views
3 Replies
Replies (3)
Message 2 of 4

aignatovich
Advisor
Advisor
Accepted solution

Hi!

 

Try:

 

trans.BasisX = XYZ.BasisY;
trans.BasisY = XYZ.BasisZ;
trans.BasisZ = XYZ.BasisX; // or -1*XYZ.BasisX

 

In general BasisZ will be your section direction, BasisX is your section line direction (in plan, for example), BasisY should be orthogonal to BasisZ and BasisX

Message 3 of 4

Anonymous
Not applicable

Thanx, I even tried random attempts and there cant be that many 9? with the signs maybe 12?

I will definitely memorize this info!

 

0 Likes
Message 4 of 4

aignatovich
Advisor
Advisor

The section box can have any conformal transform. You can create it, for example via multiplication of any numbers of simple transforms, such as rotation, reflection, translation.

 

I've recently wrote creation of section boxes for each wall in room. Look at this is the part of the code:

private static BoundingBoxXYZ CreateSectionBoundingBox(XYZ startPoint, XYZ endPoint, double height)
{
	var length = (endPoint - startPoint).GetLength();

	return new BoundingBoxXYZ
		{
			Min = XYZ.Zero,
			Max = new XYZ(length, height, 1),
			Transform = CreateSectionTransform(startPoint, endPoint)
		};
}

private static Transform CreateSectionTransform(XYZ startPoint, XYZ endPoint)
{
	var direction = endPoint - startPoint;

	var angle = XYZ.BasisX.AngleOnPlaneTo(direction, XYZ.BasisZ);

	var shiftInsideRoomLenght = UnitUtils.ConvertToInternalUnits(300, DisplayUnitType.DUT_MILLIMETERS);

	var shiftInsideRoomDirection = direction.CrossProduct(XYZ.BasisZ).Normalize();

	return Transform.CreateTranslation(startPoint + shiftInsideRoomLenght * shiftInsideRoomDirection)
		   *Transform.CreateRotation(XYZ.BasisX, 0.5*Math.PI)
		   *Transform.CreateRotation(XYZ.BasisY, angle + Math.PI)
		   *Transform.CreateTranslation(-XYZ.BasisX*direction.GetLength());
}