示例#1
0
        public void Mathvalue2(Document doc, DoubleTee doubleTee, List <DoubleTee> listdt)
        {
            ProgressbarWPF progressbarWPF = new ProgressbarWPF(listdt.Count, "Loading...");

            progressbarWPF.Show();
            foreach (var item in listdt)
            {
                progressbarWPF.Giatri();
                if (progressbarWPF.iscontinue == false)
                {
                    break;
                }
                using (Transaction tran = new Transaction(doc, "Math Value"))
                {
                    tran.Start();
                    item.Length_of_Drop.Set(doubleTee.Length_of_Drop.AsDouble());
                    item.High_Point_Elevation.Set(doubleTee.High_Point_Elevation.AsDouble());
                    item.Low_Point_Elevation.Set(doubleTee.Low_Point_Elevation.AsDouble());
                    item.CL_DT.Set(doubleTee.CL_DT.AsDouble());
                    item.Manual_Mark_End_Offset.Set(doubleTee.Manual_Mark_End_Offset.AsDouble());
                    item.Manual_Mark_End_Warp_Angle.Set(doubleTee.Manual_Mark_End_Warp_Angle.AsDouble());
                    item.Manual_Opp_End_Offset.Set(doubleTee.Manual_Opp_End_Offset.AsDouble());
                    item.Manual_Opp_End_Warp_Angle.Set(doubleTee.Manual_Opp_End_Warp_Angle.AsDouble());
                    tran.Commit();
                }
            }
            progressbarWPF.Close();
        }
        public void CopyText(Document doc, List <ElementId> ids, View source, List <View> Taggets)
        {
            ProgressbarWPF progressbarWPF = new ProgressbarWPF(Taggets.Count, "Copy Text");

            progressbarWPF.Show();
            foreach (var Tagget in Taggets)
            {
                if (progressbarWPF.iscontinue == false)
                {
                    break;
                }
                using (Transaction t = new Transaction(doc, "Copy Text"))
                {
                    t.Start();
                    FailureHandlingOptions options       = t.GetFailureHandlingOptions();
                    MyPreProcessor         ignoreProcess = new MyPreProcessor();
                    options.SetClearAfterRollback(true);
                    options.SetFailuresPreprocessor(ignoreProcess);
                    t.SetFailureHandlingOptions(options);
                    try
                    {
                        ElementTransformUtils.CopyElements(source, ids, Tagget, Transform.Identity, new CopyPasteOptions());
                    }
                    catch
                    {
                    }
                    t.Commit();
                }
            }
            progressbarWPF.Close();
        }
        public Dictionary <string, List <CEGRebarInfo> > GetAllRebar(Document doc)
        {
            Dictionary <string, List <CEGRebarInfo> > dic  = new Dictionary <string, List <CEGRebarInfo> >();
            Dictionary <string, List <CEGRebarInfo> > dic2 = new Dictionary <string, List <CEGRebarInfo> >();
            List <FamilyInstance> col            = (from FamilyInstance x in new FilteredElementCollector(doc).WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_SpecialityEquipment).OfClass(typeof(FamilyInstance)) where x.Symbol.LookupParameter("BAR_SHAPE") != null select x).Cast <FamilyInstance>().ToList();
            ProgressbarWPF        progressbarWPF = new ProgressbarWPF(col.Count, "Export Schedule Rebar")
            {
                topmessage = "Collecting rebar..."
            };

            progressbarWPF.Show();
            foreach (var item in col)
            {
                progressbarWPF.Giatri();
                if (!progressbarWPF.iscontinue)
                {
                    break;
                }
                Autodesk.Revit.DB.Parameter parameter = (item != null) ? item.Symbol.LookupParameter("BAR_SHAPE") : null;
                bool fg = string.IsNullOrEmpty((parameter != null) ? parameter.AsString() : null);
                if (!fg)
                {
                    CEGRebarInfo rebar = new CEGRebarInfo(item);
                    if (rebar.UnistImperial != null && rebar.UnistImperial != "")
                    {
                        if (dic.ContainsKey(rebar.UnistImperial))
                        {
                            dic[rebar.UnistImperial].Add(rebar);
                        }
                        else
                        {
                            dic.Add(rebar.UnistImperial, new List <CEGRebarInfo> {
                                rebar
                            });
                        }
                    }
                }
            }
            var keys = dic.Keys.ToList();

            Caculator(keys);
            foreach (var item in keys)
            {
                foreach (var item2 in dic[item])
                {
                    if (dic2.ContainsKey(item2.UnistImperial))
                    {
                        dic2[item2.UnistImperial].Add(item2);
                    }
                    else
                    {
                        dic2.Add(item2.UnistImperial, new List <CEGRebarInfo> {
                            item2
                        });
                    }
                }
            }
            progressbarWPF.Close();
            return(dic2);
        }
        public void Setvalue(Document doc, List <ProductCEG> list, string value)
        {
            ProgressbarWPF progressBarform = new ProgressbarWPF(list.Count, "Loading...");

            progressBarform.Show();
            foreach (var i in list)
            {
                progressBarform.Giatri();
                if (progressBarform.iscontinue == false)
                {
                    break;
                }
                Parameter commentdata = i.instance.LookupParameter(value);
                if (commentdata != null)
                {
                    string hj = commentdata.AsString();
                    using (Transaction tran = new Transaction(doc, "Set"))
                    {
                        tran.Start();
                        FamilyInstance flat = Flat(doc, i.instance);
                        if (flat != null)
                        {
                            Parameter fldata = flat.LookupParameter(value);
                            if (fldata != null)
                            {
                                Parameter volume = flat.LookupParameter("Volume");
                                double    Value  = volume.AsDouble();
                                double    kl     = Value * 150;
                                double    k1     = Math.Round(kl / 1000, 1);
                                double    k2     = k1 * 1000;
                                double    k3     = Math.Ceiling(k2) + 50;
                                commentdata.Set(k3.ToString());
                                fldata.Set(k3.ToString());
                                string gh = commentdata.AsString();
                            }
                        }
                        else
                        {
                            Parameter volume = i.instance.LookupParameter("Volume");
                            double    Value  = volume.AsDouble();
                            double    kl     = Value * 150;
                            double    k1     = Math.Round(kl / 1000, 1);
                            double    k2     = k1 * 1000;
                            double    k3     = Math.Ceiling(k2) + 50;
                            commentdata.Set(k3.ToString());
                            string gh = commentdata.AsString();
                        }
                        tran.Commit();
                    }
                }
            }
            progressBarform.Close();
        }
        public void OpenMultisheet(List <ViewSheet> viewSheets)
        {
            ProgressbarWPF progressbarWPF = new ProgressbarWPF(viewSheets.Count, "Opening...");

            progressbarWPF.Show();
            foreach (var item in viewSheets)
            {
                progressbarWPF.Giatri();
                if (!progressbarWPF.iscontinue)
                {
                    break;
                }
                uidoc.ActiveView = item;
            }
            progressbarWPF.Close();
        }
