Exemple #1
0
        // for https://forums.autodesk.com/t5/revit-api-forum/how-to-calculate-the-center-point-of-elbow/m-p/9803893
        /// <summary>
        /// Return elbow connectors.
        /// Return null if the given element is not a
        /// family instance with exactly two connectors.
        /// </summary>
        List <Connector> GetElbowConnectors(Element e)
        {
            List <Connector> cons = null;
            FamilyInstance   fi   = e as FamilyInstance;

            if (null != fi)
            {
                MEPModel m = fi.MEPModel;
                if (null != m)
                {
                    ConnectorManager cm = m.ConnectorManager;
                    if (null != cm)
                    {
                        ConnectorSet cs = cm.Connectors;
                        if (2 == cs.Size)
                        {
                            cons = new List <Connector>(2);
                            bool first = true;
                            foreach (Connector c in cs)
                            {
                                if (first)
                                {
                                    cons[0] = c;
                                }
                                else
                                {
                                    cons[1] = c;
                                }
                            }
                        }
                    }
                }
            }
            return(cons);
        }
        // for https://forums.autodesk.com/t5/revit-api-forum/how-to-calculate-the-center-point-of-elbow/m-p/9803893
        /// <summary>
        /// Return elbow connector transforms.
        /// Return null if the given element is not a
        /// family instance with exactly two connectors.
        /// </summary>
        List <Transform> GetElbowConnectorTransforms(Element e)
        {
            List <Transform> xs = null;
            FamilyInstance   fi = e as FamilyInstance;

            if (null != fi)
            {
                MEPModel m = fi.MEPModel;
                if (null != m)
                {
                    ConnectorManager cm = m.ConnectorManager;
                    if (null != cm)
                    {
                        ConnectorSet cs = cm.Connectors;
                        if (2 == cs.Size)
                        {
                            xs = new List <Transform>(2);
                            bool first = true;
                            foreach (Connector c in cs)
                            {
                                if (first)
                                {
                                    xs[0] = c.CoordinateSystem;
                                }
                                else
                                {
                                    xs[1] = c.CoordinateSystem;
                                }
                            }
                        }
                    }
                }
            }
            return(xs);
        }
Exemple #3
0
        /// <summary>
        /// Соединяет два заданных элемента в точке p.
        /// </summary>
        /// <exception cref="ArgumentException">Возникает, если один из элементов не имеет соединителей
        /// </exception>
        public static void Connect(
            XYZ p,
            Element a,
            Element b)
        {
            ConnectorManager cm = GetConnectorManager(a);

            if (null == cm)
            {
                throw new ArgumentException(
                          "Элемент А не имеет соединителей.");
            }

            Connector ca = GetConnectorClosestTo(
                cm.Connectors, p);

            cm = GetConnectorManager(b);

            if (null == cm)
            {
                throw new ArgumentException(
                          " Элемент В не имеет соединителей.");
            }

            Connector cb = GetConnectorClosestTo(
                cm.Connectors, p);

            ca.ConnectTo(cb);
            //cb.ConnectTo( ca );
        }
Exemple #4
0
        public static Connector Connector(this ConnectorManager connectorManager, XYZ xYZ, ConnectorType connectorType = ConnectorType.End, double tolerance = Core.Tolerance.MacroDistance)
        {
            if (connectorManager == null || xYZ == null)
            {
                return(null);
            }

            ConnectorSet connectorSet = connectorManager.Connectors;

            if (connectorSet == null)
            {
                return(null);
            }

            double tolerance_Temp = tolerance;

#if Revit2017 || Revit2018 || Revit2019 || Revit2020
            tolerance_Temp = UnitUtils.ConvertToInternalUnits(tolerance_Temp, DisplayUnitType.DUT_METERS);
#else
            tolerance_Temp = UnitUtils.ConvertToInternalUnits(tolerance_Temp, UnitTypeId.Meters);
#endif

            foreach (Connector connector in connectorSet)
            {
                if (connector.ConnectorType == connectorType && connector.Origin.DistanceTo(xYZ) <= tolerance_Temp)
                {
                    return(connector);
                }
            }

            return(null);
        }
 public static void Initialize()
 {
     Configuration.StorageBaseFolder = FileSystem.Current.LocalStorage;
     Websockets.Droid.WebsocketConnection.Link();
     ConnectorManager.SetConnector(typeof(WebSocketBaseConnector));
     BaseLogger.Logger = typeof(AndroidLogger);
 }
