Beispiel #1
0
        public void CreateTextNote(Document doc, CSAZDimCallout dim, Selection sel, ref TextNote textNote)
        {
            var    typetextnote      = (from TextNoteType x in new FilteredElementCollector(doc).OfClass(typeof(TextNoteType)) where x.Name == "3/32\" Arial" select x).First();
            XYZ    Point             = sel.PickPoint();
            double SpaceToStartPoint = Point.DistanceTo(dim.Startpoint);
            double SpaceToEndPoint   = Point.DistanceTo(dim.Endpoint);

            if (SpaceToEndPoint < SpaceToStartPoint)
            {
                using (Transaction tran = new Transaction(doc, "Create Text"))
                {
                    tran.Start();
                    textNote = TextNote.Create(doc, doc.ActiveView.Id, dim.Endpoint, dim.Numbersegment + " " + dim.ControlMark, typetextnote.Id);

                    tran.Commit();
                }
            }
            else
            {
                using (Transaction tran = new Transaction(doc, "Create Text"))
                {
                    tran.Start();
                    textNote = TextNote.Create(doc, doc.ActiveView.Id, dim.Startpoint, dim.Numbersegment + " " + dim.ControlMark, typetextnote.Id);
                    double value = textNote.Width;
                    XYZ    p1    = Timdiemdimngang(dim.Startpoint, dim.VectorDirection, value);
                    doc.Create.NewDetailCurve(doc.ActiveView, Line.CreateBound(dim.Startpoint, p1));
                    tran.Commit();
                }
            }
        }
Beispiel #2
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication application      = commandData.Application;
            UIDocument    activeUIDocument = application.ActiveUIDocument;
            Application   application2     = application.Application;
            Document      doc = activeUIDocument.Document;
            Selection     sel = activeUIDocument.Selection;
            //while (iscontinue)
            //{
            //    try
            //    {
            //        Reference reference = sel.PickObject(ObjectType.Element,/* new Filterdimention(),*/ "Select Dimension");
            //        Dimension dimension = doc.GetElement(reference) as Dimension;
            //        CSAZDimCallout dim = new CSAZDimCallout(doc, dimension, new XYZ(1, 0, 0));
            //        CreateTextNote(doc, dim);
            //    }
            //    catch
            //    {
            //        iscontinue = false;
            //    }
            //}
            Reference      reference = sel.PickObject(ObjectType.Element, /* new Filterdimention(),*/ "Select Dimension");
            Dimension      dimension = doc.GetElement(reference) as Dimension;
            CSAZDimCallout dim       = new CSAZDimCallout(doc, dimension, new XYZ(1, 0, 0));
            TextNote       textNote  = null;

            CreateTextNote(doc, dim, sel, ref textNote);
            Transaction tran = new Transaction(doc, "Create Line");

            tran.Start();
            PLane3D pLane3D = new PLane3D(doc.ActiveView.Origin, doc.ActiveView.ViewDirection);
            double  value   = textNote.GetMaximumAllowedWidth();
            XYZ     p1      = Timdiemdimngang(dim.Endpoint, dim.VectorDirection, 3);
            var     dline   = doc.Create.NewDetailCurve(doc.ActiveView, Line.CreateBound(pLane3D.ProjectPointOnPlane(dim.Endpoint), pLane3D.ProjectPointOnPlane(p1)));

            tran.Commit();
            return(Result.Succeeded);
        }
Beispiel #3
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;

            uidoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;

            doc = uidoc.Document;
            sel = uidoc.Selection;
            FamilySymbol symbolembed1 = null;
            FamilySymbol symbolembed2 = null;
            FamilySymbol symbolrebar1 = null;
            FamilySymbol symbolrebar2 = null;

            Findfamilysymbol(doc, ref symbolembed1, ref symbolembed2, ref symbolrebar1, ref symbolrebar2);
            while (iscontinue)
            {
                Transaction tran = new Transaction(doc, "Callout dimension");
                tran.Start();
                try
                {
                    Reference      reference = sel.PickObject(ObjectType.Element, /* new Filterdimention(),*/ "Select Dimension");
                    Dimension      dimension = doc.GetElement(reference) as Dimension;
                    CSAZDimCallout dim       = new CSAZDimCallout(doc, dimension, new XYZ(1, 0, 0));
                    if (dim.Type == "EMBED")
                    {
                        Direction direction = dim.Direction;
                        switch (direction)
                        {
                        case Direction.Horizontal:
                            PasteSymbolEmbed(doc, symbolembed1, sel, dim);
                            break;

                        case Direction.Vertical:
                            PasteSymbolEmbed(doc, symbolembed2, sel, dim);
                            break;

                        case Direction.Undefine:
                            PasteSymbolEmbed(doc, symbolembed1, sel, dim);
                            break;

                        default:
                            break;
                        }
                    }
                    if (dim.Type == "REBAR")
                    {
                        Direction direction = dim.Direction;
                        switch (direction)
                        {
                        case Direction.Horizontal:
                            PasteSymbolRebar(doc, symbolrebar1, sel, dim);
                            break;

                        case Direction.Vertical:
                            PasteSymbolRebar(doc, symbolrebar2, sel, dim);
                            break;

                        case Direction.Undefine:
                            PasteSymbolRebar(doc, symbolrebar1, sel, dim);
                            break;

                        default:
                            break;
                        }
                    }
                }
                catch (Exception)
                {
                    this.iscontinue = false;
                }

                tran.Commit();
            }
            return(Result.Succeeded);
        }
Beispiel #4
0
        public void PasteSymbolRebar(Document doc, FamilySymbol familySymbol, Selection sel, CSAZDimCallout dim)
        {
            //XYZ p = dim.Endpoint - dim.Line.Direction * 3.8;
            XYZ     p       = null;
            XYZ     point   = sel.PickPoint();
            PLane3D pLane3D = new PLane3D(doc.ActiveView.Origin, doc.ActiveView.ViewDirection);
            XYZ     vp      = pLane3D.ProjectPointOnPlane(point);

            if (vp.DistanceTo(dim.Endpoint) > vp.DistanceTo(dim.Startpoint))
            {
                p = dim.Startpoint - dim.Line.Direction * 3;
            }
            else
            {
                p = dim.Endpoint + dim.Line.Direction * 2;
            }
            FamilyInstance element = doc.Create.NewFamilyInstance(p, familySymbol, doc.ActiveView);
            Parameter      p1      = element.LookupParameter("Part No.");

            p1.Set(dim.ControlMark);
            Parameter p2 = element.LookupParameter("TEXT 2");

            p2.Set(dim.Side);
            Parameter p3 = element.LookupParameter("TEXT 3");
            var       ty = string.Concat("CL", " ", "(", dim.Quality, ")");

            p3.Set(ty);
        }