Ejemplo n.º 1
0
        private bool GenerateMultiplePipe(PAAModel model)
        {
            Document doc  = model.Document;
            View     view = doc.GetElement(model.ViewId) as View;

            if (view == null)
            {
                return(false);
            }
            model.CalculateLocations();
            if (model.IsRegenerate)
            {
                model.Clear();
            }
            XYZ parallelVector    = model.ParallelVector;
            XYZ verticalVector    = model.VerticalVector;
            var pipeAndNodePoints = model.PipeAndNodePoints;
            //线 创建
            FamilyInstance line = doc.Create.NewFamilyInstance(model.TargetLocation, model.GetLineFamily(doc), view);
            //线 旋转处理
            LocationPoint locationPoint = line.Location as LocationPoint;

            locationPoint.RotateByXY(model.TargetLocation, model.VerticalVector);
            model.LineId = line.Id;
            UpdateLineParameters(model, pipeAndNodePoints, line, verticalVector);
            //标注 创建
            model.AnnotationIds = new List <ElementId>();
            for (int i = 0; i < pipeAndNodePoints.Count(); i++)
            {
                var subTag = doc.Create.NewTag(view, pipeAndNodePoints[i].Target, false, TagMode.TM_ADDBY_CATEGORY, TagOrientation.Horizontal, pipeAndNodePoints[i].AnnotationPoint);
                model.AnnotationIds.Add(subTag.Id);
            }
            return(true);
        }
Ejemplo n.º 2
0
        private static bool GenerateSinglePipe(PAAModel model)
        {
            Document doc  = model.Document;
            View     view = doc.GetElement(model.ViewId) as View;

            if (view == null)
            {
                return(false);
            }
            //主体
            var target         = doc.GetElement(model.TargetId);
            var targetLocation = target.Location as LocationCurve;
            var p0             = targetLocation.Curve.GetEndPoint(0);
            var p1             = targetLocation.Curve.GetEndPoint(1);
            var pMiddle        = new XYZ((p0.X + p1.X) / 2, (p0.Y + p1.Y) / 2, (p0.Z + p1.Z) / 2);

            model.TargetLocation = pMiddle;
            //线生成
            List <Line> lines = new List <Line>();

            model.CalculateLocations();                                            //计算内容定位
            lines.Add(Line.CreateBound(model.BodyStartPoint, model.BodyEndPoint)); //竖干线
            lines.Add(Line.CreateBound(model.BodyEndPoint, model.LeafEndPoint));   //斜支线
            model.LineIds = new List <ElementId>();
            foreach (var line in lines)
            {
                var lineElement = doc.Create.NewDetailCurve(view, line);
                model.LineIds.Add(lineElement.Id);
            }
            //文本生成
            IndependentTag subTag = doc.Create.NewTag(view, doc.GetElement(model.TargetId), false, TagMode.TM_ADDBY_CATEGORY, TagOrientation.Horizontal, model.AnnotationLocation);

            model.AnnotationId     = subTag.Id;
            subTag.TagHeadPosition = model.AnnotationLocation;
            subTag.ChangeTypeId(model.GetAnnotationFamily(doc, model.TargetId).Id);
            return(true);
        }