Exemple #6
0
        static public DuctOrientation GetDuctOrientation(ConnectorManager conMngr)
        {
            XYZ    orientation = GetDuctDirection(conMngr);
            double angleToZ    = orientation.AngleTo(XYZ.BasisZ);

            if (orientation.IsAlmostEqualTo(XYZ.BasisZ) || orientation.IsAlmostEqualTo(XYZ.BasisZ.Negate()))
            {
                return(DuctOrientation.StraightVertical);
            }
            else if (orientation.IsAlmostEqualTo(new XYZ(orientation.X, orientation.Y, 0)))
            {
                return(DuctOrientation.Horizontal);
            }
            // угол между Z и вектором от 60 до 120 градусов
            else if (angleToZ > (Math.PI / 3) && angleToZ < (2 * Math.PI / 3))
            {
                return(DuctOrientation.AlmostHorizontal);
            }
            // угол между Z и вектором больше 150 градусов или меньше 30
            else if (angleToZ > (5 * Math.PI / 6) || angleToZ < (Math.PI / 6))
            {
                return(DuctOrientation.AlmostVertical);
            }
            else
            {
                return(DuctOrientation.Angled);
            }
        }
Exemple #7
0
        /// <summary>
        /// Return the element's connector at the given
        /// location, and its other connector as well,
        /// in case there are exactly two of them.
        /// </summary>
        /// <param name="e">An element, e.g. duct, pipe or family instance</param>
        /// <param name="location">The location of one of its connectors</param>
        /// <param name="otherConnector">The other connector, in case there are just two of them</param>
        /// <returns>The connector at the given location</returns>
        static Connector GetConnectorAt(
            Element e,
            XYZ location,
            out Connector otherConnector)
        {
            otherConnector = null;

            Connector targetConnector = null;

            ConnectorManager cm = GetConnectorManager(e);

            bool hasTwoConnectors = 2 == cm.Connectors.Size;

            foreach (Connector c in cm.Connectors)
            {
                if (c.Origin.IsAlmostEqualTo(location))
                {
                    targetConnector = c;

                    if (!hasTwoConnectors)
                    {
                        break;
                    }
                }
                else if (hasTwoConnectors)
                {
                    otherConnector = c;
                }
            }
            return(targetConnector);
        }
Exemple #8
0
 static public Curve FindDuctCurve(ConnectorManager conMngr)
 {
     try
     {
         List <Connector> connectors     = GetConnectors(conMngr);
         List <Connector> HvacConnectors = connectors.Where(x => x.Domain == Domain.DomainHvac || x.Domain == Domain.DomainPiping).ToList();
         List <XYZ>       connectorsPts  = HvacConnectors.Select(x => x.Origin).ToList();
         Curve            curve;
         if (connectorsPts.Count == 2)
         {
             curve = Line.CreateBound(connectorsPts[0], connectorsPts[1]);;
             return(curve);
         }
         else
         {
             // решение супер неудачное потому что дает много ложных срабатываний
             // ну а что поделать
             curve = FindLongestCurveFromPoints(connectorsPts);
         }
         return(curve);
     }
     catch (Autodesk.Revit.Exceptions.InvalidOperationException)
     {
         return(null);
     }
 }
