Example #1
0
        internal BentBeam(Autodesk.DesignScript.Geometry.Point ptStart, Autodesk.DesignScript.Geometry.Point ptEnd, Autodesk.DesignScript.Geometry.Point ptOnArc, Autodesk.DesignScript.Geometry.Vector vOrientation)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    string handle    = SteelServices.ElementBinder.GetHandleFromTrace();
                    var    beamStart = (ptStart == null ? new Point3d() : Utils.ToAstPoint(ptStart, true));
                    var    beamEnd   = (ptEnd == null ? new Point3d() : Utils.ToAstPoint(ptEnd, true));
                    _ptOnArc = Utils.ToAstPoint(ptOnArc, true);

                    Autodesk.AdvanceSteel.Modelling.BentBeam beam = null;
                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        ProfileName profName = new ProfileName();
                        ProfilesManager.GetProfTypeAsDefault("I", out profName);

                        beam = new Autodesk.AdvanceSteel.Modelling.BentBeam(profName.Name, Vector3d.kZAxis, beamStart, _ptOnArc, beamEnd);

                        beam.WriteToDb();
                    }
                    else
                    {
                        beam = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.BentBeam;

                        if (beam != null && beam.IsKindOf(FilerObject.eObjectType.kBentBeam))
                        {
                            beam.SetSystemline(beamStart, _ptOnArc, beamEnd);
                            Utils.SetOrientation(beam, Utils.ToAstVector3d(vOrientation, true));
                        }
                        else
                        {
                            throw new System.Exception("Not a bent Beam");
                        }
                    }

                    Handle = beam.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(beam);
                }
            }
        }
Example #2
0
 public static Triple ToTriple(this Point point) => new Triple(point.X, point.Y, point.Z);
Example #3
0
 /// <summary>
 /// 判断点相等
 /// </summary>
 /// <param name="po1"></param>
 /// <param name="po2"></param>
 /// <returns></returns>
 public static bool IsEqualsTo(this Point po1, Point po2)
 {
     return(po1.IsAlmostEqualTo(po2));
 }
 /// <summary>
 /// Create an Advance Steel bent beam between two points and a point on arc
 /// </summary>
 /// <param name="start">Start point</param>
 /// <param name="end">End point</param>
 /// <param name="ptOnArc">Point on arc</param>
 /// <param name="vOrientation">Section orientation</param>
 /// <returns></returns>
 public static BentBeam ByStartPointEndPoint(Autodesk.DesignScript.Geometry.Point start, Autodesk.DesignScript.Geometry.Point end, Autodesk.DesignScript.Geometry.Point ptOnArc, Autodesk.DesignScript.Geometry.Vector vOrientation)
 {
     return(new BentBeam(start, end, ptOnArc, vOrientation));
 }
Example #5
0
        /// <summary>
        /// Create a Revit Perspective View from an Eye position and target position and Bounding Box
        /// </summary>
        /// <param name="eyePoint">Eye point in meters</param>
        /// <param name="target">Target of view in meters</param>
        /// <param name="boundingBox">Bounding box represented in meters</param>
        /// <param name="name"></param>
        /// <param name="isolateElement"></param>
        /// <returns></returns>
        public static PerspectiveView ByEyePointTargetAndBoundingBox(Autodesk.DesignScript.Geometry.Point eyePoint, Autodesk.DesignScript.Geometry.Point target, Autodesk.DesignScript.Geometry.BoundingBox boundingBox, string name, bool isolateElement)
        {
            if (boundingBox == null)
            {
                throw new ArgumentNullException("boundingBox");
            }

            if (eyePoint == null)
            {
                throw new ArgumentNullException("eyePoint");
            }

            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            return(new PerspectiveView(eyePoint.ToXyz(), target.ToXyz(), boundingBox.ToRevitType(), name, isolateElement));
        }
