Esempio n. 1
0
            public BlockReference GetRedirectBlockReferenceCopy(BlockReference br, Point3d directionPoint)
            {
                using (Transaction trans = Tools.StartTransaction())
                {
                    br = (BlockReference)br.Id.GetObject(OpenMode.ForRead, true, true);
                    double ang = 0d;
                    if (Mode == DirectionMode.Horizontal)
                    {
                        ang = br.BlockTransform.CoordinateSystem3d.Xaxis.GetAngleTo(br.Position.GetVectorTo(directionPoint));
                    }
                    else
                    {
                        ang = br.BlockTransform.CoordinateSystem3d.Yaxis.GetAngleTo(br.Position.GetVectorTo(directionPoint));
                    }

                    Polyline arrow = (Polyline)this.ArrowLine.Clone();
                    arrow.AddVertexAt(0, this.Origin);
                    arrow.AddVertexAt(4, new Point3d(
                                          arrow.EndPoint.X + arrow.GetFirstDerivative(0d).X *defSpaceLength,
                                          arrow.EndPoint.Y + arrow.GetFirstDerivative(0d).Y *defSpaceLength,
                                          arrow.EndPoint.Z));
                    arrow.TransformBy(br.BlockTransform);


                    if (Math.Abs(ang) > Math.PI / 2d)
                    {
                        Matrix3d mat;
                        if (this.Mode == DirectionMode.Horizontal)
                        {
                            Vector3d vector;
                            if (br.BlockTransform.CoordinateSystem3d.Xaxis.X >= 0)
                            {
                                vector = br.Position - arrow.EndPoint;
                            }
                            else
                            {
                                vector = arrow.EndPoint - br.Position;
                            }
                            mat = Matrix3d.Displacement(vector.MultiplyBy(br.BlockTransform.CoordinateSystem3d.Xaxis.X));
                        }
                        else
                        {
                            Vector3d vector;
                            if (br.BlockTransform.CoordinateSystem3d.Yaxis.Y >= 0)
                            {
                                vector = br.Position - arrow.EndPoint;
                            }
                            else
                            {
                                vector = arrow.EndPoint - br.Position;
                            }
                            mat = Matrix3d.Displacement(vector.MultiplyBy(br.BlockTransform.CoordinateSystem3d.Yaxis.Y));
                        }
                        //var anBr = br.GetAnonymClone(br.Position.TransformBy(mat)).GetObjectForWrite<BlockReference>();
                        //br = (BlockReference)anBr.Clone();
                        //anBr.Erase(true);
                        //br.InnerTransform(mat);
                        //return (BlockReference)br.GetTransformedCopy(mat);
                        return((BlockReference)br.InnerTransform2(mat));
                    }
                    else
                    {
                        return(null);
                    }
                }
            }