Esempio n. 1
0
        //Tag by hand example
        public void tagRebar()
        {
            UIDocument uiDoc = this.ActiveUIDocument;

            Document doc = uiDoc.Document;

            ElementId myViewId = new ElementId(649704);

            View myView = doc.GetElement(myViewId) as View;


            ElementId myRebarId = new ElementId(813273);

            var rebarList = doc.GetElement(myRebarId);



            IList <ElementId> elementIds
                = new List <ElementId>();



            MultiReferenceAnnotationType type
                = doc.GetElement(new ElementId(413569)) as MultiReferenceAnnotationType;


            MultiReferenceAnnotationOptions options
                = new MultiReferenceAnnotationOptions(type);

            options.TagHeadPosition        = new XYZ(0, 100, 0);
            options.DimensionLineOrigin    = new XYZ(5, 5, 1);
            options.DimensionLineDirection = new XYZ(0, 1, 0);
            options.DimensionPlaneNormal   = myView.ViewDirection;
            options.SetElementsToDimension(elementIds);

            using (Transaction tran = new Transaction(doc))
            {
                tran.Start("Create_Rebar_Vertical");

                var mra = MultiReferenceAnnotation.Create(
                    doc, myView.Id, options);

                tran.Commit();
            }
        }
Esempio n. 2
0
        //Tag by hand example
        public void tagMultiRebar_PickBeam()
        {
            UIDocument uiDoc = this.ActiveUIDocument;

            Document doc = uiDoc.Document;


            View myView = doc.ActiveView;
            //Pick beam to get min max bound

            Reference myRefBeam = uiDoc.Selection.PickObject(ObjectType.Element, "Pick host beam...");
            Element   myBeam    = doc.GetElement(myRefBeam);



            BoundingBoxXYZ myBeam_BB = myBeam.get_BoundingBox(myView);

            XYZ minPointBeam    = myBeam_BB.Min;
            XYZ maxPointBeam    = myBeam_BB.Max;
            XYZ centerPointBeam = (minPointBeam + maxPointBeam) / 2;



            //Get all Rebar Set In Section of Beam

            List <List <Rebar> > myRebarListList = getListRebarSorted_2(myView, myBeam);


            int factorDelta = 5;

            foreach (Rebar myRebarSetBottom in myRebarListList[0])
            {
//				//Get bouding box of rebarSet
//				BoundingBoxXYZ myRebar_BB = myRebarSetBottom.get_BoundingBox(myView);
//
//				XYZ minPointRebar = myRebar_BB.Min;
//				XYZ maxPointRebar = myRebar_BB.Max;
//				XYZ centerPointRebar = (minPointRebar + maxPointRebar)/2;

                IList <ElementId> elementIds
                    = new List <ElementId>();

                elementIds.Add(myRebarSetBottom.Id);

                MultiReferenceAnnotationType type
                    = doc.GetElement(new ElementId(413569)) as MultiReferenceAnnotationType;


                MultiReferenceAnnotationOptions options
                    = new MultiReferenceAnnotationOptions(type);

                setCurrentViewAsWorkPlan();


                double deltaZ = 0.1;

                XYZ myPickPoint = new XYZ();
                myPickPoint = new XYZ(minPointBeam.X, minPointBeam.Y, minPointBeam.Z + (-1 * deltaZ * factorDelta));
//				if(centerPointRebar.Z<centerPointBeam.Z)
//				{
//					myPickPoint = new XYZ(minPointBeam.X, minPointBeam.Y, minPointBeam.Z + (-1*deltaZ*factorDelta));
//				}
//				else
//				{
//					myPickPoint = new XYZ(maxPointBeam.X, maxPointBeam.Y, maxPointBeam.Z + (deltaZ*factorDelta));
//				}



                //TaskDialog.Show("abc", "point picked: "+ myPickPoint.X + "; " + myPickPoint.Y + "; " +myPickPoint.Z);

                //			myPickPoint = new XYZ(-10, 57, -7.54);
                options.TagHeadPosition        = new XYZ(myPickPoint.X - 2, myPickPoint.Y - 2, myPickPoint.Z);
                options.DimensionLineOrigin    = new XYZ(myPickPoint.X, myPickPoint.Y, myPickPoint.Z);
                options.DimensionLineDirection = myView.RightDirection;
                options.DimensionPlaneNormal   = myView.ViewDirection;
                options.SetElementsToDimension(elementIds);


                using (Transaction tran = new Transaction(doc))
                {
                    tran.Start("Create_Rebar_Vertical");

                    MultiReferenceAnnotation myMRA = MultiReferenceAnnotation.Create(doc, myView.Id, options);


                    tran.Commit();
                }

                factorDelta = factorDelta + 5;
            }



            factorDelta = 5;
            foreach (Rebar myRebarSetBottom in myRebarListList[1])
            {
//				//Get bouding box of rebarSet
//				BoundingBoxXYZ myRebar_BB = myRebarSetBottom.get_BoundingBox(myView);
//
//				XYZ minPointRebar = myRebar_BB.Min;
//				XYZ maxPointRebar = myRebar_BB.Max;
//				XYZ centerPointRebar = (minPointRebar + maxPointRebar)/2;

                IList <ElementId> elementIds
                    = new List <ElementId>();

                elementIds.Add(myRebarSetBottom.Id);

                MultiReferenceAnnotationType type
                    = doc.GetElement(new ElementId(413569)) as MultiReferenceAnnotationType;


                MultiReferenceAnnotationOptions options
                    = new MultiReferenceAnnotationOptions(type);

                setCurrentViewAsWorkPlan();


                double deltaZ = 0.1;

                XYZ myPickPoint = new XYZ();
                myPickPoint = new XYZ(minPointBeam.X, minPointBeam.Y, maxPointBeam.Z + (1 * deltaZ * factorDelta));
//				if(centerPointRebar.Z<centerPointBeam.Z)
//				{
//					myPickPoint = new XYZ(minPointBeam.X, minPointBeam.Y, minPointBeam.Z + (-1*deltaZ*factorDelta));
//				}
//				else
//				{
//					myPickPoint = new XYZ(maxPointBeam.X, maxPointBeam.Y, maxPointBeam.Z + (deltaZ*factorDelta));
//				}



                //TaskDialog.Show("abc", "point picked: "+ myPickPoint.X + "; " + myPickPoint.Y + "; " +myPickPoint.Z);

                //			myPickPoint = new XYZ(-10, 57, -7.54);
                options.TagHeadPosition        = new XYZ(myPickPoint.X - 2, myPickPoint.Y - 2, myPickPoint.Z);
                options.DimensionLineOrigin    = new XYZ(myPickPoint.X, myPickPoint.Y, myPickPoint.Z);
                options.DimensionLineDirection = myView.RightDirection;
                options.DimensionPlaneNormal   = myView.ViewDirection;
                options.SetElementsToDimension(elementIds);


                using (Transaction tran = new Transaction(doc))
                {
                    tran.Start("Create_Rebar_Vertical");

                    MultiReferenceAnnotation myMRA = MultiReferenceAnnotation.Create(doc, myView.Id, options);


                    tran.Commit();
                }

                factorDelta = factorDelta + 5;
            }
        }