Example #6
0
 public static PointSupport Define(Autodesk.DesignScript.Geometry.Point point, Motions motions, [DefaultArgument("MotionsPlasticLimits.Default()")] MotionsPlasticLimits motionsPlasticLimits, Rotations rotations, [DefaultArgument("RotationsPlasticLimits.Default()")] RotationsPlasticLimits rotationsPlasticLimits, [DefaultArgument("S")] string identifier)
 {
     return(new PointSupport(Geometry.FdPoint3d.FromDynamo(point), motions, motionsPlasticLimits, rotations, rotationsPlasticLimits, identifier));
 }
        /// <summary>
        /// Compares a single curve to a list of curves to find any curves that have the same normalised vector.
        /// </summary>
        /// <param name="curve"></param>
        /// <param name="curves"></param>
        /// <search></search>
        public static List <Autodesk.DesignScript.Geometry.Curve> FindMatchingVectorCurves(this Autodesk.DesignScript.Geometry.Curve curve, List <Autodesk.DesignScript.Geometry.Curve> curves)
        {
            Autodesk.DesignScript.Geometry.Point stPt1  = curve.StartPoint;
            Autodesk.DesignScript.Geometry.Point endPt1 = curve.EndPoint;

            Autodesk.DesignScript.Geometry.Vector vec1 = Autodesk.DesignScript.Geometry.Vector.ByTwoPoints(stPt1, endPt1).Normalized();
            string str1 = vec1.ToString();

            List <string> curveList = new List <string>();

            foreach (var c in curves)
            {
                Autodesk.DesignScript.Geometry.Point stPt2  = c.StartPoint;
                Autodesk.DesignScript.Geometry.Point endPt2 = c.EndPoint;

                Autodesk.DesignScript.Geometry.Vector vec2 = Autodesk.DesignScript.Geometry.Vector.ByTwoPoints(stPt2, endPt2).Normalized();
                string str2 = vec2.ToString();
                curveList.Add(str2);

                //Dispose redundant geometry
                stPt2.Dispose();
                endPt2.Dispose();
                vec2.Dispose();
            }

            List <Autodesk.DesignScript.Geometry.Curve> matchingCurves = new List <Autodesk.DesignScript.Geometry.Curve>();

            for (int i = 0; i < curveList.Count; i++)
            {
                if (str1 == curveList[i])
                {
                    matchingCurves.Add(curves[i]);
                }
            }

            if (matchingCurves.Count == 0)
            {
                List <string> revCurveList = new List <string>();
                foreach (var c in curves)
                {
                    Autodesk.DesignScript.Geometry.Point stPt2  = c.StartPoint;
                    Autodesk.DesignScript.Geometry.Point endPt2 = c.EndPoint;

                    Autodesk.DesignScript.Geometry.Vector vec2 = Autodesk.DesignScript.Geometry.Vector.ByTwoPoints(endPt2, stPt2).Normalized();
                    string str2 = vec2.ToString();
                    revCurveList.Add(str2);

                    //Dispose redundant geometry
                    stPt2.Dispose();
                    endPt2.Dispose();
                    vec2.Dispose();
                }
                for (int i = 0; i < revCurveList.Count; i++)
                {
                    if (str1 == revCurveList[i])
                    {
                        matchingCurves.Add(curves[i]);
                    }
                }
            }

            //Dispose redundant geometry
            stPt1.Dispose();
            endPt1.Dispose();
            vec1.Dispose();

            return(matchingCurves);
        }
Example #8
0
 /// <summary>
 /// Create a Revit Room Element
 /// </summary>
 /// <param name="level">Level the room is hosted on</param>
 /// <param name="location">Location for the center of the room</param>
 /// <param name="name">Room name</param>
 /// <param name="number">Room number</param>
 /// <returns></returns>
 public static Room ByLocation(Elements.Level level, Autodesk.DesignScript.Geometry.Point location, string name = "", string number = "")
 {
     return(new Room((Autodesk.Revit.DB.Level)level.InternalElement, location.ToRevitType(true), name, number));
 }
Example #9
0
 /// <summary>
 /// Check if a point is inside of a room
 /// </summary>
 public bool IsInsideRoom(Autodesk.DesignScript.Geometry.Point point)
 {
     return(this.InternalRevitElement.IsPointInRoom(point.ToRevitType()));
 }