Exemple #9
0
        //
        //関数:
        //  説明:
        //      ノードを更新
        //      EventControllerに変更を反映させます
        //      Transitionは設定しなおされます
        //      変更内容はrect, tranditionsです
        //
        void UpdateEventCtrlNode()
        {
            //各ノードに対する処理
            foreach (var node in nodes.Values)
            {
                var transitions = new List <SerializableTransition>();
                foreach (var junction in node.junctionList)
                {
                    //Exit部分のジャンクションを対象とする
                    if (junction.side == JunctionSide.Right)
                    {
                        var connector = ConnectorManager.GetConnector(node, junction);
                        if (connector != null)
                        {
                            //
                            var transition = new SerializableTransition(connector.conditions, currentLayer.serializableEventNodeList.IndexOf(connector.EndNode.eventNode));
                            transitions.Add(transition);
                        }
                    }
                }

                //ノードを更新
                node.eventNode.rect = node.Rect;
                node.eventNode.outputTransitions = transitions;
            }
        }
Exemple #10
0
        private bool VerifyUnusedConnectors(FamilyInstance fi)
        {
            bool hasUnusedElectricalConnector = false;

            try
            {
                MEPModel mepModel = fi.MEPModel;
                if (null == mepModel)
                {
                    return(hasUnusedElectricalConnector);
                }

                ConnectorManager cm = mepModel.ConnectorManager;
                ConnectorSet     unusedConnectors = cm.UnusedConnectors;
                if (null == unusedConnectors || unusedConnectors.IsEmpty)
                {
                    return(hasUnusedElectricalConnector);
                }

                foreach (Connector connector in unusedConnectors)
                {
                    if (connector.Domain == Domain.DomainElectrical)
                    {
                        hasUnusedElectricalConnector = true;
                        break;
                    }
                }
            }
            catch (Exception)
            {
                return(hasUnusedElectricalConnector);
            }

            return(hasUnusedElectricalConnector);
        }
Exemple #11
0
        /// <summary>
        /// Connect two MEP elements at a given point p.
        /// </summary>
        /// <exception cref="ArgumentException">Thrown if
        /// one of the given elements lacks connectors.
        /// </exception>
        public static void Connect(
            XYZ p,
            Element a,
            Element b)
        {
            ConnectorManager cm = GetConnectorManager(a);

            if (null == cm)
            {
                throw new ArgumentException(
                          "Element a has no connectors.");
            }

            Connector ca = GetConnectorClosestTo(
                cm.Connectors, p);

            cm = GetConnectorManager(b);

            if (null == cm)
            {
                throw new ArgumentException(
                          "Element b has no connectors.");
            }

            Connector cb = GetConnectorClosestTo(
                cm.Connectors, p);

            ca.ConnectTo(cb);
            //cb.ConnectTo( ca );
        }
        public static List <ConnectorManager> GetConnectorManagers(this ConnectorManager connectorManager)
        {
            if (connectorManager == null)
            {
                return(null);
            }

            Element element = connectorManager.Owner;
            List <ConnectorManager> result = new List <ConnectorManager>();

            foreach (Connector connector in connectorManager.Connectors)
            {
                foreach (Connector connector_Ref in connector.AllRefs)
                {
                    if (connector_Ref.Owner.Id != element.Id && !(connector_Ref.Owner is MEPSystem) && !(connector_Ref.Owner is InsulationLiningBase))
                    {
                        if (result.Find(x => x.Owner.Id == connector_Ref.ConnectorManager.Owner.Id) == null)
                        {
                            result.Add(connector_Ref.ConnectorManager);
                        }
                    }
                }
            }

            return(result);
        }
