Text Along Line

Text Along Line

Anonymous
Not applicable
415 Views
3 Replies
Message 1 of 4

Text Along Line

Anonymous
Not applicable

Hi,

Using the following code trying to place textnote along pipe curve but results are not correct as the textnote doesn't rotates along the line. This I am doing in 3D view. I am creating a ModelLine using the pipe's curve and then creating textnote which should follow the ModelLine.

// get the curve of the element
Curve curve = ((LocationCurve)elem.Location).Curve;
              
// get start and end point of pipe
XYZ PipeEnd = curve.GetEndPoint(1);
XYZ PipeStart = curve.GetEndPoint(0);

 // get vector representing the pipe
double difX = (PipeEnd.X - PipeStart.X);
double difY = (PipeEnd.Y - PipeStart.Y);
XYZ baseVec = new XYZ(difX,difY, 0);

Double textRad = Math.Atan2(baseVec.Y, baseVec.X);

var testOptions = new TextNoteOptions() { HorizontalAlignment = HorizontalTextAlignment.Center, Rotation = textRad, TypeId = (doc.GetElement(texttypeID) as TextNoteType).Id };
var text = TextNote.Create(doc, view.Id, origin,strText, testOptions);

Thanks & Regards

Sanjay Pandey

0 Likes
416 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk
0 Likes
Message 3 of 4

Anonymous
Not applicable

Dear Jeremy,

Already using the code as suggested but the getting wrong results.

Output when not specifying angle in TextNoteOptions

withoutangle.pngOutput When specifying angle:


withangle.pngThanks & Regards

Sanjay Pandey

0 Likes
Message 4 of 4

jeremytammik
Autodesk
Autodesk

The sample is presumably using a 2D view.

 

In a 3D view, the required text orientation will be different for each point of view.

 

Therefore, it makes no sense to try to add the text in a 3D view.

 

Consult with an application expert on the right way to address this and determine the best practices, optimal workflow and solution manually through the user interface first, before trying to program anything.

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes