how to make two object parallel?

how to make two object parallel?

nam_vt
Enthusiast Enthusiast
7,168 Views
4 Replies
Message 1 of 5

how to make two object parallel?

nam_vt
Enthusiast
Enthusiast

I have two instant family in a Revit project. I want to rotate the second element to the same orientation and direction with the firs element.

0 Likes
Accepted solutions (1)
7,169 Views
4 Replies
Replies (4)
Message 2 of 5

BenoitE&A
Collaborator
Collaborator

Hey nam,

From what I understand of your question the 2 objects are identical or are lines (or the term parallel has no meaning).

So I'd do:

Find the patern you can compare in the 2 objects (a vector giving the direction of your object?)

Find the angle between the 2 vectors

Rotate the second object (you can use ElementTransformUtils.RotateElement).

 

Have fun

Benoit


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
0 Likes
Message 3 of 5

nam_vt
Enthusiast
Enthusiast

I know that 

ElementTransformUtils.RotateElement( Document document, ElementId elementToRotate, Line axis, double angle );

But how I get axis from the first element?

The code detect the angle:

LocationPoint locationPt = element1.Location as LocationPoint;

 double angle = locationPt.Rotation;

 

0 Likes
Message 4 of 5

BenoitE&A
Collaborator
Collaborator

Well if your Object is not a Point the Location property has other properties. For example a Wall has a LocationCurve. So you can use these other properties. Since we know Nothing of your object it is hard to be more precise...


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
0 Likes
Message 5 of 5

JimJia
Alumni
Alumni
Accepted solution

Dear nam_vt,

 

You need to calculate axis you want manually.

Assume the two elements are column, and you want to rotate the element around XYZ.BasisZ.

Following codes show you how to create the axis that you want to use:

 

 

LocationPoint locationPt1 = element1.Location as LocationPoint;

LocationPoint locationPt2 = element2.Location as LocationPoint;

 

Line lineBetweenColumns = Line.CreateBound(locationPt1.Point, locationPt2.Point);
XYZ centerOfLine = lineBetweenColumns.Evaluate(0.5, true);
//there is the axis you can use for rotate
Line axis = Line.CreateUnbound(centerOfLine, XYZ.BasisZ);


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com