Example #10
0
        internal ConcreteBentBeam(string concName,
                                  Autodesk.DesignScript.Geometry.Point ptStart,
                                  Autodesk.DesignScript.Geometry.Point ptEnd,
                                  Autodesk.DesignScript.Geometry.Point ptOnArc,
                                  Autodesk.DesignScript.Geometry.Vector vOrientation,
                                  List <Property> concreteProperties)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    List <Property> defaultData     = concreteProperties.Where(x => x.Level == ".").ToList <Property>();
                    List <Property> postWriteDBData = concreteProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>();

                    string handle = SteelServices.ElementBinder.GetHandleFromTrace();

                    Point3d  beamStart  = (ptStart == null ? new Point3d() : Utils.ToAstPoint(ptStart, true));
                    Point3d  beamEnd    = (ptEnd == null ? new Point3d() : Utils.ToAstPoint(ptEnd, true));
                    Vector3d refVect    = Utils.ToAstVector3d(vOrientation, true);
                    Point3d  pointOnArc = Utils.ToAstPoint(ptOnArc, true);

                    Autodesk.AdvanceSteel.Modelling.ConcreteBentBeam concBentBeam = null;
                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        concBentBeam = new Autodesk.AdvanceSteel.Modelling.ConcreteBentBeam(concName, refVect, beamStart, pointOnArc, beamEnd);
                        if (defaultData != null)
                        {
                            Utils.SetParameters(concBentBeam, defaultData);
                        }

                        concBentBeam.WriteToDb();

                        if (postWriteDBData != null)
                        {
                            Utils.SetParameters(concBentBeam, postWriteDBData);
                        }
                    }
                    else
                    {
                        concBentBeam = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.ConcreteBentBeam;

                        if (concBentBeam != null && concBentBeam.IsKindOf(FilerObject.eObjectType.kConcreteBentBeam))
                        {
                            concBentBeam.SetSystemline(beamStart, pointOnArc, beamEnd);
                            concBentBeam.SetSysStart(beamStart);
                            concBentBeam.SetSysEnd(beamEnd);
                            concBentBeam.ProfName = concName;
                            Utils.SetOrientation(concBentBeam, refVect);

                            if (defaultData != null)
                            {
                                Utils.SetParameters(concBentBeam, defaultData);
                            }

                            if (postWriteDBData != null)
                            {
                                Utils.SetParameters(concBentBeam, postWriteDBData);
                            }
                        }
                        else
                        {
                            throw new System.Exception("Not a Bent Concrete Beam");
                        }
                    }

                    Handle = concBentBeam.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(concBentBeam);
                }
            }
        }