Esempio n. 3
0
        //Tag by hand example
        public void tagMultiRebar()
        {
            UIDocument uiDoc = this.ActiveUIDocument;

            Document doc = uiDoc.Document;


            View myView = doc.ActiveView;


            ElementId myRebarId = new ElementId(813273);


            var rebarSet = doc.GetElement(myRebarId);

            //Get bouding box of rebarSet
            BoundingBoxXYZ myRebar_BB = rebarSet.get_BoundingBox(myView);

            XYZ minPointRebar    = myRebar_BB.Min;
            XYZ maxPointRebar    = myRebar_BB.Max;
            XYZ centerPointRebar = (minPointRebar + maxPointRebar) / 2;


            IList <ElementId> elementIds
                = new List <ElementId>();

            elementIds.Add(rebarSet.Id);

            MultiReferenceAnnotationType type
                = doc.GetElement(new ElementId(413569)) as MultiReferenceAnnotationType;


            MultiReferenceAnnotationOptions options
                = new MultiReferenceAnnotationOptions(type);


            setCurrentViewAsWorkPlan();

            //Pick beam to get min max bound

            Reference      myRefBeam = uiDoc.Selection.PickObject(ObjectType.Element, "Pick host beam...");
            Element        myBeam    = doc.GetElement(myRefBeam);
            BoundingBoxXYZ myBeam_BB = myBeam.get_BoundingBox(myView);

            XYZ minPointBeam    = myBeam_BB.Min;
            XYZ maxPointBeam    = myBeam_BB.Max;
            XYZ centerPointBeam = (minPointBeam + maxPointBeam) / 2;

            double deltaZ      = 0.1;
            int    factorDelta = 1;
            XYZ    myPickPoint = new XYZ();

            if (centerPointRebar.Z < centerPointBeam.Z)
            {
                myPickPoint = new XYZ(minPointBeam.X, minPointBeam.Y, minPointBeam.Z + (-1 * deltaZ * factorDelta));
            }
            else
            {
                myPickPoint = new XYZ(maxPointBeam.X, maxPointBeam.Y, maxPointBeam.Z + (deltaZ * factorDelta));
            }



            TaskDialog.Show("abc", "point picked: " + myPickPoint.X + "; " + myPickPoint.Y + "; " + myPickPoint.Z);

//			myPickPoint = new XYZ(-10, 57, -7.54);
            options.TagHeadPosition        = new XYZ(myPickPoint.X + 5, myPickPoint.Y - 1, myPickPoint.Z);
            options.DimensionLineOrigin    = new XYZ(myPickPoint.X, myPickPoint.Y, myPickPoint.Z);
            options.DimensionLineDirection = new XYZ(0, 1, 0);
            options.DimensionPlaneNormal   = myView.ViewDirection;
            options.SetElementsToDimension(elementIds);


            using (Transaction tran = new Transaction(doc))
            {
                tran.Start("Create_Rebar_Vertical");

                MultiReferenceAnnotation myMRA = MultiReferenceAnnotation.Create(doc, myView.Id, options);


                tran.Commit();
            }
        }