PolyLine2D - Moves after applying a Normal

PolyLine2D - Moves after applying a Normal

Anonymous
Not applicable
545 Views
2 Replies
Message 1 of 3

PolyLine2D - Moves after applying a Normal

Anonymous
Not applicable

I am creating a a PolyLine2D that is perpendicular to 2 points that are selected by the user.

I have created a normal, in one of my test cases this is -0.998174459224936,-0.060396597180692,0

When this is applied i.e PL.Normal = ObjN the PolyLine is created in offset from the required location.

(note it is parrallel to the 2 points).

 

How do I need to Transform the PolyLine 2D to the correct location?

 

The full function is drawing the outline of and I beam as a polyline, creating a region and extruding to a solid3d.

 

Thanks in Advance

Martin

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

Anonymous
Not applicable

Here is the full function code

 

   Function Draw_I(ShapeData As StructureFeasol.SelectedShape, _
               points As Geometry.Point3dCollection, _
               ByVal LayerName As String) As ObjectId

        Dim DOC As Document = Application.DocumentManager.MdiActiveDocument
        Dim DB As Database = DOC.Database
        Dim fcn As String = "Shapes2D.Draw_I"
        Dim SH As StructureFeasol.Shape = ShapeData.Shape
        Dim ObjID As ObjectId
        LayerMake.AddLayer(LayerName)
        Using tr As Transaction = DB.TransactionManager.StartTransaction()
            Dim BT As BlockTable
            BT = tr.GetObject(DB.BlockTableId, OpenMode.ForRead)
            ''
            Dim btr As BlockTableRecord
            btr = tr.GetObject(BT(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
            ''
            Dim ctr As Geometry.Point3d = points(0)
            Dim nrm As Geometry.Point3d = points(1)
            ''
            Dim x As Double = nrm.X - ctr.X
            Dim y As Double = nrm.Y - ctr.Y
            Dim z As Double = nrm.Z - ctr.Z
            Dim ObjN As New Geometry.Vector3d(x, y, z)

            ''
            Dim ctr2 As Geometry.Point3d = ctr 'TODO Modify for Insert Point
            Dim Ang As Double = ShapeData.Rotation
            Dim PTS As New Geometry.Point3dCollection
            Dim ISflg As Double = (SH.Width - SH.WebThick) / 2.0
            Dim ISweb As Double = SH.Depth - (SH.FlgThick / 2.0)
            PTS.Add(New Geometry.Point3d(ctr2.X + SH.WebThick / 2.0, _
                                         ctr2.Y + SH.Depth / 2.0 - SH.FlgThick, _
                                         ctr2.Z))
            PTS.Add(PointCalculating.PolarPoints(PTS(0), (Ang + 0.0) * Deg2Rad, ISflg))
            PTS.Add(PointCalculating.PolarPoints(PTS(1), (Ang + 90.0) * Deg2Rad, SH.FlgThick))
            PTS.Add(PointCalculating.PolarPoints(PTS(2), (Ang + 180.0) * Deg2Rad, SH.Width))
            PTS.Add(PointCalculating.PolarPoints(PTS(3), (Ang + 270.0) * Deg2Rad, SH.FlgThick))
            PTS.Add(PointCalculating.PolarPoints(PTS(4), (Ang + 0.0) * Deg2Rad, ISflg))
            PTS.Add(PointCalculating.PolarPoints(PTS(5), (Ang + 270.0) * Deg2Rad, ISweb))
            PTS.Add(PointCalculating.PolarPoints(PTS(6), (Ang + 180.0) * Deg2Rad, ISflg))
            PTS.Add(PointCalculating.PolarPoints(PTS(7), (Ang + 270.0) * Deg2Rad, SH.FlgThick))
            PTS.Add(PointCalculating.PolarPoints(PTS(8), (Ang + 0.0) * Deg2Rad, SH.Width))
            PTS.Add(PointCalculating.PolarPoints(PTS(9), (Ang + 90.0) * Deg2Rad, SH.FlgThick))
            PTS.Add(PointCalculating.PolarPoints(PTS(10), (Ang + 180.0) * Deg2Rad, ISflg))
            ''
            Dim PL As Polyline2d = New Polyline2d(Poly2dType.SimplePoly, PTS, 0.0, True, 0.0, 0.0, Nothing)
            PL.Normal = ObjN.GetNormal
            PL.TransformBy(DOC.Editor.CurrentUserCoordinateSystem)

            ObjID = btr.AppendEntity(PL)
            tr.AddNewlyCreatedDBObject(PL, True)
            tr.Commit()
        End Using
        Return ObjID
    End Function

 

0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

My solution was to rotate the object.

I did this in two stages - About the ZAxis and about a Vector perpendicular to what I thought the normal should be.

0 Likes