Пример #1
0
        public void Cutting(Document doc, List <FamilyInstance> listcut, List <FamilyInstance> listconn)
        {
            ProgressBarform progressBarform = new ProgressBarform(listconn.Count, "Cutting");

            progressBarform.Show();
            using (Transaction tran = new Transaction(doc, "Cut Void"))
            {
                tran.Start();
                foreach (var conn in listconn)
                {
                    progressBarform.giatri();
                    if (progressBarform.iscontinue == false)
                    {
                        break;
                    }
                    //var list = FindElementNearly(doc, conn, listcut);
                    foreach (var framming in listcut)
                    {
                        try
                        {
                            if (InstanceVoidCutUtils.CanBeCutWithVoid(framming))
                            {
                                InstanceVoidCutUtils.AddInstanceVoidCut(doc, framming, conn);
                            }
                        }
                        catch
                        {
                        }
                    }
                }
                tran.Commit();
            }
            progressBarform.Close();
        }
Пример #2
0
        public void DuplicateSheet(Document doc, List <ViewSheet> viewSheets)
        {
            ProgressBarform progressBarform = new ProgressBarform(viewSheets.Count, "Loading...");

            progressBarform.Show();
            foreach (ViewSheet sheet in viewSheets)
            {
                progressBarform.giatri();
                if (progressBarform.iscontinue == false)
                {
                    break;
                }
                FamilyInstance Tileblock = GetTileBlock(doc, sheet);
                using (Transaction tran = new Transaction(doc, "Dup"))
                {
                    tran.Start();
                    ViewSheet viewSheet = ViewSheet.Create(doc, Tileblock.GetTypeId());
                    viewSheet.Name = sheet.Name;
                    CopyViews(sheet, viewSheet);
                    CopyParameterValue(sheet, viewSheet);
                    tran.Commit();
                }
            }
            progressBarform.Close();
        }
Пример #3
0
        private void Doding(Document doc, List <FamilyInstance> listinstance, bool checklevelandgrid)
        {
            ProgressBarform progressBarform = new ProgressBarform(listinstance.Count, "Loading...");

            progressBarform.Show();
            foreach (var instance in listinstance)
            {
                progressBarform.giatri();
                if (progressBarform.iscontinue == false)
                {
                    break;
                }
                var Workplane = instance.get_Parameter(BuiltInParameter.SKETCH_PLANE_PARAM);
                if (Workplane != null)
                {
                    var value = Workplane.AsString();
                    if (checklevelandgrid)
                    {
                        if (!value.StartsWith("Reference Plane"))
                        {
                            listsource.Add(new GroupInstanceInfo(instance));
                        }
                    }
                    else
                    {
                        if (!value.StartsWith("Grid") && !value.StartsWith("Reference Plane") && !value.StartsWith("Level"))
                        {
                            listsource.Add(new GroupInstanceInfo(instance));
                        }
                    }
                }
            }
            progressBarform.Close();
            this._exEvent = ExternalEvent.Create((IExternalEventHandler) new CheckWorkPlaneEvent(this, doc));
            var form = new FrmCheckReference(this, doc);

            form.Show();
            form.ExEvent = this._exEvent;
        }
Пример #4
0
        public void ChangeName(Document doc)
        {
            List <ViewSheet> viewSheets      = GetViewSheets(doc);
            ProgressBarform  progressBarform = new ProgressBarform(viewSheets.Count, "Loading...");

            progressBarform.Show();
            foreach (ViewSheet sheet in viewSheets)
            {
                progressBarform.giatri();
                if (progressBarform.iscontinue == false)
                {
                    break;
                }
                var gi = sheet.GetAllPlacedViews();
                foreach (var i in gi)
                {
                    Element ele   = doc.GetElement(i);
                    View    view  = ele as View;
                    string  Sname = view.Name;
                    using (Transaction tran = new Transaction(doc, "Rename"))
                    {
                        tran.Start();
                        if (Sname.EndsWith("Copy 2"))
                        {
                            string name2 = Sname.Replace("Copy 2", "S");
                            view.Name = name2;
                        }
                        if (Sname.EndsWith("Copy 1"))
                        {
                            string name2 = Sname.Replace("Copy 1", "S");
                            view.Name = name2;
                        }
                        tran.Commit();
                    }
                }
            }
            progressBarform.Close();
        }