Example #11
0
        internal StraightBeam(Autodesk.DesignScript.Geometry.Point ptStart,
                              Autodesk.DesignScript.Geometry.Point ptEnd,
                              Autodesk.DesignScript.Geometry.Vector vOrientation,
                              int refAxis, bool crossSectionMirror,
                              List <Property> beamProperties)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    List <Property> defaultData     = beamProperties.Where(x => x.Level == ".").ToList <Property>();
                    List <Property> postWriteDBData = beamProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>();
                    Property        foundProfName   = beamProperties.FirstOrDefault <Property>(x => x.Name == "ProfName");
                    string          sectionName     = "";
                    if (foundProfName != null)
                    {
                        sectionName = (string)foundProfName.InternalValue;
                    }

                    string handle = SteelServices.ElementBinder.GetHandleFromTrace();

                    Point3d  beamStart = Utils.ToAstPoint(ptStart, true);
                    Point3d  beamEnd   = Utils.ToAstPoint(ptEnd, true);
                    Vector3d refVect   = Utils.ToAstVector3d(vOrientation, true);

                    if (string.IsNullOrEmpty(sectionName))
                    {
                        ProfileName profName = new ProfileName();
                        ProfilesManager.GetProfTypeAsDefault("I", out profName);
                        sectionName = profName.Name;
                    }

                    Autodesk.AdvanceSteel.Modelling.StraightBeam beam = null;
                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        beam = new Autodesk.AdvanceSteel.Modelling.StraightBeam(sectionName, beamStart, beamEnd, refVect);
                        if (Beam.eRefAxis.IsDefined(typeof(Beam.eRefAxis), refAxis) == true)
                        {
                            beam.RefAxis = (Beam.eRefAxis)refAxis;
                        }
                        beam.SetCrossSectionMirrored(crossSectionMirror, false);

                        if (defaultData != null)
                        {
                            Utils.SetParameters(beam, defaultData);
                        }

                        beam.WriteToDb();

                        if (postWriteDBData != null)
                        {
                            Utils.SetParameters(beam, postWriteDBData);
                        }
                    }
                    else
                    {
                        beam = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.StraightBeam;

                        if (beam != null && beam.IsKindOf(FilerObject.eObjectType.kStraightBeam))
                        {
                            string sectionType = Utils.SplitSectionName(sectionName)[0];
                            string sectionSize = Utils.SplitSectionName(sectionName)[1];
                            Utils.AdjustBeamEnd(beam, beamStart);
                            beam.SetSysStart(beamStart);
                            beam.SetSysEnd(beamEnd);
                            beam.ChangeProfile(sectionType, sectionSize);
                            if (Beam.eRefAxis.IsDefined(typeof(Beam.eRefAxis), refAxis) == true)
                            {
                                beam.RefAxis = (Beam.eRefAxis)refAxis;
                            }

                            if (defaultData != null)
                            {
                                Utils.SetParameters(beam, defaultData);
                            }

                            beam.SetCrossSectionMirrored(crossSectionMirror, false);
                            Utils.SetOrientation(beam, refVect);

                            if (postWriteDBData != null)
                            {
                                Utils.SetParameters(beam, postWriteDBData);
                            }
                        }
                        else
                        {
                            throw new System.Exception("Not a straight Beam");
                        }
                    }
                    Handle = beam.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(beam);
                }
            }
        }
 static FamilyInstance ByStartEndPoints(Point start, Point end, FamilySymbol framing_type)
 {
     throw new NotImplementedException();
 }
Example #13
0
        /// <summary>
        /// Create a Revit Tag for a Revit Element at a specified location point
        /// </summary>
        /// <param name="view">View to tag in</param>
        /// <param name="element">Element to tag</param>
        /// <param name="location">Location point</param>
        /// <param name="horizontal">Optional: Place tag horizontal, defaults to true</param>
        /// <param name="addLeader">Optional: Add a leader, defaults to false</param>
        /// <returns></returns>
        /// <search>
        /// tagelement,annotate,documentation,taglocation
        /// </search>
        public static Tag ByElementAndLocation(Revit.Elements.Views.View view, Element element, Autodesk.DesignScript.Geometry.Point location, bool horizontal = true, bool addLeader = false)
        {
            Autodesk.Revit.DB.View           revitView   = (Autodesk.Revit.DB.View)view.InternalElement;
            Autodesk.Revit.DB.XYZ            point       = location.ToRevitType(true);
            Autodesk.Revit.DB.TagMode        tagMode     = TagMode.TM_ADDBY_CATEGORY;
            Autodesk.Revit.DB.TagOrientation orientation = (horizontal) ? TagOrientation.Horizontal : TagOrientation.Vertical;

            if (!view.IsAnnotationView())
            {
                throw new Exception(Properties.Resources.ViewDoesNotSupportAnnotations);
            }

            return(new Tag(revitView, element.InternalElement, orientation, tagMode, addLeader, point));
        }
Example #14
0
 public abstract Vector GetOffset(Point newPosition, Vector viewDirection);
Example #15
0
 public abstract Vector GetOffset(Point newPosition, Vector viewDirection);
Example #16
0
        public static Inventor.Point ToPoint(this Autodesk.DesignScript.Geometry.Point xyz)
        {
            TransientGeometry transGeo = InventorServices.Persistence.PersistenceManager.InventorApplication.TransientGeometry;

            return(transGeo.CreatePoint(xyz.X, xyz.Y, xyz.Z));
        }
Example #17
0
 public abstract bool HitTest(Point source, Vector direction, out object hitObject);
