Exemplo n.º 1
0
        /// <summary>
        /// 获取 线族
        /// </summary>
        public static FamilySymbol GetLineFamily(this PAATextType type, Document doc)
        {
            switch (type)
            {
            case PAATextType.Option1:
                return(PAAContext.Get_MultipleLineOnLine(doc));

            case PAATextType.Option2:
                return(PAAContext.Get_MultipleLineOnEdge(doc));

            default:
                throw new NotImplementedException("暂不支持该类型");
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 保存
 /// </summary>
 /// <param name="doc"></param>
 public void Save(Document doc)
 {
     PAAContext.SaveCollection(doc);
 }
Exemplo n.º 3
0
        public void Execute(UpdaterData updateData)
        {
            try
            {
                if (PAAContext.IsEditing == true)
                {
                    PAAContext.IsEditing = false;
                    return;
                }
                var        document      = updateData.GetDocument();
                var        edits         = updateData.GetModifiedElementIds();
                var        collection    = PAAContext.GetCollection(document);
                List <int> movedEntities = new List <int>();
                foreach (var changeId in edits)
                {
                    PAAModel model = null;

                    #region 单管 主体 重新生成
                    var targetMoved = collection.Data.FirstOrDefault(c => c.TargetId == changeId);
                    if (targetMoved != null)
                    {
                        model = targetMoved;
                        if (movedEntities.Contains(model.TargetId.IntegerValue))
                        {
                            continue;
                        }
                        var creater        = PAAContext.Creator;
                        var target         = document.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);
                        var offset         = pMiddle - model.TargetLocation;
                        offset.ToSameZ(new XYZ(0, 0, 0));
                        model.BodyStartPoint += offset;
                        model.BodyEndPoint   += offset;
                        model.LeafEndPoint   += offset;
                        //必要族
                        model.Document       = document;
                        model.IsRegenerate   = true;
                        model.RegenerateType = RegenerateType.BySingle;
                        if (!PAAContext.Creator.Regenerate(model))
                        {
                            collection.Data.Remove(model);
                        }
                        movedEntities.Add(model.TargetId.IntegerValue);
                        //PAAContext.IsEditing = true;//重新生成无需避免移动导致的重复触发
                        continue;
                    }
                    #endregion

                    #region 多管 主体 重新生成
                    targetMoved = collection.Data.FirstOrDefault(c => c.TargetIds != null && c.TargetIds.Contains(changeId));
                    if (targetMoved != null)
                    {
                        model = targetMoved;
                        if (movedEntities.Contains(changeId.IntegerValue))
                        {
                            continue;
                        }
                        model.Document       = document;
                        model.IsRegenerate   = true;
                        model.RegenerateType = RegenerateType.ByMultipleTarget;
                        if (!PAAContext.Creator.Regenerate(model))
                        {
                            collection.Data.Remove(model);
                        }
                        movedEntities.AddRange(model.TargetIds.Select(c => c.IntegerValue));
                        //PAAContext.IsEditing = true;//重新生成无需避免移动导致的重复触发
                        continue;
                    }
                    #endregion

                    #region 根据 标注 重新生成
                    var textMoved = collection.Data.FirstOrDefault(c => c.AnnotationId == changeId);
                    if (textMoved != null)
                    {
                        model = textMoved;
                        if (movedEntities.Contains(model.TargetId.IntegerValue))
                        {
                            continue;
                        }
                        var creater    = PAAContext.Creator;
                        var annotation = document.GetElement(changeId) as IndependentTag;
                        var offset     = annotation.TagHeadPosition - model.AnnotationLocation;
                        offset.ToSameZ(new XYZ(0, 0, 0));
                        model.BodyEndPoint  += offset;
                        model.LeafEndPoint  += offset;
                        model.Document       = document;
                        model.IsRegenerate   = true;
                        model.RegenerateType = RegenerateType.BySingle;
                        if (!PAAContext.Creator.Regenerate(model))
                        {
                            collection.Data.Remove(model);
                        }
                        movedEntities.Add(model.TargetId.IntegerValue);
                        //PAAContext.IsEditing = true;//重新生成无需避免移动导致的重复触发
                        continue;
                    }
                    #endregion

                    #region 根据Line重新生成
                    var lineMoved = collection.Data.FirstOrDefault(c => c.LineId == changeId);
                    if (lineMoved != null)
                    {
                        model = lineMoved;
                        bool isExisted = false;
                        foreach (var TargetId in model.TargetIds)
                        {
                            if (movedEntities.Contains(TargetId.IntegerValue))
                            {
                                isExisted = true;
                                break;
                            }
                        }
                        if (isExisted)
                        {
                            continue;
                        }
                        model.Document       = document;
                        model.IsRegenerate   = true;
                        model.RegenerateType = RegenerateType.ByMultipleLine;
                        if (PAAContext.Creator.Regenerate(model))
                        {
                            PAAContext.IsEditing  = true;
                            PAAContext.IsDeleting = true;
                        }
                        else
                        {
                            collection.Data.Remove(model);
                        }
                        movedEntities.AddRange(model.TargetIds.Select(c => c.IntegerValue));
                        //var line0 = document.GetElement(model.LineIds[0]);
                        //var pStart = (line0.Location as LocationCurve).Curve.GetEndPoint(0);
                        //PAAContext.Creator.Regenerate(document, model, target, pStart - model.BodyStartPoint);
                        //movedEntities.Add(model.TargetId.IntegerValue);
                        ////CSAContext.IsEditing = true;//重新生成无需避免移动导致的重复触发
                        continue;
                    }
                    #endregion
                }
                PAAContext.SaveCollection(document);
            }
            catch (Exception ex)
            {
                VLLogHelper.Error(ex);
            }
        }
Exemplo n.º 4
0
        public XYZ VerticalVector = null; //坐标定位,垂直于标注对象
        public FamilySymbol GetAnnotationFamily(Document doc, ElementId targetId)
        {
            switch (AnnotationType)
            {
            case PAAAnnotationType.SPL:
                switch (TargetType)
                {
                case PAATargetType.Pipe:
                    return(PAAContext.GetSPLTag_Pipe(doc));

                case PAATargetType.Duct:
                    if (IsRoundDuct(doc.GetElement(targetId)))
                    {
                        return(PAAContext.GetSPLTag_Duct_Round(doc));
                    }
                    else
                    {
                        return(PAAContext.GetSPLTag_Duct_Rectangle(doc));
                    }

                case PAATargetType.CableTray:
                    return(PAAContext.GetSPLTag_CableTray(doc));

                case PAATargetType.Conduit:
                default:
                    throw new NotImplementedException("暂不支持");
                }

            case PAAAnnotationType.SL:
                switch (TargetType)
                {
                case PAATargetType.Pipe:
                    return(PAAContext.GetSLTag_Pipe(doc));

                case PAATargetType.Duct:
                    return(PAAContext.GetSLTag_Duct(doc));

                case PAATargetType.CableTray:
                    return(PAAContext.GetSLTag_CableTray(doc));

                case PAATargetType.Conduit:
                default:
                    throw new NotImplementedException("暂不支持");
                }

            case PAAAnnotationType.PL:
                switch (TargetType)
                {
                case PAATargetType.Pipe:
                    return(PAAContext.GetPLTag_Pipe(doc));

                case PAATargetType.Duct:
                    if (IsRoundDuct(doc.GetElement(targetId)))
                    {
                        return(PAAContext.GetPLTag_Duct_Round(doc));
                    }
                    else
                    {
                        return(PAAContext.GetPLTag_Duct_Rectangle(doc));
                    }

                case PAATargetType.CableTray:
                    return(PAAContext.GetPLTag_CableTray(doc));

                case PAATargetType.Conduit:
                default:
                    throw new NotImplementedException("暂不支持");
                }

            case PAAAnnotationType.SP:
                switch (TargetType)
                {
                case PAATargetType.Pipe:
                    throw new NotImplementedException("管道无该类型");

                case PAATargetType.Duct:
                    if (IsRoundDuct(doc.GetElement(targetId)))
                    {
                        return(PAAContext.GetSPTag_Duct_Round(doc));
                    }
                    else
                    {
                        return(PAAContext.GetSPTag_Duct_Rectangle(doc));
                    }

                case PAATargetType.CableTray:
                    return(PAAContext.GetSPTag_CableTray(doc));

                case PAATargetType.Conduit:
                default:
                    throw new NotImplementedException("暂不支持");
                }

            default:
                throw new NotImplementedException("暂不支持该类型");
            }
        }