コード例 #1
0
ファイル: GSACache.cs プロジェクト: guusgooskens/speckleGSA
    //Since EntitiesInList doesn't offer load cases/combinations as a GsaEntity type, a dummy GSA instance is 
    //created where a node is created for every load case/combination in the specification.  This is done separately for load cases and combinations.
    private List<string> ExpandSubsetViaProxy(List<int> existingIndices, List<string> specParts, string marker)
    {
      var items = new List<string>();
      var gsaProxy = new GSAProxy();

      try
      {
        gsaProxy.NewFile(false);

        for (int i = 0; i < existingIndices.Count(); i++)
        {
          var indexStr = existingIndices[i].ToString();
          gsaProxy.SetGwa(string.Join("\t", new[] { "SET", "NODE.3", indexStr, indexStr, "NO_RGB", "0", "0", "0" }));
        }
        gsaProxy.Sync();
        var tempSpec = string.Join(" ", specParts.Select(a => RemoveMarker(a)));
        items.AddRange(gsaProxy.GetNodeEntitiesInList(tempSpec).Select(e => marker + e.ToString()));
      }
      catch { }
      finally
      {
        gsaProxy.Close();
        gsaProxy = null;
      }

      return items;
    }
コード例 #2
0
        public static void CalibrateNodeAt()
        {
            float coordValue         = 1000;
            var   unitCoincidentDict = new Dictionary <string, float>()
            {
                { "mm", 20 }, { "cm", 1 }, { "in", 1 }, { "m", 0.1f }
            };
            var units = new[] { "m", "cm", "mm", "in" };

            var proxy = new GSAProxy();

            proxy.NewFile(false);
            foreach (var u in units)
            {
                proxy.SetUnits(u);
                var   nodeIndex = proxy.NodeAt(coordValue, coordValue, coordValue, unitCoincidentDict[u]);
                float factor    = 1;
                var   gwa       = proxy.GetGwaForNode(nodeIndex);
                var   pieces    = gwa.Split(GSAProxy.GwaDelimiter);
                if (float.TryParse(pieces.Last(), out float z1))
                {
                    if (z1 != coordValue)
                    {
                        var factorCandidate = coordValue / z1;

                        nodeIndex = proxy.NodeAt(coordValue * factorCandidate, coordValue * factorCandidate, coordValue * factorCandidate, 1 * factorCandidate);

                        gwa    = proxy.GetGwaForNode(nodeIndex);
                        pieces = gwa.Split(GSAProxy.GwaDelimiter);

                        if (float.TryParse(pieces.Last(), out float z2) && z2 == 1000)
                        {
                            //it's confirmed
                            factor = factorCandidate;
                        }
                    }
                }
                if (UnitNodeAtFactors.ContainsKey(u))
                {
                    UnitNodeAtFactors[u] = factor;
                }
                else
                {
                    UnitNodeAtFactors.Add(u, factor);
                }
            }

            proxy.Close();

            NodeAtCalibrated = true;
        }