示例#6
0
        public void Getviewportonsheet(Document doc, List <ViewSheet> viewsheets, string Prefix, string Suffix, string SheetNumber_)
        {
            //ProgressBarform progressBarform = new ProgressBarform(viewsheets.Count, "Loading...");
            //progressBarform.Show();
            ProgressbarWPF progressbarWPF = new ProgressbarWPF(viewsheets.Count, "Loading...");

            progressbarWPF.Show();
            using (Transaction tran = new Transaction(doc, "Rename Sheet"))
            {
                tran.Start();
                foreach (var i in viewsheets)
                {
                    //progressBarform.giatri();
                    //if (progressBarform.iscontinue == false)
                    //{
                    //    break;
                    //}
                    progressbarWPF.Giatri();
                    if (progressbarWPF.iscontinue == false)
                    {
                        break;
                    }
                    i.ViewName = Prefix + " " + i.ViewName + " " + Suffix;
                    if (SheetNumber_.Length != 0)
                    {
                        int    so             = int.Parse(SheetNumber_);
                        string ten            = i.SheetNumber;
                        string newstring      = ten.Split('.')[0];
                        string newstring2     = ten.Split('.')[1];
                        int    soo            = int.Parse(newstring2);
                        int    lp             = int.Parse(SheetNumber_);
                        int    jh             = soo + lp;
                        string newsheetnumber = newstring + "." + jh;
                        i.SheetNumber = newsheetnumber;
                    }
                    var y = i.GetAllPlacedViews();
                    foreach (var t in y)
                    {
                        View hh = doc.GetElement(t) as View;
                        hh.ViewName = Prefix + " " + hh.ViewName + " " + Suffix;
                    }
                }
                tran.Commit();
            }
            progressbarWPF.Close();
            //progressBarform.Close();
        }