Пример #5
0
        public void CopyElements(Document doc, FamilyInstance familyInstance, List <FamilyInstance> listinstance, ICollection <ElementId> elementIds)
        {
            ICollection <ElementId> newlist         = new List <ElementId>();
            CopyPasteOptions        option          = new CopyPasteOptions();
            ProgressBarform         progressBarform = new ProgressBarform(listinstance.Count, "Loading...");

            progressBarform.Show();
            foreach (FamilyInstance source in listinstance)
            {
                progressBarform.giatri();
                if (progressBarform.iscontinue == false)
                {
                    break;
                }
                Transform transform  = TransformToCopy(source, familyInstance);
                Transform transform1 = Transform.CreateTranslation(transform.Origin);
                using (Transaction tran = new Transaction(doc, "copy"))
                {
                    tran.Start();
                    FailureHandlingOptions options       = tran.GetFailureHandlingOptions();
                    IgnoreProcess          ignoreProcess = new IgnoreProcess();
                    options.SetClearAfterRollback(true);
                    options.SetFailuresPreprocessor(ignoreProcess);
                    tran.SetFailureHandlingOptions(options);
                    try
                    {
                        newlist = ElementTransformUtils.CopyElements(doc, elementIds, doc, transform, option);
                        Remove_product(doc, newlist);
                    }
                    catch (Exception)
                    {
                    }
                    tran.Commit();
                }
            }
            progressBarform.Close();
        }
        public void Running(Document doc)
        {
            List <ViewSheet> ListSheets = GetAllSheetErection(doc);

            using (Transaction tran = new Transaction(doc, "Add Suffix ControlNumber"))
            {
                tran.Start();
                ProgressBarform progressBarform = new ProgressBarform(ListSheets.Count, "Running...");
                progressBarform.Show();
                foreach (ViewSheet sheet in ListSheets)
                {
                    progressBarform.giatri();
                    if (progressBarform.iscontinue == false)
                    {
                        break;
                    }
                    string      sheetNumber = sheet.SheetNumber;
                    List <View> Views       = GetAllViewPlaceOnSheet(doc, sheet);
                    foreach (View view in Views)
                    {
                        List <FamilyInstance> Products = GetAllProductInview(doc, view);
                        foreach (FamilyInstance product in Products)
                        {
                            FamilyInstance _product       = product.GetSuperInstances();
                            Parameter      Control_number = _product.LookupParameter("CONTROL_NUMBER");
                            if (Control_number != null)
                            {
                                Control_number.Set(sheetNumber + Control_number.AsString());
                            }
                        }
                    }
                }
                progressBarform.Close();
                tran.Commit();
            }
        }
