示例#1
0
        public static void BrickDimCheck(BrickDimSelector brDimSel, UIDocument uidoc, Document doc)
        {
            ISelectionFilter dimsFilt = new SelectionFilterDims();
            ElementId        dimId    = uidoc.Selection.PickObject(ObjectType.Element, dimsFilt).ElementId;
            Dimension        dim      = doc.GetElement(dimId) as Dimension;

            StringBuilder sb = new StringBuilder();

            //if empty add to cut brick list list
            //we could also check for multi dims and flag to user, poss with split method...
            if (dim.Value == null)
            {
                sb.Append("Something went wrong, perhaps this is a multi-dim?");
                brDimSel.BrickDimReadout.Content = sb.ToString();
                //we could probably override suffixes here if we wanted...dim.Suffix = "Joint";
                //this is probably a multi one, we could give a list?!
            }

            else
            {
                //get dimension value in mm
                double dimValue      = Convert.ToDouble(dim.Value);
                double dimValueMm    = UnitUtils.ConvertFromInternalUnits(dimValue, UnitTypeId.Millimeters);
                double dimValueMmRnd = BrickFuncts.round(dimValueMm); //round to 1 dp

                //divide by CO
                double dimCO = dimValueMmRnd / BrickFuncts.CO(1);
                //get math floor and set of CO values
                double dimCOflr = Math.Floor(dimCO);

                double dimCOflrCO      = BrickFuncts.round(BrickFuncts.CO(dimCOflr));
                double dimCOflrCOminus = BrickFuncts.round(BrickFuncts.COMinus(dimCOflr));
                double dimCOflrCOPlus  = BrickFuncts.round(BrickFuncts.COPlus(dimCOflr));

                //get math ceiling and set of CO values
                double dimCOclng = Math.Ceiling(dimCO);

                double dimCOclngCO      = BrickFuncts.round(BrickFuncts.CO(dimCOclng));
                double dimCOclngCOminus = BrickFuncts.round(BrickFuncts.COMinus(dimCOclng));
                double dimCOclngCOPlus  = BrickFuncts.round(BrickFuncts.COPlus(dimCOclng));

                sb.Append("CO-\t\tCO\t\tCO+\n");
                sb.Append(dimCOflrCOminus.ToString() + "\t\t" + dimCOflrCO.ToString() + "\t\t" + dimCOflrCOPlus.ToString() + "\n");
                sb.Append(dimCOclngCOminus.ToString() + "\t\t" + dimCOclngCO.ToString() + "\t\t" + dimCOclngCOPlus.ToString());

                brDimSel.BrickDimReadout.Content = sb.ToString();
                brDimSel.DimSelClick.Text        = dimValueMmRnd.ToString();
            }
        }
示例#2
0
        public static void DimClrChngSuffix(Dimension dim, UIDocument uidoc)
        {
            //if empty add to cut brick list list
            //we could also check for multi dims and flag to user, poss with split method...
            if (dim.Value == null)
            {
                uidoc.ActiveView.SetElementOverrides(dim.Id, ClrSettings.ogsJoint());
                //we could probably override suffixes here if we wanted...dim.Suffix = "Joint";
            }

            else
            {
                //get dimension value in mm
                double dimValue      = Convert.ToDouble(dim.Value);
                double dimValueMm    = UnitUtils.ConvertFromInternalUnits(dimValue, UnitTypeId.Millimeters);
                double dimValueMmRnd = BrickFuncts.round(dimValueMm); //round to 1 dp

                if (dimValueMmRnd == 10)
                {
                    //if value == 10, add item to cut brick list
                    uidoc.ActiveView.SetElementOverrides(dim.Id, ClrSettings.ogsJoint());
                    dim.Suffix = "Joint";
                }

                else
                {
                    //divide by CO
                    double dimCO = dimValueMmRnd / BrickFuncts.CO(1);
                    //get math floor and set of CO values
                    double dimCOflr = Math.Floor(dimCO);

                    double dimCOflrCO      = BrickFuncts.round(BrickFuncts.CO(dimCOflr));
                    double dimCOflrCOminus = BrickFuncts.round(BrickFuncts.COMinus(dimCOflr));
                    double dimCOflrCOPlus  = BrickFuncts.round(BrickFuncts.COPlus(dimCOflr));

                    //get math ceiling and set of CO values
                    double dimCOclng = Math.Ceiling(dimCO);

                    double dimCOclngCO      = BrickFuncts.round(BrickFuncts.CO(dimCOclng));
                    double dimCOclngCOminus = BrickFuncts.round(BrickFuncts.COMinus(dimCOclng));
                    double dimCOclngCOPlus  = BrickFuncts.round(BrickFuncts.COPlus(dimCOclng));

                    if ((dimValueMmRnd == dimCOflrCO) || (dimValueMmRnd == dimCOclngCO))
                    {
                        dim.Suffix = "CO";
                        uidoc.ActiveView.SetElementOverrides(dim.Id, ClrSettings.ogsCO());
                    }

                    else if ((dimValueMmRnd == dimCOflrCOminus) || (dimValueMmRnd == dimCOclngCOminus))
                    {
                        dim.Suffix = "CO-";
                        uidoc.ActiveView.SetElementOverrides(dim.Id, ClrSettings.ogsCOminus());
                    }

                    else if ((dimValueMmRnd == dimCOflrCOPlus) || (dimValueMmRnd == dimCOclngCOPlus))
                    {
                        dim.Suffix = "CO+";
                        uidoc.ActiveView.SetElementOverrides(dim.Id, ClrSettings.ogsCOplus());
                    }

                    else
                    {
                        dim.Suffix = "cut";
                        uidoc.ActiveView.SetElementOverrides(dim.Id, ClrSettings.ogsCut());
                    }
                }

                //sb.AppendLine(dimValueMmRnd.ToString());
            }
        }