示例#1
0
        public NodeBuilder GetLine(Point3D point1, Point3D point2)
        {
            NodeBuilder result;
            NodeBuilder p1 = null, p2 = null;

            if (_points.TryGetValue(point1, out result))
            {
                p1 = result;
            }
            if (_points.TryGetValue(point2, out result))
            {
                p2 = result;
            }
            if (p1 != null)
            {
                if (p2 != null)
                {
                    foreach (var child in _document.Root.Children.Values)
                    {
                        var nb = new NodeBuilder(child);
                        if (nb.FunctionName == FunctionNames.LineTwoPoints)
                        {
                            var nbP = NodeBuilderUtils.GetDependencyReferenceIndexes(child.Index, _document).ToList();
                            if ((nbP[0] == p1.Node.Index || nbP[0] == p2.Node.Index) && (nbP[1] == p1.Node.Index || nbP[1] == p2.Node.Index))
                            {
                                return(new NodeBuilder(child));
                            }
                        }
                    }
                }
                else
                {
                    p2 = GetPoint(point2);
                }
            }
            else
            {
                p1 = GetPoint(point1);
                if (p2 == null)
                {
                    p2 = GetPoint(point2);
                }
            }
            var line = new NodeBuilder(_document, FunctionNames.LineTwoPoints);

            line[0].Reference = p1.Node;
            line[1].Reference = p2.Node;
            line.ExecuteFunction();
            return(line);
        }