示例#7
0
        public void MathValue(Document doc, List <DoubleTee> list1, Dictionary <string, List <DoubleTee> > dic)
        {
            ProgressbarWPF progressbarWPF = new ProgressbarWPF(list1.Count, "Loading...");

            progressbarWPF.Show();
            foreach (var item in list1)
            {
                progressbarWPF.Giatri();
                if (progressbarWPF.iscontinue == false)
                {
                    break;
                }
                using (Transaction tran = new Transaction(doc, "Math Dt"))
                {
                    tran.Start();
                    foreach (var item2 in dic.Keys.ToList())
                    {
                        var       list2 = dic[item2].ToList();
                        DoubleTee flag  = Getdtnearly(item, list2);
                        if (flag != null)
                        {
                            flag.Length_of_Drop.Set(item.Length_of_Drop.AsDouble());
                            flag.High_Point_Elevation.Set(item.High_Point_Elevation.AsDouble());
                            flag.Low_Point_Elevation.Set(item.Low_Point_Elevation.AsDouble());
                            flag.CL_DT.Set(item.CL_DT.AsDouble());
                            flag.Manual_Mark_End_Offset.Set(item.Manual_Mark_End_Offset.AsDouble());
                            flag.Manual_Mark_End_Warp_Angle.Set(item.Manual_Mark_End_Warp_Angle.AsDouble());
                            flag.Manual_Opp_End_Offset.Set(item.Manual_Opp_End_Offset.AsDouble());
                            flag.Manual_Opp_End_Warp_Angle.Set(item.Manual_Opp_End_Warp_Angle.AsDouble());
                        }
                        else
                        {
                            continue;
                        }
                    }
                    tran.Commit();
                }
            }
            progressbarWPF.Close();
        }
        public void Set(Document doc, List <AssemblyInstance> assemblyInstances, string value)
        {
            ProgressbarWPF progressBarform = new ProgressbarWPF(assemblyInstances.Count, "Loading...");

            progressBarform.Show();
            foreach (var item in assemblyInstances)
            {
                progressBarform.Giatri();
                if (progressBarform.iscontinue == false)
                {
                    break;
                }
                string    giatri;
                var       family      = GetVolumnAssembly(doc, item, out giatri);
                Parameter commentdata = family.LookupParameter(value);
                using (Transaction tran = new Transaction(doc, "Set"))
                {
                    tran.Start();
                    commentdata.Set(giatri.ToString());
                    tran.Commit();
                }
            }
            progressBarform.Close();
        }
