Esempio n. 1
0
        protected static void setCurveMethod(Autodesk.Revit.DB.CurveElement ce, Curve c)
        {
            bool foundMethod = false;

            if (hasMethodSetCurve)
            {
                Type         CurveElementType     = typeof(Autodesk.Revit.DB.CurveElement);
                MethodInfo[] curveElementMethods  = CurveElementType.GetMethods(BindingFlags.Instance | BindingFlags.Public);
                String       nameOfMethodSetCurve = "SetGeometryCurveOverridingJoins";

                foreach (MethodInfo m in curveElementMethods)
                {
                    if (m.Name == nameOfMethodSetCurve)
                    {
                        object[] argsM = new object[1];
                        argsM[0] = c;

                        foundMethod = true;
                        m.Invoke(ce, argsM);
                        break;
                    }
                }
            }
            if (!foundMethod)
            {
                hasMethodSetCurve = false;
                ce.GeometryCurve  = c;
            }
        }
        public static void DrawCurveElement(RenderDescription description, object obj)
        {
            Autodesk.Revit.DB.CurveElement elem = obj as Autodesk.Revit.DB.CurveElement;

            if (elem == null)
            {
                return;
            }

            DrawCurve(description, elem.GeometryCurve);
        }
Esempio n. 3
0
        internal void AssertCurveEqual(DB.CurveElement sourceElem, DB.CurveElement destElem)
        {
            Assert.NotNull(destElem);
            Assert.Equal(sourceElem.Name, destElem.Name);

            AssertEqualParam(sourceElem, destElem, BuiltInParameter.CURVE_ELEM_LENGTH);
            AssertEqualParam(sourceElem, destElem, BuiltInParameter.BUILDING_CURVE_GSTYLE);

            if (((LocationCurve)sourceElem.Location).Curve.IsBound)
            {
                var sourceEnd = ((LocationCurve)sourceElem.Location).Curve.GetEndPoint(0);
                var destEnd   = ((LocationCurve)destElem.Location).Curve.GetEndPoint(0);

                Assert.Equal(sourceEnd.X, destEnd.X, 4);
                Assert.Equal(sourceEnd.Y, destEnd.Y, 4);
                Assert.Equal(sourceEnd.Z, destEnd.Z, 4);
            }
        }