Exemple #13
0
        /// <summary>
        /// Функция для заполнения коллекции классов вершин и рёбер.
        /// </summary>
        /// <param name="selectedElements">элементы систем.</param>
        /// <returns>Коллекция.</returns>
        private List <Vertex> GetListVertexAndEdges(FilteredElementCollector selectedElements)
        {
            List <Vertex> vertices = new List <Vertex>();
            List <Edge>   edges;

            foreach (Element element in selectedElements)
            {
                ConnectorManager vertex = (element as FamilyInstance).MEPModel.ConnectorManager;

                // Цикл по всем рёбрам вершины.
                edges = new List <Edge>();
                foreach (Connector vertexConnector in vertex.Connectors)
                {
                    foreach (Connector edge in vertexConnector.AllRefs)
                    {
                        edges.Add(new Edge()
                        {
                            IdEdge = edge.Owner.Id.IntegerValue, IsVisited = false, EdgeWidth = 0
                        });
                    }
                }
                vertices.Add(new Vertex()
                {
                    Edges = edges, IdVertex = vertex.Owner.Id.IntegerValue, IsVisited = false
                });
                edges = null;
            }

            return(vertices);
        }
Exemple #14
0
        public void Test1()
        {
            ConnectorManager.Register(new Mysql(connectString));

            Admin admin2 = (Admin)Model.Query <Admin>().Where("id", 1).FindOne();

            Assert.AreEqual(1, admin2.Id);
        }
Exemple #15
0
 public static void Initial()
 {
     // PlayerPrefs.DeleteAll();
     // ここで全てのデータを取得する
     NodeId.Init();
     Init();
     ConnectorManager.Init();
 }
Exemple #16
0
        void Init()
        {
            wantsMouseMove = true;
            ConnectorManager.Init();
            NodeManager.Init();

            Instance = this;
        }
Exemple #17
0
        Stream(ArrayList data, ConnectorManager connectorMgr)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(ConnectorManager)));

            data.Add(new Snoop.Data.Enumerable("Connectors", connectorMgr.Connectors));
            data.Add(new Snoop.Data.Enumerable("Unused connectors", connectorMgr.UnusedConnectors));
            data.Add(new Snoop.Data.Object("Owner", connectorMgr.Owner));
        }
    public void Viewdata()
    {
        string _2digit    = node_A.GetBase64();
        string tmp_2digit = ConnectorManager.GetBase64();

        _2digit         += tmp_2digit;
        inputField1.text = StringToBase64(_2digit);
    }
Exemple #19
0
        public static Connector GetOpenConnector(Element element, Connector inputConnector, MEPSystem system)
        {
            Connector        openConnector = null;
            ConnectorManager cm            = null;

            if (element is FamilyInstance)
            {
                FamilyInstance fi = element as FamilyInstance;
                cm = fi.MEPModel.ConnectorManager;
            }
            else
            {
                MEPCurve mepCurve = element as MEPCurve;
                cm = mepCurve.ConnectorManager;
            }

            foreach (Connector conn in cm.Connectors)
            {
                if (conn.MEPSystem == null || !conn.MEPSystem.Id.IntegerValue.Equals(system.Id.IntegerValue))
                {
                    continue;
                }

                ////if (conn.MEPSystem == null || !RemoveNumInString(conn.MEPSystem.Name).Equals(RemoveNumInString(m_system.Name)))
                ////    continue;


                if (inputConnector != null && conn.IsConnectedTo(inputConnector))
                {
                    continue;
                }

                if (!conn.IsConnected)
                {
                    openConnector = conn;
                    break;
                }

                foreach (Connector refConnector in conn.AllRefs)
                {
                    if (refConnector.ConnectorType != ConnectorType.End ||
                        refConnector.Owner.Id.IntegerValue.Equals(conn.Owner.Id.IntegerValue))
                    {
                        continue;
                    }
                    if (inputConnector != null && refConnector.Owner.Id.IntegerValue.Equals(inputConnector.Owner.Id.IntegerValue))
                    {
                        continue;
                    }
                    openConnector = GetOpenConnector(refConnector.Owner, conn, system);
                    if (openConnector != null)
                    {
                        return(openConnector);
                    }
                }
            }
            return(openConnector);
        }
