provide some common geometry judgement and calculate method
Example #1
0
        /// <summary>
        /// remove the hooks from one boundary curve of the Major Direction Layer
        /// or Exterior Direction Layer
        /// </summary>
        /// <returns>whether the command is successful</returns>
        private bool ChangeHookType()
        {
            //find two vertical AreaReinforcementCurve
            Line line0 = m_areaReinCurves[0].Curve as Line;
            Line line1 = m_areaReinCurves[1].Curve as Line;
            Line line2 = m_areaReinCurves[2].Curve as Line;
            AreaReinforcementCurve temp = null;

            if (GeomUtil.IsVertical(line0, line1))
            {
                temp = m_areaReinCurves[1];
            }
            else
            {
                temp = m_areaReinCurves[2];
            }

            //remove hooks
            ParameterUtil.SetParaInt(m_areaReinCurves[0],
                                     BuiltInParameter.REBAR_SYSTEM_OVERRIDE, -1);
            Parameter para = m_areaReinCurves[0].get_Parameter(
                BuiltInParameter.REBAR_SYSTEM_HOOK_TYPE_TOP_DIR_1);
            bool flag = ParameterUtil.SetParaNullId(para);

            ParameterUtil.SetParaInt(temp, BuiltInParameter.REBAR_SYSTEM_OVERRIDE, -1);
            para = temp.get_Parameter(
                BuiltInParameter.REBAR_SYSTEM_HOOK_TYPE_TOP_DIR_1);
            flag &= ParameterUtil.SetParaNullId(para);

            return(flag);
        }
Example #2
0
        /// <summary>
        /// check whether the selected is expected, prepare necessary data
        /// </summary>
        /// <param name="selected">selected elements</param>
        /// <returns>whether the selected AreaReinforcement is expected</returns>
        private bool PreData(ElementSet selected)
        {
            //selected is not only one AreaReinforcement
            if (selected.Size != 1)
            {
                return(false);
            }
            foreach (Object o in selected)
            {
                m_areaRein = o as AreaReinforcement;
                if (null == m_areaRein)
                {
                    return(false);
                }
            }

            //whether the selected AreaReinforcement is rectangular
            CurveArray curves = new CurveArray();

            m_areaReinCurves = new List <AreaReinforcementCurve>();
            IList <ElementId> curveIds = m_areaRein.GetBoundaryCurveIds();

            foreach (ElementId o in curveIds)
            {
                AreaReinforcementCurve areaCurve = m_doc.GetElement(o) as AreaReinforcementCurve;
                if (null == areaCurve)
                {
                    ApplicationException appEx = new ApplicationException
                                                     ("There is unexpected error with selected AreaReinforcement.");
                    throw appEx;
                }
                m_areaReinCurves.Add(areaCurve);
                curves.Append(areaCurve.Curve);
            }
            bool flag = GeomUtil.IsRectangular(curves);

            return(flag);
        }