Пример #7
0
        public void CopyElementsConnFlangeDtee(Document doc, FamilyInstance familyInstance, List <FamilyInstance> listinstance, ICollection <ElementId> elementIds, bool valuekey)
        {
            ICollection <ElementId> newlist  = new List <ElementId>();
            Parameter        pa1             = familyInstance.LookupParameter("Flange_Edge_Offset_Right");
            double           Flange_Right1   = pa1.AsDouble();
            Parameter        pa2             = familyInstance.LookupParameter("Flange_Edge_Offset_Left");
            double           Flange_Left1    = pa2.AsDouble();
            Parameter        pal             = familyInstance.LookupParameter("DIM_LENGTH");
            double           dim_length      = pal.AsDouble();
            var              f1              = elementIds.First();
            double           kl              = Nut(doc, familyInstance, f1);
            CopyPasteOptions option          = new CopyPasteOptions();
            ProgressBarform  progressBarform = new ProgressBarform(listinstance.Count, "Loading...");

            progressBarform.Show();
            foreach (FamilyInstance source in listinstance)
            {
                if (source.Id != familyInstance.Id)
                {
                    using (Transaction tran = new Transaction(doc, "Copy"))
                    {
                        tran.Start();
                        Transform transform1   = source.GetTransform();
                        Parameter pa3          = source.LookupParameter("Flange_Edge_Offset_Right");
                        double    Flange_Right = pa3.AsDouble();
                        ElementId sourceid     = source.GetTypeId();
                        Element   sourcetype   = doc.GetElement(sourceid);
                        Parameter sourcepa     = sourcetype.LookupParameter("DT_Stem_Spacing_Form");
                        Parameter pa4          = source.LookupParameter("Flange_Edge_Offset_Left");
                        double    Flange_Left  = pa4.AsDouble();
                        double    val1         = Flange_Right1 - Flange_Right;
                        double    val2         = Flange_Left1 - Flange_Left;
                        progressBarform.giatri();
                        if (progressBarform.iscontinue == false)
                        {
                            break;
                        }
                        Transform transform                  = TransformToCopy(source, familyInstance);
                        FailureHandlingOptions options       = tran.GetFailureHandlingOptions();
                        IgnoreProcess          ignoreProcess = new IgnoreProcess();
                        options.SetClearAfterRollback(true);
                        options.SetFailuresPreprocessor(ignoreProcess);
                        tran.SetFailureHandlingOptions(options);
                        try
                        {
                            newlist = ElementTransformUtils.CopyElements(doc, elementIds, doc, transform, option);
                            Remove_product(doc, newlist);
                        }
                        catch (Exception)
                        {
                        }
                        if (valuekey == true)
                        {
                            if (sourcepa == null)
                            {
                                if (val1 != 0 || val2 != 0)
                                {
                                    FamilyInstance    flatsource        = GetFlat(doc, familyInstance);
                                    FamilyInstance    flattarget        = GetFlat(doc, source);
                                    List <PlanarFace> planarFacessource = FlFaces(flatsource);
                                    List <PlanarFace> planarFacetarget  = FlFaces(flattarget);
                                    Element           elesource         = doc.GetElement(elementIds.First());
                                    double            spatarget         = 0;
                                    foreach (ElementId i in newlist)
                                    {
                                        Element       eletarget      = doc.GetElement(i);
                                        LocationPoint locationPoint2 = eletarget.Location as LocationPoint;
                                        XYZ           pointtarget    = locationPoint2.Point;
                                        spatarget = DistanceToMin(doc, source, planarFacetarget, pointtarget, kl);
                                        if (spatarget != 0)
                                        {
                                            break;
                                        }
                                    }
                                    if (spatarget != 0)
                                    {
                                        foreach (ElementId i in newlist)
                                        {
                                            XYZ point1 = new XYZ(0, 0, 0);
                                            point1 = point1 + transform1.BasisX * -spatarget;
                                            ElementTransformUtils.MoveElement(doc, i, point1);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (val2 > 0)
                                {
                                    foreach (ElementId i in newlist)
                                    {
                                        XYZ point1 = new XYZ(0, 0, 0);
                                        point1 = point1 + transform1.BasisX * -val2;
                                        ElementTransformUtils.MoveElement(doc, i, point1);
                                    }
                                }
                                else
                                {
                                    foreach (ElementId i in newlist)
                                    {
                                        XYZ point1 = new XYZ(0, 0, 0);
                                        point1 = point1 + transform1.BasisX * -val2;
                                        ElementTransformUtils.MoveElement(doc, i, point1);
                                    }
                                }
                            }
                        }
                        if (valuekey == false)
                        {
                            if (sourcepa == null)
                            {
                                if (val1 != 0 || val2 != 0)
                                {
                                    FamilyInstance    flatsource        = GetFlat(doc, familyInstance);
                                    FamilyInstance    flattarget        = GetFlat(doc, source);
                                    List <PlanarFace> planarFacessource = FlFaces(flatsource);
                                    List <PlanarFace> planarFacetarget  = FlFaces(flattarget);
                                    Element           elesource         = doc.GetElement(elementIds.First());
                                    double            spatarget         = 0;
                                    foreach (ElementId i in newlist)
                                    {
                                        Element       eletarget      = doc.GetElement(i);
                                        LocationPoint locationPoint2 = eletarget.Location as LocationPoint;
                                        XYZ           pointtarget    = locationPoint2.Point;
                                        spatarget = DistanceToMin(doc, source, planarFacetarget, pointtarget, kl);
                                        if (spatarget != 0)
                                        {
                                            break;
                                        }
                                    }
                                    if (spatarget != 0)
                                    {
                                        foreach (ElementId i in newlist)
                                        {
                                            XYZ point1 = new XYZ(0, 0, 0);
                                            point1 = point1 + transform1.BasisX * spatarget;
                                            ElementTransformUtils.MoveElement(doc, i, point1);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (val1 > 0)
                                {
                                    foreach (ElementId i in newlist)
                                    {
                                        XYZ point1 = new XYZ(0, 0, 0);
                                        point1 = point1 + transform1.BasisX * (val1);
                                        ElementTransformUtils.MoveElement(doc, i, point1);
                                    }
                                }
                                else
                                {
                                    foreach (ElementId i in newlist)
                                    {
                                        XYZ point1 = new XYZ(0, 0, 0);
                                        point1 = point1 + transform1.BasisX * (-val1);
                                        ElementTransformUtils.MoveElement(doc, i, point1);
                                    }
                                }
                            }
                        }
                        tran.Commit();
                    }
                }
            }
            progressBarform.Close();
        }
        public Dictionary <string, string> Excute(Document doc, List <ElementId> elementIds)
        {
            Dictionary <string, List <string> > dic  = new Dictionary <string, List <string> >();
            Dictionary <string, List <string> > dic2 = new Dictionary <string, List <string> >();
            Dictionary <string, string>         dic3 = new Dictionary <string, string>();
            List <ElementId> listids = new List <ElementId>();

            foreach (var item in elementIds)
            {
                FamilyInstance familyInstance = (FamilyInstance)doc.GetElement(item);
                var            warped         = GetWarped(doc, familyInstance);
                listids.Add(warped.Id);
            }
            ProgressBarform progressBarform = new ProgressBarform(listids.Count, "Loading...");

            progressBarform.Show();
            for (int i = 0; i < listids.Count - 1; i++)
            {
                var item = (FamilyInstance)doc.GetElement(listids[i]);
                progressBarform.giatri();
                if (progressBarform.iscontinue == false)
                {
                    break;
                }
                var          WARPED = GetWarped(doc, item);
                List <Solid> solids = AllSolids(WARPED);
                if (solids != null)
                {
                    foreach (Solid it in solids)
                    {
                        if (it != null && it.Faces.Size < 50)
                        {
                            IList <FamilyInstance> a1 = Checkintersect(doc, it, listids, item);
                            var sup = GetSuperInstances(new List <FamilyInstance> {
                                item
                            });
                            List <FamilyInstance> checksup = GetSuperInstances(a1.ToList());
                            foreach (var i1 in checksup)
                            {
                                if (dic.ContainsKey(sup.First().Name))
                                {
                                    dic[sup.First().Name].Add(Unionstring(sup.First(), i1));
                                }
                                else
                                {
                                    dic.Add(sup.First().Name, new List <string> {
                                        Unionstring(sup.First(), i1)
                                    });
                                }
                            }
                        }
                    }
                }
                listids.RemoveAt(i);
                i--;
            }
            foreach (var item in dic.Keys)
            {
                dic2.Add(item, RemoveContankey(dic[item]));
            }
            foreach (var item2 in dic2.Keys)
            {
                var fg = SpilitS(dic2[item2]);
                foreach (var item in fg.Keys)
                {
                    dic3.Add(item, fg[item]);
                }
            }
            progressBarform.Close();
            return(dic3);
        }
        public void Crash(Document doc)
        {
            List <ViewSheet> ListSheets = GetAllSheetErection(doc);

            using (Transaction tran = new Transaction(doc, "Add Suffix ControlNumber"))
            {
                tran.Start();
                ProgressBarform progressBarform = new ProgressBarform(ListSheets.Count, "Running...");
                progressBarform.Show();
                foreach (ViewSheet sheet in ListSheets)
                {
                    progressBarform.giatri();
                    if (progressBarform.iscontinue == false)
                    {
                        break;
                    }
                    string sheetNumber = sheet.SheetNumber.Split('-').Last().Replace(".", "");

                    List <View> Views = GetAllViewPlaceOnSheet(doc, sheet);
                    foreach (View view in Views)
                    {
                        Dictionary <string, List <IndependentTag> > dic4 = new Dictionary <string, List <IndependentTag> >();
                        List <IndependentTag> independentTags            = FindsymboltaginView(doc, view);
                        foreach (var tag in independentTags)
                        {
                            FamilyInstance instancesource = doc.GetElement(tag.TaggedLocalElementId) as FamilyInstance;
                            if (instancesource.Category.Name != null)
                            {
                                if (instancesource.Category.Name.Contains("Structural Framing"))
                                {
                                    FamilyInstance _product       = instancesource.GetSuperInstances();
                                    Parameter      Control_number = _product.LookupParameter("CONTROL_NUMBER");
                                    string         stringrevert   = RevertString(Control_number.AsString());
                                    string         value          = RevertString(stringrevert.Substring(0, 3));
                                    if (Control_number != null)
                                    {
                                        Control_number.Set(sheetNumber + value);
                                    }
                                }
                            }
                        }
                        //foreach (IndependentTag tag in independentTags)
                        //{
                        //    if (dic4.ContainsKey(tag.Name))
                        //    {
                        //        dic4[tag.Name].Add(tag);
                        //    }
                        //    else
                        //    {
                        //        dic4.Add(tag.Name, new List<IndependentTag> { tag });
                        //    }
                        //}
                        //if(dic2.ContainsKey(view.Name))
                        //{
                        //    continue;
                        //}
                        //else
                        //{
                        //    dic2.Add(view.Name, dic4);
                        //}
                        //dic2.Add(view.Name, dic4);
                    }
                }
                progressBarform.Close();
                tran.Commit();
            }
        }
Пример #10
0
        public Dictionary <string, string> Doing(Document doc, List <ElementId> elementIds)
        {
            Dictionary <string, List <string> > dic  = new Dictionary <string, List <string> >();
            Dictionary <string, List <string> > dic2 = new Dictionary <string, List <string> >();
            Dictionary <string, string>         dic3 = new Dictionary <string, string>();
            List <ElementId> listids         = elementIds.ToList();
            ProgressBarform  progressBarform = new ProgressBarform(listids.Count, "Loading...");

            progressBarform.Show();
            for (int i = 0; i < listids.Count; i++)
            {
                var item = (FamilyInstance)doc.GetElement(listids[i]);
                progressBarform.giatri();
                if (progressBarform.iscontinue == false)
                {
                    break;
                }
                ElementId faid      = item.GetTypeId();
                Element   elemtype  = doc.GetElement(faid);
                Parameter pa        = elemtype.LookupParameter("IDENTITY_DESCRIPTION");
                Transform transform = item.GetTransform();
                if (pa != null)
                {
                    string pa1 = pa.AsString();
                    if (pa1.Contains("STRAND"))
                    {
                        IList <Solid> solids1 = lbr_.CreateSolid(doc, item, transform);
                        if (solids1 != null)
                        {
                            foreach (Solid it in solids1)
                            {
                                IList <FamilyInstance> a1 = Checkstrand(doc, it, listids);
                                var sup = GetSuperInstances(new List <FamilyInstance> {
                                    item
                                });
                                List <FamilyInstance> checksup = GetSuperInstances(a1.ToList());
                                foreach (var i1 in checksup)
                                {
                                    if (dic.ContainsKey(sup.First().Name))
                                    {
                                        dic[sup.First().Name].Add(Unionstring(sup.First(), i1));
                                    }
                                    else
                                    {
                                        dic.Add(sup.First().Name, new List <string> {
                                            Unionstring(sup.First(), i1)
                                        });
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        List <Solid> solids = AllSolids(item);
                        if (solids != null)
                        {
                            foreach (Solid it in solids)
                            {
                                if (it != null && it.Faces.Size < 50)
                                {
                                    IList <FamilyInstance> a1 = Checkintersect(doc, it, listids, item);
                                    var sup = GetSuperInstances(new List <FamilyInstance> {
                                        item
                                    });
                                    List <FamilyInstance> checksup = GetSuperInstances(a1.ToList());
                                    foreach (var i1 in checksup)
                                    {
                                        if (dic.ContainsKey(sup.First().Name))
                                        {
                                            dic[sup.First().Name].Add(Unionstring(sup.First(), i1));
                                        }
                                        else
                                        {
                                            dic.Add(sup.First().Name, new List <string> {
                                                Unionstring(sup.First(), i1)
                                            });
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                listids.RemoveAt(i);
                i--;
            }
            foreach (var item in dic.Keys)
            {
                dic2.Add(item, RemoveContankey(dic[item]));
            }
            foreach (var item2 in dic2.Keys)
            {
                var fg = SpilitS(dic2[item2]);
                foreach (var item in fg.Keys)
                {
                    dic3.Add(item, fg[item]);
                }
            }
            progressBarform.Close();
            return(dic3);
        }