Exemple #20
0
        public MainControl()
        {
            InitializeComponent();

            Options.Increment = 0;
            var maxSize = new Size(FixedWidth, _maxHeight);

            Options.Horizontal    = Size = mainTable.Size = maxSize;
            Options.MaxHorizontal = MaximumSize = mainTable.MaximumSize = maxSize;
            Options.MinHorizontal = MinimumSize = mainTable.MinimumSize = new Size(FixedWidth, _minHeight);

            try
            {
                _settingsManager = new SettingsManager();
                var audioBandAppearance = _settingsManager.AudioBandSettings.AudioBandAppearance;
                _settingsWindow          = new SettingsWindow(audioBandAppearance);
                _settingsWindow.Closing += SettingsWindowOnClosing;

                ResetState();
                _audioBandViewModel.PropertyChanged += AudioBandViewModelOnPropertyChanged;
                SizeChanged += OnSizeChanged;

                nowPlayingText.DataBindings.Add(nameof(nowPlayingText.NowPlayingText), _audioBandViewModel, nameof(AudioBandViewModel.NowPlayingText));
                nowPlayingText.DataBindings.Add(nameof(nowPlayingText.ArtistFont), audioBandAppearance, nameof(AudioBandAppearance.NowPlayingArtistFont));
                nowPlayingText.DataBindings.Add(nameof(nowPlayingText.ArtistColor), audioBandAppearance, nameof(AudioBandAppearance.NowPlayingArtistColor));
                nowPlayingText.DataBindings.Add(nameof(nowPlayingText.TrackNameFont), audioBandAppearance, nameof(AudioBandAppearance.NowPlayingTrackNameFont));
                nowPlayingText.DataBindings.Add(nameof(nowPlayingText.TrackNameColor), audioBandAppearance, nameof(AudioBandAppearance.NowPlayingTrackNameColor));
                albumArt.DataBindings.Add(nameof(albumArt.Image), _audioBandViewModel, nameof(AudioBandViewModel.AlbumArt));
                audioProgress.DataBindings.Add(nameof(audioProgress.Progress), _audioBandViewModel, nameof(AudioBandViewModel.AudioProgress));
                audioProgress.DataBindings.Add(nameof(audioProgress.ForeColor), audioBandAppearance, nameof(AudioBandAppearance.TrackProgressColor));
                audioProgress.DataBindings.Add(nameof(audioProgress.BackColor), audioBandAppearance, nameof(AudioBandAppearance.TrackProgressBackColor));
                previousButton.DataBindings.Add(nameof(previousButton.Image), _audioBandViewModel, nameof(AudioBandViewModel.PreviousButtonBitmap));
                playPauseButton.DataBindings.Add(nameof(playPauseButton.Image), _audioBandViewModel, nameof(AudioBandViewModel.PlayPauseButtonBitmap));
                nextButton.DataBindings.Add(nameof(nextButton.Image), _audioBandViewModel, nameof(AudioBandViewModel.NextButtonBitmap));

                _connectorManager = new ConnectorManager();
                _connectorManager.PluginsChanged += ConnectorManagerOnPluginsChanged;
                Options.ContextMenuItems          = BuildContextMenu();

                ApplySettings();
            }
            catch (ReflectionTypeLoadException e)
            {
                _logger.Error(e);
                foreach (var loaderException in e.LoaderExceptions)
                {
                    _logger.Error(loaderException);
                }

                throw;
            }
            catch (Exception e)
            {
                _logger.Error(e);
                throw;
            }
        }
        public void DeleteTransition(object obj)
        {
            JunctionPosition position = obj as JunctionPosition;

            if (ConnectorManager.IsConnected(this, (JunctionPosition)position))
            {
                ConnectorManager.Disconnect(this, position);
            }
        }
        void MakeTransition(object obj)
        {
            JunctionPosition position = obj as JunctionPosition;

            if (!ConnectorManager.IsConnected(this, (JunctionPosition)position))
            {
                ConnectorManager.StartConnecting(this, (JunctionPosition)position);
            }
        }
Exemple #23
0
    public bool ConnectHost(string id, string pass, string hostIp)
    {
        if (connector == null)
        {
            connector = GameObject.Find("ConnectorManager").GetComponent <ConnectorManager>();
        }
        bool res = connector.ConnectToHost(id, pass, hostIp);

        return(res);
    }