示例#9
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;

            doc = uidoc.Document;
            Selection sel = uidoc.Selection;

            listpoint.Clear();
            Insulationlbr           insulationlbr     = Insulationlbr.Instance;
            InsulationSupport       insulationSupport = new InsulationSupport();
            FamilyInstance          WALLINSTANCE      = null;
            List <FamilySymbol>     listsym           = insulationlbr.GetFamilySymbols(doc);
            List <Rectangleslbr>    soluong           = new List <Rectangleslbr>();
            AssemblyInstance        instance          = null;
            FamilyInstance          insu   = null;
            Rectangleslbr           rec    = null;
            ICollection <ElementId> copyid = new List <ElementId>();
            //Reference rf = sel.PickObject(ObjectType.Element, new AssemblySelectionfilter(), "Assembly");
            //Element ele = doc.GetElement(rf);
            //AssemblyInstance instance = ele as Assembly+Instance;
            ProgressbarWPF progressbarWPF = new ProgressbarWPF(4, "Loading...");

            progressbarWPF.Show();
            for (int i = 1; i < 4; i++)
            {
                progressbarWPF.Giatri();
                if (progressbarWPF.iscontinue == false)
                {
                    break;
                }
                if (i == 1)
                {
                    if (doc.ActiveView.IsAssemblyView)
                    {
                        instance = doc.GetElement(doc.ActiveView.AssociatedAssemblyInstanceId) as AssemblyInstance;
                    }
                    insu         = insulationlbr.Getinsulation(doc, instance);
                    WALLINSTANCE = insulationlbr.GetWall(doc, instance);
                    //var topface = insulationSupport.FindTopWallother(insu);
                    rec = insulationlbr.DrawingFaceTop(doc, instance);
                }
                if (i == 2)
                {
                    var               right   = doc.ActiveView.RightDirection;
                    PlanarFace        topface = insulationSupport.FindTopWallother(insu);
                    IList <CurveLoop> loops   = topface.GetEdgesAsCurveLoops();
                    if (loops.Count != 1)
                    {
                        soluong = insulationSupport.DrawBlockOut2(doc, instance, insu, WALLINSTANCE, rec, 0.125, 8);
                        List <List <Rectangleslbr> > listrec = new List <List <Rectangleslbr> >();
                        listrec = Rectangleslbr.ListRecVert(soluong);
                        insulationSupport.SortRectangleslist(listrec);
                        if (Math.Floor(right.X) != 0)
                        {
                            copyid = Rectangleslbr.LayoutInsulationvert(doc, listrec);
                        }
                        else
                        {
                            copyid = Rectangleslbr.LayoutInsulationvert2(doc, listrec);
                        }
                    }
                    else
                    {
                        soluong = insulationSupport.DrawBlockOut1(doc, instance, insu, WALLINSTANCE, rec, 0.125, 8);
                        List <List <Rectangleslbr> > listrec = new List <List <Rectangleslbr> >();
                        listrec = Rectangleslbr.ListRecVert(soluong);
                        insulationSupport.SortRectangleslist(listrec);
                        if (Math.Floor(right.X) != 0)
                        {
                            copyid = Rectangleslbr.LayoutInsulationvert(doc, listrec);
                        }
                        else
                        {
                            copyid = Rectangleslbr.LayoutInsulationvert2(doc, listrec);
                        }
                    }
                }
                if (i == 3)
                {
                    View viewcopy = insulationlbr.CreateDraftingView(doc);
                    using (Transaction tran = new Transaction(doc, "Copy"))
                    {
                        tran.Start();
                        ElementTransformUtils.CopyElements(doc.ActiveView, copyid, viewcopy, null, new CopyPasteOptions());
                        doc.Delete(copyid);
                        tran.Commit();
                    }
                    TaskDialog.Show("Insulation lay out", "Finish View" + " " + viewcopy.Name);
                }
            }
            progressbarWPF.Close();

            /////////
            //IList<Element> rf = sel.PickElementsByRectangle(new Filterdetailline(), "Detailline");
            //ICollection<ElementId> listd = new List<ElementId>();
            //foreach (Element e in rf)
            //{
            //    listd.Add(e.Id);
            //}
            //List<XYZ> list = insulationlbr.GetIntersectXYZoncurve(doc, listd);
            //List<FamilySymbol> listsym = insulationlbr.GetFamilySymbols(doc);
            //List<Rectangleslbr> soluong = Rectangleslbr.CreateRectangle(doc, list);
            ////insulationlbr.PlaceSymmbolonRectangles(doc, listsym, soluong);
            //List<List<Rectangleslbr>> listrec = new List<List<Rectangleslbr>>();
            //listrec = Rectangleslbr.ListRecVert(soluong);
            //TaskDialog.Show("SSS", soluong.Count.ToString());
            ////insulationlbr.PlaceSymmbolonPoint(doc, listsym, list);
            //insulationlbr.PlaceSymmbolonRectangles(doc, listsym, soluong);
            return(Result.Succeeded);
        }
