Esempio n. 1
0
        public void Create_Mullion_Dimension()
        {
            Document   doc   = this.ActiveUIDocument.Document;
            UIDocument uidoc = this.ActiveUIDocument;

            Transaction t = new Transaction(doc, "script");

            t.Start();
            if (uidoc.ActiveView.SketchPlane == null)
            {
                Plane       plane = new Plane(uidoc.ActiveView.ViewDirection, uidoc.ActiveView.Origin);
                SketchPlane sp    = SketchPlane.Create(doc, plane);
                uidoc.ActiveView.SketchPlane = sp;
                uidoc.ActiveView.HideActiveWorkPlane();
            }
            t.Commit();

            Options opt = doc.Application.Create.NewGeometryOptions();

            opt.ComputeReferences = true;

            IList <Face>   hfaces           = new List <Face>();
            IList <Face>   vfaces           = new List <Face>();
            ReferenceArray referenceArray_h = new ReferenceArray();
            ReferenceArray referenceArray_v = new ReferenceArray();

            ISelectionFilter mullionfilter = new MullionSelectionFilter();

            IList <Element> selec = uidoc.Selection.PickElementsByRectangle(mullionfilter);

            foreach (Element e in uidoc.Selection.PickElementsByRectangle(mullionfilter))
            {
                selec.Add(e);
            }

            foreach (Mullion mul in selec)
            {
                if (mul.HandOrientation.Z == 1 || mul.HandOrientation.Z == -1)

                {
                    GeometryElement geo = mul.get_Geometry(opt);

                    foreach (GeometryObject geoObject in geo)
                    {
                        GeometryInstance instance = geoObject as GeometryInstance;

                        foreach (GeometryObject instObj in instance.SymbolGeometry)
                        {
                            Solid solid = instObj as Solid;
                            foreach (Face face in solid.Faces)
                            {
                                if (face.ComputeNormal(new UV(0, 0)).X == 1 || face.ComputeNormal(new UV(0, 0)).X == -1)
                                {
                                    referenceArray_h.Append(face.Reference);
                                }
                            }
                        }
                    }
                }

                if (mul.HandOrientation.X == 1 || mul.HandOrientation.X == -1 || mul.HandOrientation.Y == -1 || mul.HandOrientation.Y == 1)

                {
                    GeometryElement geo = mul.get_Geometry(opt);

                    foreach (GeometryObject geoObject in geo)
                    {
                        GeometryInstance instance = geoObject as GeometryInstance;

                        foreach (GeometryObject instObj in instance.SymbolGeometry)
                        {
                            Solid solid = instObj as Solid;
                            foreach (Face face in solid.Faces)
                            {
                                if (face.ComputeNormal(new UV(0, 0)).X == 1 || face.ComputeNormal(new UV(0, 0)).X == -1)
                                {
                                    referenceArray_v.Append(face.Reference);
                                }
                            }
                        }
                    }
                }
            }



            XYZ pnt = uidoc.Selection.PickPoint(ObjectSnapTypes.None);

            try
            {
                XYZ up = pnt + uidoc.ActiveView.UpDirection;

                XYZ right = pnt + uidoc.ActiveView.RightDirection;


                Line newLine_v = Line.CreateBound(pnt, right);
                Line newLine_h = Line.CreateBound(pnt, up);

                using (Transaction tr = new Transaction(doc, "dim"))
                {
                    tr.Start();
                    Dimension newDimension_h = doc.Create.NewDimension(doc.ActiveView, newLine_h, referenceArray_h);
                    Dimension newDimension_v = doc.Create.NewDimension(doc.ActiveView, newLine_v, referenceArray_v);

                    uidoc.ActiveView.HideActiveWorkPlane();
                    tr.Commit();
                }
            }
            // catch the exceptions
            catch
            {
                TaskDialog.Show("11", "script error ask Hongseok");
            }
        }
Esempio n. 2
0
        public void Create_V_Mullion_Dimension()
        {
            Document   doc   = this.ActiveUIDocument.Document;
            UIDocument uidoc = this.ActiveUIDocument;

            Options opt = doc.Application.Create.NewGeometryOptions();

            opt.ComputeReferences = true;

            IList <Face>   vfaces           = new List <Face>();
            ReferenceArray referenceArray_v = new ReferenceArray();

            ISelectionFilter mullionfilter = new MullionSelectionFilter();

            foreach (Element mul in uidoc.Selection.PickElementsByRectangle(mullionfilter))
            {
                GeometryElement geo = mul.get_Geometry(opt);

                foreach (GeometryObject geoObject in geo)
                {
                    GeometryInstance instance = geoObject as GeometryInstance;

                    foreach (GeometryObject instObj in instance.SymbolGeometry)
                    {
                        Solid solid = instObj as Solid;
                        foreach (Face face in solid.Faces)
                        {
                            if (face.ComputeNormal(new UV(0, 0)).X == 1 || face.ComputeNormal(new UV(0, 0)).X == -1)
                            {
                                referenceArray_v.Append(face.Reference);
                            }
                        }
                    }
                }
            }



            XYZ pnt = uidoc.Selection.PickPoint(ObjectSnapTypes.None);

            try
            {
                XYZ p1 = pnt + new XYZ(0, 0, 1);
                XYZ p2 = pnt + new XYZ(0, 0, -1);
                XYZ p3 = pnt + new XYZ(1, 0, 0);
                XYZ p4 = pnt + new XYZ(-1, 0, 0);

                Line newLine_v = Line.CreateBound(p3, p4);

                using (Transaction t = new Transaction(doc, "dim"))
                {
                    t.Start();
                    Dimension newDimension_v = doc.Create.NewDimension(doc.ActiveView, newLine_v, referenceArray_v);
                    t.Commit();
                }
            }
            // catch the exceptions
            catch
            {
                TaskDialog.Show("11", "script error ask Hongseok");
            }
        }