How to move a diagonal dimension with vector

How to move a diagonal dimension with vector

yahya_kilic
Participant Participant
300 Views
2 Replies
Message 1 of 3

How to move a diagonal dimension with vector

yahya_kilic
Participant
Participant

Hi all,

 

I can move a horizontal dimension up and down. I can also move a vertical dimension to the left and right.

But I can't move a diagonal dimensions down with 300mm.

 

Can someone help me please?

Thank you in advance!

yahya_kilic_0-1693330805087.png

Black dimension is origin dim.

Red dimension is the vector

Blue dimension would be the new place of dim

0 Likes
Accepted solutions (1)
301 Views
2 Replies
Replies (2)
Message 2 of 3

Mohamed_Arshad
Advisor
Advisor
Accepted solution

Hi @yahya_kilic 


  To get the diagonal vector, you have to cross the Dimension line Vector with Z Basis. Then Multiply the distance for translation with diagonal vector. Kindly refer the below code for additional reference.

 

Reference Code:

 

 

            //01.Get Curve from Dimension
            Line line = dim.Curve.Clone() as Line;

            //02. Get Unit Vector
            XYZ unitVector = line.Direction.Normalize();

            //03. Diagonal Vector
            XYZ diagonalVec = unitVector.CrossProduct(XYZ.BasisZ);

            //04. Movement Vector 
            //Note: For Reverse Negatate the Value
            XYZ translationVec= diagonalVec.Multiply(300 / 304.8);

            using (Transaction translateDim = new Transaction(doc, "Move Dim"))
            {
                translateDim.Start();

                ElementTransformUtils.MoveElement(doc, dim.Id, translationVec);

                translateDim.Commit();
            }

 

 

 

For Additional Help regarding Mathematical Concept, Kindly check the below URL

 

https://www.mathsisfun.com/algebra/vectors-cross-product.html#:~:text=The%20Cross%20Product%20a%20%C... 

 

Hope this Helps 🙂


Mohamed Arshad K
Software Developer (CAD & BIM)

0 Likes
Message 3 of 3

yahya_kilic
Participant
Participant

@Mohamed_Arshad thank you for your explanation and example!

It does exactly what I want 😁

I will dive into the mathematical concept 😊