示例#10
0
        public void Changefamily(Document doc, FamilySymbol familySymbol, List <FamilyInstance> listinstance)
        {
            ProgressbarWPF progressbarWPF = new ProgressbarWPF(listinstance.Count, "Loading...");

            progressbarWPF.Show();
            foreach (FamilyInstance familyInstance in listinstance)
            {
                progressbarWPF.Giatri();
                if (progressbarWPF.iscontinue == false)
                {
                    break;
                }
                Dictionary <string, string> dicparameter  = new Dictionary <string, string>();
                Dictionary <string, double> dicparameter1 = new Dictionary <string, double>();
                using (Transaction tran = new Transaction(doc, "sss"))
                {
                    tran.Start();
                    FailureHandlingOptions options       = tran.GetFailureHandlingOptions();
                    MyPreProcessor         preproccessor = new MyPreProcessor();
                    options.SetClearAfterRollback(true);
                    options.SetFailuresPreprocessor(preproccessor);
                    List <Parameter> list1 = ParameterofDt.Getpameteryesno(doc, familyInstance);
                    List <Parameter> list2 = ParameterofDt.Getpameterdouble(doc, familyInstance);
                    foreach (var item in list1)
                    {
                        if (item != null)
                        {
                            dicparameter.Add(item.Definition.Name, item.AsValueString());
                        }
                    }
                    foreach (var item in list2)
                    {
                        if (item != null)
                        {
                            dicparameter1.Add(item.Definition.Name, item.AsDouble());
                        }
                    }
                    familyInstance.Symbol = familySymbol;
                    List <Parameter> list3 = ParameterofDt.Getpameteryesno(doc, familyInstance);
                    List <Parameter> list4 = ParameterofDt.Getpameterdouble(doc, familyInstance);
                    for (int i = 0; i < list3.Count; i++)
                    {
                        var g1 = list3[i];
                        if (g1 != null)
                        {
                            var giatri1 = g1.AsString();
                            foreach (var o in dicparameter)
                            {
                                if (o.Key == g1.Definition.Name)
                                {
                                    g1.Set(o.Value);
                                }
                            }
                        }
                    }
                    for (int i = 0; i < list4.Count; i++)
                    {
                        var g1 = list4[i];
                        if (g1 != null)
                        {
                            var giatri1 = g1.AsDouble();
                            foreach (var o in dicparameter1)
                            {
                                if (o.Key == g1.Definition.Name)
                                {
                                    g1.Set(o.Value);
                                }
                            }
                        }
                    }
                    tran.Commit(options);
                }
            }
            progressbarWPF.Close();
        }
