private static bool GenerateSingle_LeftOrMiddle(PAAModel model) { Document doc = model.Document; View view = doc.ActiveView; var target = doc.GetElement(model.TargetId); var line = (target.Location as LocationCurve).Curve as Line; model.UpdateVectors(line); var p0 = line.GetEndPoint(0); var p1 = line.GetEndPoint(1); switch (model.TextType) { case PAATextType.Option1: var location = (p0 + p1) / 2; model.UpdateLineWidth(target); location = location - model.LineWidth / 2 * model.ParallelVector; IndependentTag subTag = doc.Create.NewTag(view, doc.GetElement(model.TargetId), false, TagMode.TM_ADDBY_CATEGORY, TagOrientation.Horizontal, location); subTag.ChangeTypeId(model.GetAnnotationFamily(doc, model.TargetId).Id); break; case PAATextType.Option2: //location = p0.GetLengthBySide(model.ParallelVector) > p1.GetLengthBySide(model.ParallelVector) ? p1 : p0;//左上角 location = (p0 + p1) / 2; model.UpdateLineWidth(target); location = location - model.LineWidth / 2 * model.ParallelVector; location += model.CurrentFontHeight * model.VerticalVector; subTag = doc.Create.NewTag(view, doc.GetElement(model.TargetId), false, TagMode.TM_ADDBY_CATEGORY, TagOrientation.Horizontal, location); subTag.ChangeTypeId(model.GetAnnotationFamily(doc, model.TargetId).Id); break; default: break; } return(false); }
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); }