コード例 #1
0
 public static Building Building(BH.oM.Geometry.Point location)
 {
     return(new Building
     {
         Location = location,
     });
 }
コード例 #2
0
        public static BH.oM.MEP.System.WireSegment WireFromRevit(this Autodesk.Revit.DB.Electrical.Wire revitWire, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            settings = settings.DefaultIfNull();

            // Reuse a BHoM duct from refObjects it it has been converted before
            BH.oM.MEP.System.WireSegment bhomWire = refObjects.GetValue <BH.oM.MEP.System.WireSegment>(revitWire.Id);
            if (bhomWire != null)
            {
                return(bhomWire);
            }

            LocationCurve locationCurve = revitWire.Location as LocationCurve;
            Curve         curve         = locationCurve.Curve;

            BH.oM.Geometry.Point startPoint = curve.GetEndPoint(0).PointFromRevit();
            BH.oM.Geometry.Point endPoint   = curve.GetEndPoint(1).PointFromRevit();
            BH.oM.Geometry.Line  line       = BH.Engine.Geometry.Create.Line(startPoint, endPoint); // BHoM line

            // Wire
            bhomWire = BH.Engine.MEP.Create.WireSegment(line);

            //Set identifiers, parameters & custom data
            bhomWire.SetIdentifiers(revitWire);
            bhomWire.CopyParameters(revitWire, settings.ParameterSettings);
            bhomWire.SetProperties(revitWire, settings.ParameterSettings);

            refObjects.AddOrReplace(revitWire.Id, bhomWire);

            return(bhomWire);
        }
コード例 #3
0
ファイル: View3D.cs プロジェクト: chuongmep/Revit_Toolkit
        public static View View3D(this Document document, XYZ eye, XYZ target, double horizontalFieldOfView, double viewRatio = 0.5625, string viewName = null, ElementId viewTemplateId = null, ViewDetailLevel viewDetailLevel = ViewDetailLevel.Coarse)
        {
            XYZ normal       = (target - eye).Normalize();
            XYZ planarEye    = new XYZ(eye.X, eye.Y, 0);
            XYZ planarTarget = new XYZ(target.X, target.Y, 0);
            XYZ planarNormal = (planarTarget - planarEye).Normalize();

            //get vertical and horizontal angle
            double verticalAngle   = (XYZ.BasisZ.AngleTo(normal) - Math.PI / 2) * (-1);
            double horizontalAngle = XYZ.BasisX.AngleOnPlaneTo(planarNormal, XYZ.BasisZ);

            //create view orientation
            ViewOrientation3D viewOrientation3D = new ViewOrientation3D(eye, CombineHorizontalWithVerticalAngles(horizontalAngle, verticalAngle + Math.PI / 2), CombineHorizontalWithVerticalAngles(horizontalAngle, verticalAngle));

            //information can be found here
            //https://knowledge.autodesk.com/support/revit-products/learn-explore/caas/CloudHelp/cloudhelp/2014/ENU/Revit/files/GUID-A7FA8DBC-830E-482D-9B66-147399524442-htm.html

            //rotate center point to the right side, representing HFOV start point
            double    angleToRotate = Math.PI / 2;
            Transform t1            = Transform.CreateRotationAtPoint(XYZ.BasisZ, angleToRotate * -1, target);
            XYZ       rotate        = target.Add((horizontalFieldOfView / 2) * (planarNormal * -1));
            XYZ       hfovLeft      = t1.OfPoint(rotate);
            XYZ       bottomLeft    = hfovLeft.Add(((viewRatio * horizontalFieldOfView) / 2) * (viewOrientation3D.UpDirection * -1));

            //for the right
            Transform t2        = Transform.CreateRotationAtPoint(XYZ.BasisZ, angleToRotate, target);
            XYZ       hfovRight = t2.OfPoint(rotate);
            XYZ       topRight  = hfovRight.Add(((viewRatio * horizontalFieldOfView) / 2) * viewOrientation3D.UpDirection);

            //lines for top and bottom
            Line topLine    = Line.CreateBound(topRight, eye);
            Line bottomLine = Line.CreateBound(bottomLeft, eye);

            // to calculate bb max/min offset we need to perform an inverse regression estimate using y=A+B/x
            double a = 0.9995538525; //constant for THIS inverse regression
            double b = -0.08573511;  //constant for THIS inverse regression
            //get line-based element's length
            double cameraLength  = planarEye.DistanceTo(planarTarget);
            double evaluateLines = a + (b / cameraLength);

            //creates plane to project point at and retrieve cropbox.min
            BH.oM.Geometry.Plane backClippingPlane = BH.Engine.Geometry.Create.Plane(BH.Revit.Engine.Core.Convert.PointFromRevit(target), BH.Revit.Engine.Core.Convert.VectorFromRevit(viewOrientation3D.ForwardDirection));
            BH.oM.Geometry.Point pointToProject    = BH.Revit.Engine.Core.Convert.PointFromRevit(bottomLine.Evaluate(evaluateLines, true));
            BH.oM.Geometry.Point bbBhomMin         = backClippingPlane.ClosestPoint(pointToProject);
            XYZ bbMin = BH.Revit.Engine.Core.Convert.ToRevit(bbBhomMin);
            XYZ bbMax = topLine.Evaluate(evaluateLines, true);

            BoundingBoxXYZ boundingBox3DCone = new BoundingBoxXYZ();

            boundingBox3DCone.Max = bbMax;
            boundingBox3DCone.Min = bbMin;

            return(View3D(document, viewName, boundingBox3DCone, viewOrientation3D, viewTemplateId, viewDetailLevel));
        }
コード例 #4
0
ファイル: SearchMenu.cs プロジェクト: BHoM/BHoM_UI
        /*************************************/

        protected void NotifySelection(SearchItem item, BH.oM.Geometry.Point location)
        {
            if (item == null)
            {
                ItemSelected?.Invoke(this, null);
            }
            else
            {
                ItemSelected?.Invoke(this, new ComponentRequest {
                    CallerType = item.CallerType, SelectedItem = item.Item, Location = location
                });
            }
        }
コード例 #5
0
        public ROI(BH.oM.Geometry.Point start, BH.oM.Geometry.Point end)
        {
            mStartCorner  = start;
            mEndCorner    = end;
            _cutRect      = new RectangleF(StartPointS.X, StartPointS.Y, (float)Width, (float)Height);
            _id           = Guid.NewGuid();
            _motionLevels = new Dictionary <int, double>();

            _detector = new TwoFramesDifferenceDetector();
            _detector.SuppressNoise = true;

            _humanID = -1;
        }
コード例 #6
0
 public static Building Building(double elevation, double latitude, double longitude, BH.oM.Geometry.Point location)
 {
     return(new Building
     {
         Elevation = elevation,
         Latitude = latitude,
         Longitude = longitude,
         Location = location,
     });
 }
コード例 #7
0
 public void AddROI(BH.oM.Geometry.Point start, BH.oM.Geometry.Point end)
 {
     _regionsOfInterest.Add(new ROI(start, end));
     _regionsOfInterest.Last().SetStartingImage(CutROI(_regionsOfInterest.Last()));
     //_regionsOfInterest.Last().SaveStartingImage(); //Testing the division purposes
 }