Exemple #24
0
        public void Test2()
        {
            ConnectorManager.Register(new Mysql(connectString));

            var admin = new Admin {
                UserName = "******"
            };

            admin.Save();
        }
Exemple #25
0
        /// <summary>
        /// Return the connector on the element
        /// closest to the given point.
        /// </summary>
        public static Connector GetConnectorClosestTo(
            Element e,
            XYZ p)
        {
            ConnectorManager cm = GetConnectorManager(e);

            return(null == cm
              ? null
              : GetConnectorClosestTo(cm.Connectors, p));
        }
Exemple #26
0
 void minusClick()
 {
     clickCount--;
     hgt       = 80 + 25 * (clickCount - 1);
     this.rect = new Rect(this.rect.x, this.rect.y, width, hgt);
     conditions.RemoveAt(clickCount - 1);
     if (ConnectorManager.IsConnected(this, clickCount))
     {
         ConnectorManager.Disconnect(this, clickCount);
     }
 }
Exemple #27
0
 public static void WriteConnectorManager(ConnectorManager connectorManager)
 {
     Trace.WriteLine("+Connectors");
     Trace.Indent();
     WriteConnectorSet2(connectorManager.Connectors);
     Trace.Unindent();
     Trace.WriteLine("+UnusedConnectors");
     Trace.Indent();
     WriteConnectorSet2(connectorManager.UnusedConnectors);
     Trace.Unindent();
 }
Exemple #28
0
        public Model.Model FindOne()
        {
            var entity = ConnectorManager.GetConnector().FindOne(this);

            if (entity == null)
            {
                return(null);
            }

            return(EntityToModel(entity));
        }
Exemple #29
0
 public void Save()
 {
     if (!IsExists)
     {
         ConnectorManager.GetConnector().Insert(this);
     }
     else
     {
         ConnectorManager.GetConnector().Update(this);
     }
 }
Exemple #30
0
    public void ClearData()
    {
        nodes[current_type].Clear();
        NodeId.DeleteAll(current_type);
        ConnectorManager.DeleteData();

        /*NodeId.Init();
         * Init();
         * ConnectorManager.Init();*/
        // PlayerPrefs.DeleteAll();
    }
 /// <summary>
 /// Convenience method to get the secondary connector from the specified connector manager.
 /// </summary>
 /// <param name="cm">
 /// The connector manager.
 /// </param>
 /// <returns>
 /// Returns the secondary connector from the connector manager.
 /// </returns>
 Connector GetSecondaryConnector(ConnectorManager cm)
 {
     foreach (Connector cn in cm.Connectors)
     {
         MEPConnectorInfo info = cn.GetMEPConnectorInfo();
         if (info.IsSecondary)
             return cn;
     }
     return null;
 }
        Stream(ArrayList data, ConnectorManager connectorMgr)
      {
         data.Add(new Snoop.Data.ClassSeparator(typeof(ConnectorManager)));

         data.Add(new Snoop.Data.Enumerable("Connectors", connectorMgr.Connectors));
         data.Add(new Snoop.Data.Enumerable("Unused connectors", connectorMgr.UnusedConnectors));
         data.Add(new Snoop.Data.Object("Owner", connectorMgr.Owner));
      }
 /// <summary>
 /// Convenience method to get the first non-primary and non-secondary connector from the specified connector manager.
 /// </summary>
 /// <param name="cm">
 /// The connector manager.
 /// </param>
 /// <returns>
 /// Returns the first non-primary and non-secondary connector from the connector manager.
 /// </returns>
 Connector GetFirstNonPrimaryOrSecondaryConnector(ConnectorManager cm)
 {
     foreach (Connector cn in cm.Connectors)
      {
     MEPConnectorInfo info = cn.GetMEPConnectorInfo();
     if (!info.IsPrimary && !info.IsSecondary)
        return cn;
      }
      return null;
 }