Page 1 of 1

Rotate 2d desing and uddate X and Y point value

Posted: 16 Apr 2020, 11:29
by ditel
good morning
We use this routine to rotate the design and display it on the screen
our question if once rotated there is a way to save this data so that the x and y values of the entities are updated with the rotated values. Can be done?

we use this for rotate desing
Dim Grados As Single
Grados = Me.Txt_Rotar.Text
'visualization must be completed before rotation
vDrawing.Draw(Me.Pct_Visor.CreateGraphics(), New RectangleF())
vDrawing.Rotate(CADImport.FaceModule.Axes.Z, Grados) 'rotate by 90 degrees
vDrawing.BackgroundColor = Color.DimGray
vDrawing.DefaultColor = Color.White
vDrawing.GetExtents()
' adjusting visualization sizes to the control area:
Dim vRect As RectangleF
Dim vRatio As Double = vDrawing.AbsHeight * Pct_Visor.ClientSize.Width / (vDrawing.AbsWidth * Pct_Visor.ClientSize.Height)
If vRatio > 1 Then
vRect = New RectangleF(0, 0, (Pct_Visor.ClientSize.Width / vRatio), Pct_Visor.ClientSize.Height)
Else
vRect = New RectangleF(0, 0, Pct_Visor.ClientSize.Width, (Pct_Visor.ClientSize.Height * vRatio))
End If
'---------------------------------------------------
vDrawing.Draw(Pct_Visor.CreateGraphics(), vRect)

after doing this we need to update the x and y values of all the points of the entities
it is posible?

Thanks

Re: Rotate 2d desing and uddate X and Y point value

Posted: 17 Apr 2020, 19:05
by support
Hello,

CADImage.Rotate doesn't recalculate the coordinates of entities, it changes parameters of the active VPORT that affects a model space view. Instead of using the CADImage.Rotate method, you should apply a static DPoint.Rotate method to all the points of the entity you want to rotate. For example:

Code: Select all

private void RotatePolyline(CADImage cadImage, CADLWPolyLine poly, double angle, DPoint center)
{
    foreach (CADVertex vertex in poly.Vertexes)
      vertex.Point = DPoint.Rotate(vertex.Point, center, false, angle);
    cadImage.Converter.Loads(poly);
}
Mikhail

Re: Rotate 2d desing and uddate X and Y point value

Posted: 21 Apr 2020, 19:22
by ditel
Thanks