Esempio n. 4
0
        public GeometryCurve(Autodesk.Revit.DB.CurveElement curve)
        {
            this.Id = curve.Id.IntegerValue;
            List_AdjoinedElementsEnd0 = curve.GetAdjoinedCurveElements(0).Select(i => i.IntegerValue).ToList();
            List_AdjoinedElementsEnd0 = curve.GetAdjoinedCurveElements(0).Select(i => i.IntegerValue).ToList();

            this.LineType = Enum.GetName(typeof(CurveElementType), curve.CurveElementType);



            if (curve.CurveElementType == CurveElementType.ModelCurve)
            {
                ModelCurve mcurve = curve as ModelCurve;
                this.LineFormType       = mcurve.GeometryCurve.ToString();
                this.IsDetailLine       = false;
                this.geomVisibility     = new GeometryVisibility(mcurve.GetVisibility());
                this.HasTangentLockEnd0 = mcurve.HasTangentLocks(0);
                this.HasTangentLockEnd1 = mcurve.HasTangentLocks(1);
                //this.HostId = mcurve.LevelId.IntegerValue;

                try
                {
                    this.SubcategoryName = mcurve.Subcategory.Name;
                }
                catch
                {
                    this.SubcategoryName = "null";
                }

                this.TypeName = mcurve.LineStyle.Name;
            }
            else if (curve.CurveElementType == CurveElementType.SymbolicCurve)
            {
                SymbolicCurve mcurve = curve as SymbolicCurve;
                this.LineFormType       = mcurve.GeometryCurve.ToString();
                this.IsDetailLine       = false;
                this.geomVisibility     = new GeometryVisibility(mcurve.GetVisibility());
                this.HasTangentLockEnd0 = mcurve.HasTangentLocks(0);
                this.HasTangentLockEnd1 = mcurve.HasTangentLocks(1);
                //this.HostId = mcurve.LevelId.IntegerValue;
                this.SubcategoryName = mcurve.Subcategory.Name;
                this.TypeName        = mcurve.LineStyle.Name;
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Set the internal model curve along with its id's
 /// </summary>
 /// <param name="curveElement"></param>
 protected void InternalSetCurveElement(Autodesk.Revit.DB.CurveElement curveElement)
 {
     this.InternalCurveElement = curveElement;
     this.InternalElementId    = curveElement.Id;
     this.InternalUniqueId     = curveElement.UniqueId;
 }
Esempio n. 6
0
        private static string resetSketchPlaneMethod(Autodesk.Revit.DB.CurveElement mc, Curve c, Autodesk.Revit.DB.Plane flattenedOnPlane, out bool needsSketchPlaneReset)
        {
            //do we need to reset?
            needsSketchPlaneReset = false;
            Autodesk.Revit.DB.Plane newPlane = flattenedOnPlane != null ? flattenedOnPlane : CurveUtils.GetPlaneFromCurve(c, false);

            Autodesk.Revit.DB.Plane curPlane = mc.SketchPlane.GetPlane();

            bool resetPlane = false;

            {
                double llSqCur         = curPlane.Normal.DotProduct(curPlane.Normal);
                double llSqNew         = newPlane.Normal.DotProduct(newPlane.Normal);
                double dotP            = newPlane.Normal.DotProduct(curPlane.Normal);
                double dotSqNormalized = (dotP / llSqCur) * (dotP / llSqNew);
                double angleTol        = System.Math.PI / 1800.0;
                if (dotSqNormalized < 1.0 - angleTol * angleTol)
                {
                    resetPlane = true;
                }
            }
            Autodesk.Revit.DB.SketchPlane sp = null;

            if (!resetPlane)
            {
                double originDiff = curPlane.Normal.DotProduct(curPlane.Origin - newPlane.Origin);
                double tolerance  = 0.000001;
                if (originDiff > tolerance || originDiff < -tolerance)
                {
                    sp             = GetSketchPlaneFromCurve(c);
                    mc.SketchPlane = GetSketchPlaneFromCurve(c);
                }
                return((sp == null || mc.SketchPlane.Id == sp.Id) ? "" : sp.UniqueId);
            }

            //do reset if method is available

            bool foundMethod = false;

            if (hasMethodResetSketchPlane)
            {
                Type          CurveElementType        = typeof(Autodesk.Revit.DB.CurveElement);
                MethodInfo[]  curveElementMethods     = CurveElementType.GetMethods(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
                System.String nameOfMethodSetCurve    = "ResetSketchPlaneAndCurve";
                System.String nameOfMethodSetCurveAlt = "SetSketchPlaneAndCurve";

                foreach (MethodInfo m in curveElementMethods)
                {
                    if (m.Name == nameOfMethodSetCurve || m.Name == nameOfMethodSetCurveAlt)
                    {
                        object[] argsM = new object[2];
                        sp       = GetSketchPlaneFromCurve(c);
                        argsM[0] = sp;
                        argsM[1] = null;

                        foundMethod = true;
                        m.Invoke(mc, argsM);
                        break;
                    }
                }
            }
            if (!foundMethod)
            {
                //sp = dynRevitUtils.GetSketchPlaneFromCurve(c);
                hasMethodResetSketchPlane = false;
                needsSketchPlaneReset     = true;
                //expect exception, so try to keep old plane?
                //mc.SketchPlane = sp;
                return("");
            }

            if (sp != null && mc.SketchPlane.Id != sp.Id)
            {
                return(sp.UniqueId);
            }

            return("");
        }
 public CurveElement(DB.CurveElement value) : base(value)
 {
 }
Esempio n. 8
0
 /// <summary>
 /// Set the internal model curve along with its id's
 /// </summary>
 /// <param name="modelCurve"></param>
 protected void InternalSetCurveElement(Autodesk.Revit.DB.CurveElement curveElement)
 {
     this.InternalCurveElement = curveElement;
     this.InternalElementId = curveElement.Id;
     this.InternalUniqueId = curveElement.UniqueId;
 }