RotateSketchObjects not working with INV2023?

RotateSketchObjects not working with INV2023?

h.schkorwaga
Advocate Advocate
1,342 Views
8 Replies
Message 1 of 9

RotateSketchObjects not working with INV2023?

h.schkorwaga
Advocate
Advocate

Hello together,

 

since update to latest 2023.2 from 2021 the API method RotateSketchObjects from sketch object does nothing.

 

The following code wasn't altered for 2 years now and doesn't rotate the textbox anymore.

 

double dY = Endpoint.Y - Startpoint.Y;
double slope = dY / dX;
double TextboxAlignAngle = dX != 0 ? Math.Atan(slope) : Converter.rad_grd(false) * 90;


ObjectCollection objectCollection = GD.InvAPP.TransientObjects.CreateObjectCollection();
objectCollection.Add(textBoxBend);
sketch.RotateSketchObjects(objectCollection, textBoxBend.Origin, TextboxAlignAngle);

 

 

since the preferred approach ...

 

// Exception  for angles other than 90 and 180°
// textBoxBend.Rotation = TextboxAlignAngle;

 

... will throw an exception for angles except 0,90,270,360

 

The above was the way it worked.

 

Is there another way to rotate textboxes in 2023 API?

 

Thank you in advance!

 

BR

0 Likes
Accepted solutions (1)
1,343 Views
8 Replies
Replies (8)
Message 2 of 9

h.schkorwaga
Advocate
Advocate

Really no one affected?

0 Likes
Message 3 of 9

h.schkorwaga
Advocate
Advocate

No?

0 Likes
Message 4 of 9

h.schkorwaga
Advocate
Advocate

😞

0 Likes
Message 5 of 9

florian_wenzel
Advocate
Advocate

Hi,

 

what is in your ObjColl ?

 

i do something like this:

First i show the Boudaries fromTextBox

 

  Dim oTextBox As TextBox = oSketchTextBox.TextBoxes.AddFitted(oText_Point, oStringTextBox)
            oTextBox.ShowBoundaries = True

 

 

Next, then Get each SketchLine from BoundariesTextBox

 

      Dim oSketchLine As SketchLine
        Dim oObjColl As ObjectCollection = oTO.CreateObjectCollection
        For i = 1 To oSketch.SketchLines.Count

            oSketchLine = oSketch.SketchLines.Item(1)
            oObjColl.Add(oSketchLine)

        Next

 

 

Next,  i Rotate the ObjColl

 

 

    oSketch.RotateSketchObjects(oObjColl, oPoint, oAngle_Corection)

 

 

In this Case is VB.NET

But i want to say, that i Rotate the Boudaries of TextBox, not only the TextBox

 

 

0 Likes
Message 6 of 9

h.schkorwaga
Advocate
Advocate

Hi Florian,

 

thank for this good hint - but it unfortunately doesn't work for me.

 

ShowBoundaries is true (since years 🙂 )

 

With c# I did this now:

objectCollection.Add(textBoxBend);
foreach (SketchEntity item in textBoxBend.BoundaryGeometry)
{
    objectCollection.Add((SketchLine)item);
}

 

As in the sketch are more than one TextBoxes and other SketchLines I had a look in the API-Help. There I found the BoundaryGeometry which should return me the four border sketchlines of the textbox. The cast to SketchLine was my last hope, and shouldn't be necessary I guess.

 

May you could make a fast try if this works for you? If not then I suppose API is buggy here and I have to find another way to get this four SketchLines.

 

Thank you in advance!

 

0 Likes
Message 7 of 9

florian_wenzel
Advocate
Advocate

hi,

small change

Take only the First (1)  SketchLine from TextBox BoundaryGeometry.    - Not each

 

Next, take a MidPoint of this Line.

And Rotate this through this Point

 

I Have Still  Inventor 2022, too lazy.

 

 

 

 

 

0 Likes
Message 8 of 9

florian_wenzel
Advocate
Advocate

Hi,

 

C# Code:

 

 

 

 

 

 

it Works with Inventor 2023 latest Updates. 

 

Update: With SketchLines only from TextBox

 

 

 

0 Likes
Message 9 of 9

h.schkorwaga
Advocate
Advocate
Accepted solution

Hi again,

 

thank you for your efforts. My whole code was not so far away from yours. Despite I tried to take yours which led me to the same result. BUT was I just saw when swithing to Flatpattern in inventor was that the boundary was very small after rotating the textbox. When doing a resize manually with the mouse the text flips and is displayed with 90deg (see video attached).

 

Conclusion:

My code that worked for years worked the whole time (no need to rotate a boundary sketchline just the textbox itself) - BUT the behaviour of the boundary (or textbox) changed. I just haven't recognized this circumstance.

So, after rotating I adjusted the height of the textbox (simply double the fontsize)

 

 

textBoxBend.Height = fontsize*2;

 

 

This worked for me now!

 

Thank you very much!

Hel

 

 

0 Likes