Problem with polyline rotation and constrains
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have polyline objects (in 2d space) that I customized by adding a rotation and movement grips (using GripOverrules) these two work great. when I stretch movement grip, polyline would move as if I used the move command. When I stretch the rotation grip, the whole polyline would rotate around the StartPoint of the polyline. My polylines are all made of straight segments only.
Recently I tried to attach a block reference to to these polyline by using two geometric constrains, a coincident constrain (StartPoint to block reference center point constrain) and a parallel constrain (first polyline segment to a line in the block reference that contains the block center point). The move grip works fine, but the rotation grip would rotate the whole polyline but not the first segment and the block reference.
I switch parallel constrain with perpendicular and collinear but I still get the same behavior.
The strange thing is, this behavior doesn't always happen, sometimes I apply the constrains and they work as intended for few times then the break after 2-3 times of using the grip.
Also if I use Autocad's rotation command to rotate the polyline only about StartPoint, it also works as intended and it will rotate the block reference with it. Or if I grip stretch the second vertex of the polyline the behavior is correct again.
I Then tried to use a dimensional (angular) constrain instead of parallel constrain and setting the angle value to 0 to simulate same effect. this caused the same erroneous behavior.
I finally found a workaround to fix this behavior by setting a very small angle (0.1) to the angular constrain. this made the rotation grip work as intended.
The only problem I have with this solution is being much slower than using parallel constrain. I usually have about 200 polylines. and using coincident and parallel constrains doesn't show any performance issues. While having angular constrain slows the drawing dramatically.
the code I am using to rotate each polyline when the rotation grip is stretched is:
Matrix3d RotationMatrix = Matrix3d.Rotation(RotationAngle, Vector3d.ZAxis, new Point3d(new Plane(), StartPolylineSegment.StartPoint));
if (!Polyline.IsWriteEnabled)
Polyline.UpgradeOpen();
Polyline.TransformBy(RotationMatrix);Where Polyline is LWPOLYLINE and StartPolylineSegment is the first Line2dSegment
Any ideas why this behavior is happening?