示例#11
0
        public void Setvalue(Document doc, List <FamilyInstance> list, string value)
        {
            ProgressbarWPF progressBarform = new ProgressbarWPF(list.Count, "Loading...");

            progressBarform.Show();
            var ListCorbelHaunch = FindAllLedgeHaunches(doc);

            foreach (var i in list)
            {
                progressBarform.Giatri();
                if (progressBarform.iscontinue == false)
                {
                    break;
                }
                if (!CheckInAssembly(doc, i))
                {
                    var       listintersect = FindledgeandhaunchesNearly(doc, i, ListCorbelHaunch);
                    Parameter commentdata   = i.LookupParameter(value);
                    string    hj            = commentdata.AsString();
                    using (Transaction tran = new Transaction(doc, "Set"))
                    {
                        tran.Start();
                        ElementtransformToCopy tr     = new ElementtransformToCopy();
                        FamilyInstance         flat   = tr.GetFlat(doc, i);
                        FamilyInstance         wapred = tr.GetWarped(doc, i);
                        if (flat != null)
                        {
                            Parameter FlatVolumnTag   = flat.LookupParameter(value);
                            Parameter WarpedVolumnTag = wapred.LookupParameter(value);
                            Parameter volume          = flat.LookupParameter("Volume");
                            double    Value           = volume.AsDouble() + VolumnCorbelHaunch(listintersect);
                            double    kl = Value * 150;
                            double    k1 = Math.Round(kl / 1000, 1);
                            double    k2 = k1 * 1000;
                            commentdata.Set(k2.ToString());
                            FlatVolumnTag.Set(k2.ToString());
                            WarpedVolumnTag.Set(k2.ToString());
                            string gh = commentdata.AsString();
                        }
                        else
                        {
                            Parameter volume = i.LookupParameter("Volume");
                            double    Value  = volume.AsDouble() + VolumnCorbelHaunch(listintersect);
                            double    kl     = Value * 150;
                            double    k1     = Math.Round(kl / 1000, 1);
                            double    k2     = k1 * 1000;
                            commentdata.Set(k2.ToString());
                            string gh = commentdata.AsString();
                        }
                        tran.Commit();
                    }
                }
                else
                {
                    using (Transaction tran = new Transaction(doc, "Set"))
                    {
                        tran.Start();
                        Parameter commentdata = i.LookupParameter(value);
                        if (!string.IsNullOrEmpty(commentdata.AsString()))
                        {
                            ElementtransformToCopy tr     = new ElementtransformToCopy();
                            FamilyInstance         flat   = tr.GetFlat(doc, i);
                            FamilyInstance         wapred = tr.GetWarped(doc, i);
                            Parameter paproduct           = i.LookupParameter(value);
                            string    CVl = paproduct.AsString();
                            if (flat != null)
                            {
                                Parameter FlatVolumnTag   = flat.LookupParameter(value);
                                Parameter WarpedVolumnTag = wapred.LookupParameter(value);
                                FlatVolumnTag.Set(CVl);
                                WarpedVolumnTag.Set(CVl);
                            }
                        }
                        else
                        {
                            var listintersect             = FindledgeandhaunchesNearly(doc, i, ListCorbelHaunch);
                            ElementtransformToCopy tr     = new ElementtransformToCopy();
                            FamilyInstance         flat   = tr.GetFlat(doc, i);
                            FamilyInstance         wapred = tr.GetWarped(doc, i);
                            if (flat != null)
                            {
                                Parameter FlatVolumnTag   = flat.LookupParameter(value);
                                Parameter WarpedVolumnTag = wapred.LookupParameter(value);
                                Parameter volume          = flat.LookupParameter("Volume");
                                double    Value           = volume.AsDouble() + VolumnCorbelHaunch(listintersect);
                                double    kl = Value * 150;
                                double    k1 = Math.Round(kl / 1000, 1);
                                double    k2 = k1 * 1000;
                                commentdata.Set(k2.ToString());
                                FlatVolumnTag.Set(k2.ToString());
                                WarpedVolumnTag.Set(k2.ToString());
                                string gh = commentdata.AsString();
                            }
                            else
                            {
                                Parameter volume = i.LookupParameter("Volume");
                                double    Value  = volume.AsDouble() + VolumnCorbelHaunch(listintersect);
                                double    kl     = Value * 150;
                                double    k1     = Math.Round(kl / 1000, 1);
                                double    k2     = k1 * 1000;
                                commentdata.Set(k2.ToString());
                                string gh = commentdata.AsString();
                            }
                        }
                        tran.Commit();
                    }
                }
            }
            progressBarform.Close();
        }