Example #18
0
 public static SketchUpNET.Vertex ToSKPGeo(this Autodesk.DesignScript.Geometry.Point p)
 {
     return(new Vertex(p.X, p.Y, p.Z));
 }
Example #19
0
        public void ByCoordinates_NullFamilySymbol()
        {
            var pt = Point.ByCoordinates(0, 1, 2);

            Assert.Throws(typeof(System.ArgumentNullException), () => FamilyInstance.ByCoordinates(null, 0, 1, 2));
        }
        public static double AreaByCoordinates(IList <Autodesk.DesignScript.Geometry.Point> points)
        {
            double retVal = Double.NaN;

            try
            {
                if (points != null)
                {
                    // initialize variables
                    int    xCount  = 0;
                    int    yCount  = 0;
                    double xTotals = 0;
                    double yTotals = 0;
                    // resize the list of points to add one space, in case the provided list doesn't close
                    IList <Autodesk.DesignScript.Geometry.Point> workingPoints = new List <Autodesk.DesignScript.Geometry.Point>(points.Count + 1);
                    // copy the provided list into the new list
                    foreach (Autodesk.DesignScript.Geometry.Point pt in points)
                    {
                        workingPoints.Add(pt);
                    }
                    // check if the first and last points are the same, if not, add the first point to the end of the points list
                    if (points[0] != points[points.Count - 1])
                    {
                        double x = points[0].X;
                        double y = points[0].Y;
                        double z = points[0].Z;
                        workingPoints.Add(Autodesk.DesignScript.Geometry.Point.ByCoordinates(x, y, z));
                    }
                    // step thru the list and calculate the values
                    foreach (Autodesk.DesignScript.Geometry.Point pt in workingPoints)
                    {
                        Autodesk.DesignScript.Geometry.Point coord = pt;
                        // if we're not working with the last point
                        if (yCount < workingPoints.Count - 1)
                        {
                            // multiply the current points X by the next points Y
                            // and add the value to the previous set of values
                            Autodesk.DesignScript.Geometry.Point nextYPoint = workingPoints[yCount + 1];
                            xTotals = xTotals + (coord.X * nextYPoint.Y);
                            yCount  = yCount + 1;
                        }
                        // if we're not working with the last point
                        if (xCount < workingPoints.Count - 1)
                        {
                            // multiply the current points Y by the next points X
                            // and add the value to the previous set of values
                            Autodesk.DesignScript.Geometry.Point nextXPoint = workingPoints[xCount + 1];
                            yTotals = yTotals + (coord.Y * nextXPoint.X);
                            xCount  = xCount + 1;
                        }
                    }
                    // subtract the X values from the Y values to get the area
                    retVal = Math.Abs((xTotals - yTotals) / 2);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            finally
            {
            }
            return(retVal);
        }
        internal BentBeam(Autodesk.DesignScript.Geometry.Point ptStart, Autodesk.DesignScript.Geometry.Point ptEnd, Autodesk.DesignScript.Geometry.Point ptOnArc, Autodesk.DesignScript.Geometry.Vector vOrientation)
        {
            //use lock just to be safe
            //AutoCAD does not support multithreaded access
            lock (myLock)
            {
                //lock the document and start transaction
                using (var _CADAccess = new AdvanceSteel.Services.ObjectAccess.CADContext())
                {
                    string handle    = AdvanceSteel.Services.ElementBinder.GetHandleFromTrace();
                    var    beamStart = (ptStart == null ? new Point3d() : Utils.ToAstPoint(ptStart, true));
                    var    beamEnd   = (ptEnd == null ? new Point3d() : Utils.ToAstPoint(ptEnd, true));
                    _ptOnArc = Utils.ToAstPoint(ptOnArc, true);

                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        ProfileName profName = new ProfileName();
                        ProfilesManager.GetProfTypeAsDefault("I", out profName);

                        var myBeam = new Autodesk.AdvanceSteel.Modelling.BentBeam(profName.Name, Vector3d.kZAxis, beamStart, _ptOnArc, beamEnd);

                        myBeam.WriteToDb();
                        handle = myBeam.Handle;
                    }

                    var beam = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.BentBeam;

                    if (beam != null && beam.IsKindOf(FilerObject.eObjectType.kBentBeam))
                    {
                        beam.SetSystemline(beamStart, _ptOnArc, beamEnd);
                        Utils.SetOrientation(beam, Utils.ToAstVector3d(vOrientation, true));
                    }
                    else
                    {
                        throw new System.Exception("Not a bent Beam");
                    }

                    Handle = handle;

                    AdvanceSteel.Services.ElementBinder.CleanupAndSetElementForTrace(beam);
                }
            }
        }
Example #22
0
 /// <summary>
 /// Create an Advance Steel tapered beam
 /// </summary>
 /// <param name="start">Start point</param>
 /// <param name="end">End point</param>
 /// <param name="vOrientation">Section orientation</param>
 /// <returns></returns>
 public static TaperedBeam ByStartPointEndPoint(Autodesk.DesignScript.Geometry.Point start, Autodesk.DesignScript.Geometry.Point end, Autodesk.DesignScript.Geometry.Vector vOrientation)
 {
     return(new TaperedBeam(start, end, vOrientation));
 }
Example #23
0
        /// <summary>
        /// Create a Revit Perspective View from an Eye position and target position and Element
        /// </summary>
        /// <param name="eyePoint"></param>
        /// <param name="target"></param>
        /// <param name="element"></param>
        /// <param name="name"></param>
        /// <param name="isolateElement"></param>
        /// <returns></returns>
        public static PerspectiveView ByEyePointTargetAndElement(Autodesk.DesignScript.Geometry.Point eyePoint, Autodesk.DesignScript.Geometry.Point target, Element element, string name, bool isolateElement)
        {
            if (eyePoint == null)
            {
                throw new ArgumentNullException("eyePoint");
            }

            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            return(new PerspectiveView(eyePoint.ToXyz(), target.ToXyz(), element.InternalElement, name, isolateElement));
        }
 public static Point3d ToRhinoType(Autodesk.DesignScript.Geometry.Point p) => new Point3d(p.X, p.Y, p.Z);
Example #25
0
 public static Point Duplicate(this Point point) => Point.ByCoordinates(point.X, point.Y, point.Z);
Example #26
0
 /// <summary>
 /// 判断点是否重合
 /// </summary>
 /// <param name="point1"></param>
 /// <param name="point2"></param>
 /// <returns></returns>
 public static bool JudgeDuplicatePoints(Autodesk.DesignScript.Geometry.Point point1, Autodesk.DesignScript.Geometry.Point point2)
 {
     if (point1.IsAlmostEqualTo(point2))
     {
         return(true);
     }
     //if (point1.X == point2.X && point1.Y == point2.Y && point1.Z == point2.Z)
     //{
     //    return true;
     //}
     return(false);
 }
Example #27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="category"></param>
        /// <param name="refresh"></param>
        /// <returns></returns>
        public static List <List <Autodesk.DesignScript.Geometry.Point> > IntersectionPointsByCategory(Revit.Elements.Category category, Document document = null, bool refresh = false)
        {
            List <Revit.Elements.Element>         elList = new List <Revit.Elements.Element>();
            List <List <Revit.Elements.Element> > inList = new List <List <Revit.Elements.Element> >();

            List <List <Autodesk.DesignScript.Geometry.Point> > cPoints = new List <List <Autodesk.DesignScript.Geometry.Point> >();

            if (refresh)
            {
                BuiltInCategory myCatEnum = (BuiltInCategory)Enum.Parse(typeof(BuiltInCategory), category.Id.ToString(), true);
                Document        doc       = DocumentManager.Instance.CurrentDBDocument;

                //UIApplication uiapp = DocumentManager.Instance.CurrentUIApplication;
                //Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
                //UIDocument uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument;

                ElementCategoryFilter    filter    = new ElementCategoryFilter(myCatEnum);
                ElementCategoryFilter    exclude   = new ElementCategoryFilter(BuiltInCategory.OST_GenericModel);
                FilteredElementCollector excluded  = new FilteredElementCollector(doc).WherePasses(exclude);
                FilteredElementCollector collector = new FilteredElementCollector(doc).WherePasses(filter).WhereElementIsNotElementType();
                collector.Excluding(excluded.ToElementIds());

                foreach (Autodesk.Revit.DB.Element e in collector)
                {
                    DynaFunctions f = new DynaFunctions();


                    ElementIntersectsElementFilter interFiler = new ElementIntersectsElementFilter(e);
                    FilteredElementCollector       interElem  = new FilteredElementCollector(document).WherePasses(interFiler).WhereElementIsNotElementType();
                    if (interElem.GetElementCount() > 0)
                    {
                        List <Autodesk.Revit.DB.Solid> elGeoms = new List <Autodesk.Revit.DB.Solid>();
                        GeometryElement geomEl = e.get_Geometry(new Options());
                        foreach (GeometryObject geomObj in geomEl)
                        {
                            elGeoms.Add(geomObj as Autodesk.Revit.DB.Solid);
                        }

                        elList.Add(doc.GetElement(e.Id).ToDSType(true));
                        List <Autodesk.Revit.DB.Solid> iS = new List <Autodesk.Revit.DB.Solid>();
                        List <Autodesk.DesignScript.Geometry.Point> cPoint = new List <Autodesk.DesignScript.Geometry.Point>();
                        List <Autodesk.DesignScript.Geometry.Solid> iSS    = new List <Autodesk.DesignScript.Geometry.Solid>();
                        foreach (Autodesk.Revit.DB.Element el in interElem)
                        {
                            GeometryElement intEl = el.get_Geometry(new Options());
                            foreach (GeometryObject intObj in intEl)
                            {
                                iS.Add(intObj as Autodesk.Revit.DB.Solid);
                            }
                        }
                        foreach (Autodesk.Revit.DB.Solid s0 in elGeoms)
                        {
                            foreach (Autodesk.Revit.DB.Solid s1 in iS)
                            {
                                Autodesk.Revit.DB.Solid i = BooleanOperationsUtils.ExecuteBooleanOperation(s0, s1, BooleanOperationsType.Intersect);
                                if (i != null)
                                {
                                    iSS.Add(Revit.GeometryConversion.RevitToProtoSolid.ToProtoType(i));
                                    DisplayUnitType dt = doc.GetUnits().GetFormatOptions(UnitType.UT_Length).DisplayUnits;

                                    XYZ coord = new XYZ(f.convertToUnit(i.ComputeCentroid().X, dt), f.convertToUnit(i.ComputeCentroid().Y, dt), f.convertToUnit(i.ComputeCentroid().Z, dt));
                                    //XYZ coord = new XYZ(i.ComputeCentroid().X, i.ComputeCentroid().Y, i.ComputeCentroid().Z);
                                    Autodesk.DesignScript.Geometry.Point p = Autodesk.DesignScript.Geometry.Point.ByCoordinates(coord.X, coord.Y, coord.Z);
                                    cPoint.Add(p);
                                }
                            }
                        }
                        cPoints.Add(cPoint);
                    }
                }
            }
            return(cPoints);
        }
 /// <summary>
 /// Create an Advance Steel compound beam
 /// </summary>
 /// <param name="start">Start point</param>
 /// <param name="end">End point</param>
 /// <param name="vOrientation">Section orientation</param>
 /// <param name="sectionName">Section name</param>
 /// <returns></returns>
 public static CompoundBeam ByStartPointEndPoint(Autodesk.DesignScript.Geometry.Point start, Autodesk.DesignScript.Geometry.Point end, Autodesk.DesignScript.Geometry.Vector vOrientation, string sectionName)
 {
     return(new CompoundBeam(start, end, vOrientation, sectionName));
 }
Example #29
0
        /// <summary>
        /// This node will add a gridline at the specified place on the curtain wall grid.
        /// </summary>
        /// <param name="curtainGrid">The curtain grid to add a gridline to.</param>
        /// <param name="locationPoint">XYZ location to place grid</param>
        /// <param name="isUGridline">Is this gridline horizontal?</param>
        /// <returns name="curtainGridLine">The new gridline</returns>
        /// <search>
        /// curtainwall, rhythm
        /// </search>
        public static List <global::Revit.Elements.Element> AddGridLineByPoint(Autodesk.Revit.DB.CurtainGrid curtainGrid, Autodesk.DesignScript.Geometry.Point locationPoint, bool isUGridline)
        {
            List <Autodesk.Revit.DB.XYZ> revitPoint = new List <Autodesk.Revit.DB.XYZ>();

            revitPoint.Add(locationPoint.ToRevitType());
            List <global::Revit.Elements.Element> newElements = new List <global::Revit.Elements.Element>();

            Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;
            TransactionManager.Instance.EnsureInTransaction(doc);
            foreach (var point in revitPoint)
            {
                newElements.Add(curtainGrid.AddGridLine(isUGridline, point, false).ToDSType(true));
            }
            ;
            TransactionManager.Instance.TransactionTaskDone();

            return(newElements);
        }
Example #30
0
        /// <summary>
        /// Create a Revit Grid Element in a project between two end points
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public static Grid ByStartPointEndPoint(Autodesk.DesignScript.Geometry.Point start, Autodesk.DesignScript.Geometry.Point end)
        {
            if (Document.IsFamilyDocument)
            {
                throw new Exception(Properties.Resources.GridCreationFailure);
            }

            if (start == null)
            {
                throw new ArgumentNullException("start");
            }

            if (end == null)
            {
                throw new ArgumentNullException("end");
            }

            var line = Autodesk.Revit.DB.Line.CreateBound(start.ToXyz(), end.ToXyz());

            return(new Grid(line));
        }
Example #31
0
 public abstract bool HitTest(Point source, Vector direction, out object hitObject);
Example #32
0
 public static PointSupport Hinged(Autodesk.DesignScript.Geometry.Point point, [DefaultArgument("S")] string identifier)
 {
     return(PointSupport.Hinged(Geometry.FdPoint3d.FromDynamo(point), identifier));
 }
Example #33
0
        /// <summary>
        /// Form a Refernece plane from two end points in the Active view.  The cut vector is the Z Axis.
        /// </summary>
        /// <param name="start">The location where the bubble will be located</param>
        /// <param name="end">The other end</param>
        /// <returns></returns>
        public static ReferencePlane ByStartPointEndPoint( Point start, Point end )
        {
            if (start == null)
            {
                throw new ArgumentNullException("start");
            }

            if (end == null)
            {
                throw new ArgumentNullException("end");
            }

            return new ReferencePlane(  start.ToXyz(), 
                                        end.ToXyz(),
                                        (end.ToXyz() - start.ToXyz()).GetPerpendicular(),
                                        Document.ActiveView);
        }
Example #34
0
        public static Dictionary <string, Autodesk.DesignScript.Geometry.Plane> GetPlaneOffsetByCentre(Autodesk.DesignScript.Geometry.Point centrePoint,
                                                                                                       Autodesk.DesignScript.Geometry.Vector planeNormal,
                                                                                                       double distance)
        {
            Dictionary <string, Autodesk.DesignScript.Geometry.Plane> ret = new Dictionary <string, Autodesk.DesignScript.Geometry.Plane>();

            using (var ctx = new SteelServices.DocContext())
            {
                Point3d  orginPoint = Utils.ToAstPoint(centrePoint, true);
                Vector3d posVector  = Utils.ToAstVector3d(planeNormal, true);
                Vector3d negVector  = new Vector3d(posVector).Negate();
                Point3d  posPoint   = new Point3d(orginPoint).Add(posVector * Utils.ToInternalDistanceUnits(distance, true));
                Point3d  negPoint   = new Point3d(orginPoint).Add(negVector * Utils.ToInternalDistanceUnits(distance, true));
                ret["PlanePositive"] = (Autodesk.DesignScript.Geometry.Plane.ByOriginNormal(Utils.ToDynPoint(posPoint, true), planeNormal));
                ret["PlaneNegative"] = (Autodesk.DesignScript.Geometry.Plane.ByOriginNormal(Utils.ToDynPoint(negPoint, true), planeNormal));
            }
            return(ret);
        }