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

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

            opt.ComputeReferences = true;

            ReferenceArray referenceArray = new ReferenceArray();

            ISelectionFilter horwallfilter = new HorWallSelectionFilter();

            foreach (Element wall in uidoc.Selection.PickElementsByRectangle())
            {
                GeometryElement geo = wall.get_Geometry(opt);
                foreach (GeometryObject objects in geo)
                {
                    Solid solid = objects as Solid;
                    foreach (Face face in solid.Faces)
                    {
                        if (face.ComputeNormal(new UV(0, 0)).Y == 1 || face.ComputeNormal(new UV(0, 0)).Y == -1)
                        {
                            referenceArray.Append(face.Reference);
                        }
                    }
                }
            }


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

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

                Line newLine2 = Line.CreateBound(p1, p2);

                using (Transaction t = new Transaction(doc, "dim"))
                {
                    t.Start();
                    Dimension newDimension = doc.Create.NewDimension(doc.ActiveView, newLine2, referenceArray);
                    t.Commit();
                }
            }
            // catch the exceptions
            catch
            {
                TaskDialog.Show("11", "script error ask Hongseok");
            }
        }
Esempio n. 2
0
        public void IdentifyGeometry()
        {
            Document   doc   = this.ActiveUIDocument.Document;
            UIDocument uidoc = this.ActiveUIDocument;

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

            opt.ComputeReferences = true;

            ReferenceArray referenceArray = new ReferenceArray();

            ISelectionFilter horwallfilter = new HorWallSelectionFilter();

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


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

                    foreach (GeometryObject instObj in instance.SymbolGeometry)
                    {
                        if (instObj is Curve)
                        {
                            TaskDialog.Show("11", "Symbol Geometry is Curve");
                        }
                        else if (instObj is PolyLine)
                        {
                            TaskDialog.Show("11", "Symbol Geometry is Polyline");
                        }
                        else if (instObj is Solid)
                        {
                            TaskDialog.Show("11", "Symbol Geometry is Solid");
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public void CreateLegendComponentDimension()
        {
            Document   doc   = this.ActiveUIDocument.Document;
            UIDocument uidoc = this.ActiveUIDocument;

            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 horwallfilter = new HorWallSelectionFilter();

            Element wall = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element));



            GeometryElement geo = wall.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)).Y == 1 || face.ComputeNormal(new UV(0, 0)).Y == -1)
                        {
                            hfaces.Add(face);
                        }
                        if (face.ComputeNormal(new UV(0, 0)).X == 1 || face.ComputeNormal(new UV(0, 0)).X == -1)
                        {
                            vfaces.Add(face);
                        }
                    }
                }
            }

            hfaces = hfaces.OrderBy(l => l.Evaluate(new UV(0, 0)).Y).ToList();
            vfaces = vfaces.OrderBy(l => l.Evaluate(new UV(0, 0)).X).ToList();

            for (int i = 0; i < hfaces.Count; i++)
            {
                if (i == hfaces.Count - 1)
                {
                    referenceArray_h.Append(hfaces[i].Reference);
                }
                else if (hfaces[i + 1].Evaluate(new UV(0, 0)).Y - hfaces[i].Evaluate(new UV(0, 0)).Y > 0.0001)
                {
                    referenceArray_h.Append(hfaces[i].Reference);
                }
            }

            for (int i = 0; i < vfaces.Count; i++)
            {
                if (i == vfaces.Count - 1)
                {
                    referenceArray_v.Append(vfaces[i].Reference);
                }
                else if (vfaces[i + 1].Evaluate(new UV(0, 0)).X - vfaces[i].Evaluate(new UV(0, 0)).X > 0.0001)
                {
                    referenceArray_v.Append(vfaces[i].Reference);
                }
            }



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

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

                Line newLine_h = Line.CreateBound(p1, p2);
                Line newLine_v = Line.CreateBound(p3, p4);

                using (Transaction t = new Transaction(doc, "dim"))
                {
                    t.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);
                    t.Commit();
                }
            }
            // catch the exceptions
            catch
            {
                TaskDialog.Show("11", "script error ask Hongseok");
            }
        }