示例#1
0
        /// <summary>
        /// Make a line from start point to end point with the direction and style
        /// </summary>
        /// <param name="startpt">start point</param>
        /// <param name="endpt">end point</param>
        /// <param name="direction">the direction which decide the plane</param>
        /// <param name="style">line style name</param>
        public void MakeLine(Autodesk.Revit.DB.XYZ startpt, Autodesk.Revit.DB.XYZ endpt, Autodesk.Revit.DB.XYZ direction, string style)
        {
            try
            {
                m_LineCount = m_LineCount + 1;
                Line line = m_app.Application.Create.NewLineBound(startpt, endpt);
                // Line must lie in the sketch plane.  Use the direction of the line to construct a plane that hosts the target line.
                XYZ rotatedDirection = XYZ.BasisX;

                // If the direction is not vertical, cross the direction vector with Z to get a vector rotated ninety degrees.  That vector,
                // plus the original vector, form the axes of the sketch plane.
                if (!direction.IsAlmostEqualTo(XYZ.BasisZ) && !direction.IsAlmostEqualTo(-XYZ.BasisZ))
                {
                    rotatedDirection = direction.Normalize().CrossProduct(XYZ.BasisZ);
                }
                Plane       geometryPlane = m_app.Application.Create.NewPlane(direction, rotatedDirection, startpt);
                SketchPlane skplane       = m_app.ActiveUIDocument.Document.Create.NewSketchPlane(geometryPlane);
                ModelCurve  mcurve        = m_app.ActiveUIDocument.Document.Create.NewModelCurve(line, skplane);
                m_app.ActiveUIDocument.Document.Regenerate();
                ElementArray lsArr = mcurve.LineStyles;
                foreach (Autodesk.Revit.DB.Element e in lsArr)
                {
                    if (e.Name == style)
                    {
                        mcurve.LineStyle = e;
                        break;
                    }
                }
                m_app.ActiveUIDocument.Document.Regenerate();
            }
            catch (System.Exception ex)
            {
                m_outputInfo.Add("Failed to create lines: " + ex.ToString());
            }
        }
示例#2
0
        /// <summary>
        /// Get SpanDirection and SpanDirectionSymobols of Floor
        /// </summary>
        /// <param name="floor"></param>
        void GetSpanDirectionAndSymobls(Floor floor)
        {
            if (null != floor)
            {
                // get SpanDirection angle of Floor(Slab)
                // The angle returned is in radians. An exception will be thrown if the floor
                // is non structural.
                String spanDirAngle = "Span direction angle: " + floor.SpanDirectionAngle.ToString() + "\r\n";

                // get span direction symbols of Floor(Slab)
                String               symbols     = "Span direction symbols: \r\n\t";
                ElementArray         symbolArray = floor.SpanDirectionSymbols;
                ElementArrayIterator symbolIter  = symbolArray.ForwardIterator();
                symbolIter.Reset();
                while (symbolIter.MoveNext())
                {
                    Element elem = symbolIter.Current as Element;
                    if (elem != null)
                    {
                        symbols += (m_docment.get_Element(elem.GetTypeId()) as ElementType).Name + "\r\n";
                    }
                }

                MessageBox.Show(spanDirAngle + symbols, "Revit Direction", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                new Exception("Get Floor and SpanDirectionAngle and Symbols failed!");
            }
        }
示例#3
0
        /// <summary>
        /// dynElement constructor for use by workbench in creating dynElements
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="nickName"></param>
        public dynElement()
        {
            InitializeComponent();
            //System.Uri resourceLocater = new System.Uri("/DynamoElements;component/dynElement.xaml", UriKind.Relative);
            //System.Uri resourceLocater = new System.Uri("/dynElement.xaml", UriKind.Relative);
            //System.Windows.Application.LoadComponent(this, resourceLocater);

            //set the main grid's data context to
            //this element
            nickNameBlock.DataContext = this;

            inPorts       = new List <dynPort>();
            inPortData    = new List <PortData>();
            outPortData   = new List <PortData>();
            outPorts      = new List <dynPort>();
            statePorts    = new List <dynPort>();
            statePortData = new List <PortData>();
            elements      = new ElementArray();
            dataTree      = new DataTree();
            stateSetter   = new SetStateDelegate(SetState);
            Dispatcher.Invoke(stateSetter, System.Windows.Threading.DispatcherPriority.Background, new object[] { this, ElementState.DEAD });

            ElementNameAttribute elNameAttrib = this.GetType().GetCustomAttributes(typeof(ElementNameAttribute), true)[0] as ElementNameAttribute;

            if (elNameAttrib != null)
            {
                NickName = elNameAttrib.ElementName;
            }

            //set the z index to 2
            Canvas.SetZIndex(this, 1);

            //generate a guid for the component
            dynElementReadyToBuild += new dynElementReadyToBuildHandler(Build);
        }
 public SubMeshNode(State state, VertexArray vertexArray, SubMesh subMesh, Material material)
 {
     VertexArray    = vertexArray;
     ElementArray   = new ElementArray(state, subMesh);
     Material       = material;
     BoundingSphere = subMesh.BoundingSphere;
 }
示例#5
0
        //public Result OnStartup(Autodesk.Revit.UI.UIControlledApplication application)
        //{
        //    ElementUpdater updater = new ElementUpdater(application.ActiveAddInId);
        //    UpdaterRegistry.RegisterUpdater(updater);
        //    ElementClassFilter elementFilter = new ElementClassFilter(typeof(Element));
        //    UpdaterRegistry.AddTrigger(updater.getUpdaterId(), elementFilter, Element.GetChangeTypeParameter());

        //    return Result.Succeeded;
        //}

        //public Result OnShutdown(Autodesk.Revit.UI.UIControlledApplication application)
        //{
        //    return Result.Succeeded;
        //}

        void GetStyles(ref Element dynVolatileStyle, ref Element dynPersistentStyle,
                       ref Element dynXStyle, ref Element dynYStyle, ref Element dynZStyle)
        {
            Curve                tick      = m_revit.Application.Create.NewLineBound(new XYZ(), new XYZ(0, 1, 0));
            Plane                p         = new Plane(new XYZ(0, 0, 1), new XYZ());
            SketchPlane          sp        = m_doc.Document.Create.NewSketchPlane(p);
            ModelCurve           ml        = m_doc.Document.Create.NewModelCurve(tick, sp);
            ElementArray         styles    = ml.LineStyles;
            ElementArrayIterator styleIter = styles.ForwardIterator();

            while (styleIter.MoveNext())
            {
                Element style = styleIter.Current as Element;
                if (style.Name == "dynVolatile")
                {
                    dynVolatileStyle = style;
                }
                else if (style.Name == "dynPersistent")
                {
                    dynPersistentStyle = style;
                }
                else if (style.Name == "dynX")
                {
                    dynXStyle = style;
                }
                else if (style.Name == "dynY")
                {
                    dynYStyle = style;
                }
                else if (style.Name == "dynZ")
                {
                    dynZStyle = style;
                }
            }
        }
示例#6
0
 /// <summary>
 /// Constructor for the <c>ElementArrayParameter</c> object.
 /// This is used to create a parameter that can be used to
 /// determine a consistent name using the provided XML annotation.
 /// </summary>
 /// <param name="factory">
 /// this is the constructor the parameter is in
 /// </param>
 /// <param name="value">
 /// this is the annotation used for the parameter
 /// </param>
 /// <param name="index">
 /// this is the index the parameter appears at
 /// </param>
 public ElementArrayParameter(Constructor factory, ElementArray value, int index) {
    this.contact = new Contact(value, factory, index);
    this.label = new ElementArrayLabel(contact, value);
    this.name = label.GetName();
    this.factory = factory;
    this.index = index;
 }
示例#7
0
 /// <summary>
 /// Constructor for the <c>ElementArrayLabel</c> object. This
 /// creates a label object, which can be used to convert an element
 /// node to an array of XML serializable objects.
 /// </summary>
 /// <param name="contact">
 /// this is the contact that this label represents
 /// </param>
 /// <param name="label">
 /// the annotation that contains the schema details
 /// </param>
 public ElementArrayLabel(Contact contact, ElementArray label)
 {
     this.detail    = new Signature(contact, this);
     this.decorator = new Qualifier(contact);
     this.type      = contact.Type;
     this.entry     = label.entry();
     this.name      = label.name();
     this.label     = label;
 }
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                ElementArray.Dispose();
            }

            base.Dispose(disposing);
        }
        /// <summary>
        /// run this sample now
        /// </summary>
        public void Run()
        {
            try
            {
                // filtrate the windows from the element set.

                ElementClassFilter       filter1     = new ElementClassFilter(typeof(FamilyInstance));
                ElementCategoryFilter    filter2     = new ElementCategoryFilter(BuiltInCategory.OST_Windows);
                LogicalAndFilter         andFilter   = new LogicalAndFilter(filter1, filter2);
                FilteredElementCollector collector   = new FilteredElementCollector(m_doc);
                ICollection <Element>    arrayFamily = collector.WherePasses(andFilter).ToElements();

                // filtrate the Symbol from the element set to modify the window's type.


                ElementClassFilter    filter3    = new ElementClassFilter(typeof(FamilySymbol));
                ElementCategoryFilter filter4    = new ElementCategoryFilter(BuiltInCategory.OST_Windows);
                LogicalAndFilter      andFilter1 = new LogicalAndFilter(filter3, filter4);
                collector = new FilteredElementCollector(m_doc);
                ICollection <Element> found       = collector.WherePasses(andFilter1).ToElements();
                ElementArray          arraySymbol = new ElementArray();
                foreach (Element ee in found)
                {
                    if (ee.Name == "36\" x 72\"")
                    {
                        arraySymbol.Insert(ee, 0);
                        break;
                    }
                }

                MessageBox.Show("Replace 16\" x 24\" to 36\" x 72\".", "FindAndReplaceWinType");
                // matching and replacing
                int replacenum = 0;
                foreach (Element ee in arrayFamily)
                {
                    FamilyInstance windows = ee as FamilyInstance;
                    if (0 == windows.Symbol.Name.CompareTo("16\" x 24\""))
                    {
                        windows.Symbol = arraySymbol.get_Item(0) as FamilySymbol;
                        replacenum++;
                    }
                }
                // Show the number of windows modified.
                MessageBox.Show("Revit has completed its search and has made " + replacenum + " modifications.", "FindAndReplaceWinType");
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }
示例#10
0
        static void Main(string[] args)
        {
            Console.WriteLine("Person");
            var Jody = new Person
            {
                FirstName = "Jody",
                LastName  = "Sukma"
            };

            Jody.Introduce();

            Console.WriteLine("===========");
            Console.WriteLine("Kalkulator");
            Calculator calculator = new Calculator();
            var        result     = calculator.Add(3, 4);

            Console.WriteLine(result);

            Console.WriteLine("===========");
            Console.WriteLine("Array");
            ElementArray arr = new ElementArray();

            arr.Array();

            Console.WriteLine("===========");
            Console.WriteLine("Array String");
            StringArray arrStr = new StringArray();

            arrStr.ArrayString();

            Console.WriteLine("===========");
            Console.WriteLine("Enum");
            Enums enums = new Enums();

            enums.TryEnum();

            Console.WriteLine("===========");
            Console.WriteLine("Array");
            TypeAndValueType array  = new TypeAndValueType();
            Person           person = new Person();

            array.TypeOfInteger();
            Console.WriteLine();
            person.Umur();



            Console.ReadKey();
        }
示例#11
0
        public static List<ElementId> RequestMultipleCurveElementsSelection(string message)
        {
            var doc = DocumentManager.Instance.CurrentUIDocument;

            Selection choices = doc.Selection;
            choices.Elements.Clear();

            dynSettings.DynamoLogger.Log(message);

            var ca = new ElementArray();
            ISelectionFilter selFilter = new CurveSelectionFilter();
            return doc.Selection.PickElementsByRectangle(//selFilter,
                "Window select multiple curves.").Select(x => x.Id).ToList();

        }
示例#12
0
            public static IList <Element> RequestMultipleCurveElementsSelection(string message)
            {
                var doc = dynRevitSettings.Doc;

                Autodesk.Revit.UI.Selection.Selection choices = doc.Selection;
                choices.Elements.Clear();

                DynamoLogger.Instance.Log(message);

                var ca = new ElementArray();
                ISelectionFilter selFilter = new CurveSelectionFilter();

                return(doc.Selection.PickElementsByRectangle(//selFilter,
                           "Window select multiple curves.") as IList <Element>);
            }
示例#13
0
        public static List <ElementId> RequestMultipleCurveElementsSelection(string message)
        {
            var doc = DocumentManager.Instance.CurrentUIDocument;

            Selection choices = doc.Selection;

            choices.Elements.Clear();

            dynSettings.Controller.DynamoLogger.Log(message);

            var ca = new ElementArray();
            ISelectionFilter selFilter = new CurveSelectionFilter();

            return(doc.Selection.PickElementsByRectangle(//selFilter,
                       "Window select multiple curves.").Select(x => x.Id).ToList());
        }
示例#14
0
        public Quad(State state)
        {
            VertexArray = new VertexArray(state,
                                          new[]
            {
                new Vector3(-1.0f, -1.0f, 0.0f),
                new Vector3(-1.0f, 1.0f, 0.0f),
                new Vector3(1.0f, 1.0f, 0.0f),
                new Vector3(1.0f, -1.0f, 0.0f)
            });

            ElementArray = new ElementArray(state, PrimitiveType.Triangles, new uint[]
            {
                0, 2, 1,
                0, 3, 2
            });
        }
示例#15
0
        public void Perf_CreateElements_Binary5()
        {
            var dm = MakeDatamodel();

            dm.Root = new Element(dm, "root");
            var inner_elem = new Element(dm, "inner_elem");
            var arr        = new ElementArray(20000);

            dm.Root["big_array"] = arr;

            foreach (int i in Enumerable.Range(0, 19999))
            {
                arr.Add(inner_elem);
            }

            SaveAndConvert(dm, "binary", 5);
            Cleanup();
        }
示例#16
0
        /// <summary>
        /// Get wall's one end all joined walls
        /// </summary>
        /// <param name="locationCurve">The wall's location curve</param>
        /// <param name="end">The index indicates the start or end of this wall</param>
        /// <returns>The check result</returns>
        private XElement GetJoinedWalls(LocationCurve locationCurve, int end)
        {
            // retrieve joined elements
            ElementArray array = locationCurve.get_ElementsAtJoin(end);

            XElement joinedwallsNode = new XElement("JoinedWalls",
                                                    new XAttribute("Count", array.Size.ToString()));

            // output array
            foreach (Element ele in array)
            {
                if (ele is Wall)
                {
                    joinedwallsNode.Add(new XElement("JoinedWall",
                                                     new XAttribute("Name", ele.Name)));
                }
            }

            return(joinedwallsNode);
        }
示例#17
0
        private ElementArray GetSimilarForElement(ElementId elementId)
        {
            ElementArray ea = null;

            if (elementId != null)
            {
                ElementType et = _doc.GetElement(elementId) as ElementType;

                if (et != null)
                {
                    ea = new ElementArray();

                    foreach (ElementId eid in et.GetSimilarTypes())
                    {
                        ea.Append(_doc.GetElement(eid));
                    }
                }
            }

            return(ea);
        }
示例#18
0
        public static List <Autodesk.Revit.DB.Wall> TrimOrExtendWall(this IEnumerable <Autodesk.Revit.DB.Wall> walls, double maxDistance, double tolerance = Core.Tolerance.Distance)
        {
            Dictionary <double, Dictionary <Autodesk.Revit.DB.Wall, Segment2D> > dictionary = new Dictionary <double, Dictionary <Autodesk.Revit.DB.Wall, Segment2D> >();

            foreach (Autodesk.Revit.DB.Wall wall in walls)
            {
                Curve     curve     = (wall.Location as LocationCurve).Curve;
                Segment3D segment3D = Geometry.Revit.Convert.ToSAM_Segment3D(curve);

                double elevation = Math.Min(segment3D[0].Z, segment3D[1].Z);

                Dictionary <Autodesk.Revit.DB.Wall, Segment2D> dictionary_Wall = null;
                if (!dictionary.TryGetValue(elevation, out dictionary_Wall))
                {
                    dictionary_Wall       = new Dictionary <Autodesk.Revit.DB.Wall, Segment2D>();
                    dictionary[elevation] = dictionary_Wall;
                }

                dictionary_Wall[wall] = Geometry.Spatial.Plane.WorldXY.Convert(segment3D);
            }

            List <Autodesk.Revit.DB.Wall> result = new List <Autodesk.Revit.DB.Wall>();

            foreach (KeyValuePair <double, Dictionary <Autodesk.Revit.DB.Wall, Segment2D> > keyValuePair in dictionary)
            {
                List <Segment2D> segment2Ds = keyValuePair.Value.Values.ToList();

                //Filtering Walls by Level
                List <Tuple <Autodesk.Revit.DB.Wall, Segment2D, List <int>, bool> > tupleList = new List <Tuple <Autodesk.Revit.DB.Wall, Segment2D, List <int>, bool> >();
                foreach (KeyValuePair <Autodesk.Revit.DB.Wall, Segment2D> keyValuePair_Wall in keyValuePair.Value)
                {
                    LocationCurve locationCurve = keyValuePair_Wall.Key.Location as LocationCurve;

                    List <int> indexes = new List <int>();

                    ElementArray elementArray = null;

                    elementArray = locationCurve.get_ElementsAtJoin(0);
                    if (elementArray == null || elementArray.Size == 0)
                    {
                        indexes.Add(0);
                    }

                    elementArray = locationCurve.get_ElementsAtJoin(1);
                    if (elementArray == null || elementArray.Size == 0)
                    {
                        indexes.Add(1);
                    }

                    //if (indexes.Count > 0)
                    tupleList.Add(new Tuple <Autodesk.Revit.DB.Wall, Segment2D, List <int>, bool>(keyValuePair_Wall.Key, keyValuePair_Wall.Value, indexes, false));
                }

                //Seeking for walls to be extended/trimmed
                bool updated = true;
                while (updated)
                {
                    updated = false;
                    List <Tuple <Autodesk.Revit.DB.Wall, Segment2D, List <int>, bool> > tupleList_Unconnected = tupleList.FindAll(x => x.Item3 != null && x.Item3.Count > 0);
                    for (int i = 0; i < tupleList_Unconnected.Count; i++)
                    {
                        Tuple <Autodesk.Revit.DB.Wall, Segment2D, List <int>, bool> tuple = tupleList_Unconnected[i];

                        List <Tuple <Autodesk.Revit.DB.Wall, Segment2D, List <int>, bool> > tupleList_Temp = new List <Tuple <Autodesk.Revit.DB.Wall, Segment2D, List <int>, bool> >(tupleList);
                        tupleList_Temp.Remove(tuple);

                        Segment2D segment2D = tuple.Item2;
                        List <Tuple <Point2D, Segment2D> > tupleList_Intersection = new List <Tuple <Point2D, Segment2D> >();
                        foreach (Segment2D segment2D_Temp in tupleList_Temp.ConvertAll(x => x.Item2))
                        {
                            Point2D point2D_Intersection = segment2D_Temp.Intersection(segment2D, false, tolerance);
                            if (point2D_Intersection == null)
                            {
                                //Checking Colinear Segment2Ds if can be extended

                                Vector2D direction_Temp = segment2D_Temp.Direction;
                                Vector2D direction      = segment2D.Direction;

                                if (!direction_Temp.AlmostEqual(direction, tolerance) && !direction_Temp.AlmostEqual(direction.GetNegated(), tolerance))
                                {
                                    continue;
                                }

                                Point2D point2D_Temp = null;
                                Point2D point2D      = null;
                                if (!Geometry.Planar.Query.Closest(segment2D_Temp, segment2D, out point2D_Temp, out point2D, tolerance))
                                {
                                    continue;
                                }

                                if (point2D_Temp.AlmostEquals(point2D, tolerance))
                                {
                                    continue;
                                }

                                Vector2D direction_New = new Vector2D(point2D, point2D_Temp).Unit;
                                if (!direction_Temp.AlmostEqual(direction_New, tolerance) && !direction_Temp.AlmostEqual(direction_New.GetNegated(), tolerance))
                                {
                                    continue;
                                }

                                point2D_Intersection = point2D;
                            }

                            double distance;

                            distance = segment2D.Distance(point2D_Intersection);
                            if (distance > maxDistance)
                            {
                                continue;
                            }

                            distance = segment2D_Temp.Distance(point2D_Intersection);
                            if (distance > maxDistance)
                            {
                                continue;
                            }

                            tupleList_Intersection.Add(new Tuple <Point2D, Segment2D>(point2D_Intersection, segment2D_Temp));
                        }

                        if (tupleList_Intersection.Count == 0)
                        {
                            continue;
                        }

                        foreach (int index in tuple.Item3)
                        {
                            Point2D point2D = segment2D[index];

                            tupleList_Intersection.Sort((x, y) => x.Item1.Distance(point2D).CompareTo(y.Item1.Distance(point2D)));
                            Tuple <Point2D, Segment2D> tuple_Intersection = tupleList_Intersection.Find(x => x.Item1.Distance(point2D) < maxDistance);
                            if (tuple_Intersection == null)
                            {
                                continue;
                            }

                            Segment2D segment2D_Intersection = tuple_Intersection.Item2;

                            int j = tupleList.FindIndex(x => x.Item2 == segment2D_Intersection);
                            if (j == -1)
                            {
                                continue;
                            }

                            int k = tupleList.FindIndex(x => x.Item2 == segment2D);
                            if (k == -1)
                            {
                                continue;
                            }

                            //TODO: Double Check if works (added 2020.05.14)
                            if ((index == 0 && segment2D[1].AlmostEquals(tuple_Intersection.Item1)) || (index == 1 && segment2D[0].AlmostEquals(tuple_Intersection.Item1)))
                            {
                                tupleList[k] = new Tuple <Autodesk.Revit.DB.Wall, Segment2D, List <int>, bool>(tuple.Item1, new Segment2D(tuple_Intersection.Item1, tuple_Intersection.Item1), tuple.Item3.FindAll(x => x != index), true);

                                updated = true;
                                break;
                            }

                            Segment2D segment2D_Temp;

                            if (segment2D_Intersection[0].Distance(tuple_Intersection.Item1) < maxDistance || segment2D_Intersection[1].Distance(tuple_Intersection.Item1) < maxDistance)
                            {
                                segment2D_Temp = new Segment2D(segment2D_Intersection);
                                segment2D_Temp.Adjust(tuple_Intersection.Item1);
                                if (!segment2D_Temp.AlmostSimilar(segment2D_Intersection) && segment2D_Temp.GetLength() > segment2D_Intersection.GetLength())
                                {
                                    tupleList[j] = new Tuple <Autodesk.Revit.DB.Wall, Segment2D, List <int>, bool>(tupleList[j].Item1, segment2D_Temp, tupleList[j].Item3.FindAll(x => x != segment2D_Temp.GetEndIndex(tuple_Intersection.Item1)), true);
                                }
                            }

                            segment2D_Temp = new Segment2D(segment2D);
                            segment2D_Temp.Adjust(tuple_Intersection.Item1);
                            if (segment2D_Temp.AlmostSimilar(segment2D))
                            {
                                continue;
                            }

                            tupleList[k] = new Tuple <Autodesk.Revit.DB.Wall, Segment2D, List <int>, bool>(tuple.Item1, segment2D_Temp, tuple.Item3.FindAll(x => x != index), true);

                            updated = true;
                            break;
                        }

                        if (updated)
                        {
                            break;
                        }
                    }
                }

                tupleList.RemoveAll(x => !x.Item4);

                //Updating Revit Walls
                foreach (Tuple <Autodesk.Revit.DB.Wall, Segment2D, List <int>, bool> tuple in tupleList)
                {
                    Autodesk.Revit.DB.Wall wall = tuple.Item1;
                    if (!wall.IsValidObject)
                    {
                        continue;
                    }

                    Segment2D segment2D = tuple.Item2;
                    if (segment2D.GetLength() < tolerance)
                    {
                        wall.Document.Delete(wall.Id);
                        continue;
                    }

                    LocationCurve locationCurve = wall.Location as LocationCurve;

                    JoinType[] joinTypes = new JoinType[] { locationCurve.get_JoinType(0), locationCurve.get_JoinType(1) };
                    WallUtils.DisallowWallJoinAtEnd(wall, 0);
                    WallUtils.DisallowWallJoinAtEnd(wall, 1);

                    Segment3D segment3D = new Segment3D(new Point3D(segment2D[0].X, segment2D[0].Y, keyValuePair.Key), new Point3D(segment2D[1].X, segment2D[1].Y, keyValuePair.Key));

                    Line line = Geometry.Revit.Convert.ToRevit(segment3D);

                    locationCurve.Curve = line;

                    WallUtils.AllowWallJoinAtEnd(wall, 0);
                    locationCurve.set_JoinType(0, joinTypes[0]);

                    WallUtils.AllowWallJoinAtEnd(wall, 1);
                    locationCurve.set_JoinType(1, joinTypes[1]);

                    result.Add(tuple.Item1);
                }
            }

            return(result);
        }
示例#19
0
 public bool AllowElement(ElementArray elem)
 {
     return(elem is Wall);
 }
示例#20
0
        private string ParameterValue(Parameter p)
        {
            test.p = p;

            string storageType = p.StorageType.ToString();
            string result      = (p.AsValueString() ?? "").Trim();

            if (string.IsNullOrWhiteSpace(result))
            {
                switch (p.StorageType)
                {
                case StorageType.Double:
                {
                    storageType = "double";
                    result      = p.AsValueString();
                    break;
                }

                case StorageType.ElementId:
                {
                    storageType = "element id";
                    ElementId id = new ElementId(p.AsElementId().IntegerValue);
                    Element   e  = _doc.GetElement(id);

                    result = e?.Name ?? "Null Element";
                    break;
                }

                case StorageType.Integer:
                {
                    storageType = "integer";
                    result      = p.AsInteger().ToString();
                    break;
                }

                case StorageType.None:
                {
                    storageType = "none";
                    result      = p.AsValueString();
                    break;
                }

                case StorageType.String:
                {
                    storageType = "string";
                    result      = p.AsString();
                    break;
                }
                }
            }


            if (p.StorageType == StorageType.ElementId && !firstPass[firstPassItem])
            {
                ElementArray ea = GetSimilarForElement(p.AsElementId());

                ElementType et = _doc.GetElement(p.AsElementId()) as ElementType;

                if (ea != null)
                {
                    firstPass[firstPassItem++] = true;

                    logMsgDbLn2("getting similar", et.Name + " :: " + et.FamilyName);

                    foreach (Element e in ea)
                    {
                        logMsgDbLn2("type", e.Name);
                    }
                }
            }

            UnitType      u  = UnitType.UT_Undefined;
            ParameterType pt = ParameterType.Acceleration;


            result  = result.PadRight(18);
            result += " :: " + storageType.ToString().PadRight(PAD_RIGHT);


            //not valid info
            result += " :: " + p.IsReadOnly.ToString().PadRight(PAD_RIGHT);

            // not valid info
            //			result += " :: " + p.UserModifiable.ToString().PadRight(PAD_RIGHT);

            // valid info
            //			result += " :: " + p.HasValue.ToString().PadRight(PAD_RIGHT);

            result += " :: " + p.Definition.ParameterType.ToString().PadRight(PAD_RIGHT);
            result += " :: " + p.Definition.UnitType.ToString().PadRight(PAD_RIGHT);


            try
            {
                result += " :: " + p.DisplayUnitType.ToString().PadRight(PAD_RIGHT + 6);
            }
            catch
            {
                result += " :: " + "(no unit type)".PadRight(PAD_RIGHT + 6);
            }

            result += " :: " + p.Definition.ParameterGroup.ToString().PadRight(PAD_RIGHT);


            return(result);
        }
示例#21
0
 /// <summary>
 /// Create a new Block definition with a maximum element count of <paramref name="max"/>
 /// </summary>
 /// <param name="max">Max allowed elements for this block</param>
 private Block(int max) : base(FieldType.Block)
 {
     maxElements = max;
     Elements    = /*max > 0 ? new ElementArray<T>(max) :*/ new ElementArray <T>();
 }
示例#22
0
 private Block() :                                                                               base(FieldType.Block)
 {
     Elements = new ElementArray <T>();
 }
示例#23
0
        private bool SetupForTeleporter()
        {
            object obj =
                ContentManager.Instance.SelectEntry(
                    new Link(LinkDestination.GameBINEntryName, "OBJECT"),
                    "OBJECT_GUILD_PEDESTAL_TELEPORT_01");

            if (obj != null)
            {
                ContentObject o = ContentManager.Instance.FindEntry(
                    LinkDestination.GameBINEntryName, obj);

                BINEntry entry = (BINEntry)o.Object;

                if (entry.Definition != "OBJECT")
                {
                    FormMain.Instance.ErrorMessage(
                        "Invalid object selected.");
                    return(false);
                }

                myCreatedThing = new FableMod.TNG.Thing("Object");

                myCreatedThing.Create(
                    FileDatabase.Instance.TNGDefinitions,
                    entry.Name);

                myCreatedThing.UID    = FableMod.TNG.UIDManager.Generate();
                myCreatedThing.Player = 4;
                myCreatedThing.get_Variables("ScriptData").Value =
                    "Teleport?";

                entry = null;
                o     = null;

                CTCBlock block = (CTCBlock)myCreatedThing.ApplyCTC(
                    FileDatabase.Instance.TNGDefinitions,
                    "CTCActionUseScriptedHook");

                block.get_Variables("Usable").Value                   = true;
                block.get_Variables("ForceConfirmation").Value        = true;
                block.get_Variables("TeleportToRegionEntrance").Value =
                    true;

                ElementArray arr = (ElementArray)
                                   myCreatedThing.Find("CreateTC");

                Variable var = (Variable)arr.Add();
                var.Value = "CTCActionUseScriptedHook";

                // Create the teleporter marker.

                FableMod.TNG.Thing marker = new FableMod.TNG.Thing("Marker");

                marker.Create(
                    FileDatabase.Instance.TNGDefinitions,
                    "MARKER_BASIC");

                marker.UID    = FableMod.TNG.UIDManager.Generate();
                marker.Player = 4;

                // Set the teleport connector.
                block.get_Variables("EntranceConnectedToUID").Value =
                    marker.UID;

                // We're creating a teleporter...
                myTeleporter = marker;

                return(true);
            }

            return(false);
        }
 /// <summary>
 /// Create a new Block definition that is a clone of <paramref name="value"/>
 /// </summary>
 /// <param name="value">Block to clone</param>
 public Block(Block <T> value) :                                                  this(value.maxElements)
 {
     this.elements = (ElementArray <T>)value.elements.Clone();
 }
示例#25
0
        public void Perf_CreateElements_Binary5()
        {
            var dm = MakeDatamodel();
            dm.Root = new Element(dm, "root");
            var inner_elem = new Element(dm, "inner_elem");
            var arr = new ElementArray(20000);
            dm.Root["big_array"] = arr;

            foreach (int i in Enumerable.Range(0, 19999))
                arr.Add(inner_elem);

            SaveAndConvert(dm, "binary", 5);
            Cleanup();
        }
示例#26
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication           uiapp = commandData.Application;
            UIDocument              uidoc = uiapp.ActiveUIDocument;
            Application             app = uiapp.Application;
            Document                doc = uidoc.Document;
            Selection               SelectedObjs = uidoc.Selection;
            ICollection <ElementId> ids = uidoc.Selection.GetElementIds();
            Line           dimDirCross = null; Line dimDir = null;
            int            selectdim  = 0;
            bool           updateMode = false;
            ElementArray   dimensions = new ElementArray();
            ReferenceArray dimto = new ReferenceArray();

            GetMenuValues(uiapp);
            foreach (ElementId eid in ids)
            {
                if (doc.GetElement(eid).GetType() == typeof(Grid))
                {
                    Grid grid = doc.GetElement(eid) as Grid;
                    dimto.Append(new Reference(grid));
                }
                else if (doc.GetElement(eid).GetType() == typeof(Dimension))
                {
                    updateMode = true;
                    dimensions.Append(doc.GetElement(eid));
                }
                else
                {
                    GeometryElement geom    = doc.GetElement(eid).get_Geometry(Store.Dimop(doc.ActiveView));
                    Line            refLine = GetLineOfGeom(geom);
                    if (selectdim == 0)
                    {
                        dimDir      = Line.CreateBound(refLine.GetEndPoint(0), refLine.GetEndPoint(1));
                        dimDirCross = RackDim.GetPerpendicular(dimDir, Store.mod_place);
                        selectdim   = 1;
                    }
                    dimto.Append(refLine.Reference);
                }
            }
            if (updateMode)
            {
                foreach (Element elem in dimensions)
                {
                    selectdim = 0;
                    Dimension      dim        = elem as Dimension;
                    ReferenceArray updatedref = new ReferenceArray();
                    foreach (Reference refe in dim.References)
                    {
                        if (doc.GetElement(refe.ElementId).GetType() == typeof(Grid))
                        {
                            Grid grid = doc.GetElement(refe.ElementId) as Grid;
                            updatedref.Append(new Reference(grid));
                        }
                        else
                        {
                            GeometryElement geom    = doc.GetElement(refe.ElementId).get_Geometry(Store.Dimop(doc.ActiveView));
                            Line            refLine = GetLineOfGeom(geom);
                            if (selectdim == 0)
                            {
                                dimDir      = Line.CreateBound(refLine.GetEndPoint(0), refLine.GetEndPoint(1));
                                dimDirCross = RackDim.GetPerpendicular(dimDir, Store.mod_place);
                                selectdim   = 1;
                            }
                            updatedref.Append(refLine.Reference);
                        }
                    }
                    RackDim.CreateRackDim(doc, uiapp, dimDir, dimDirCross, updatedref);
                    using (Transaction deltrans = new Transaction(doc))
                    {
                        deltrans.Start("Update Dimension");
                        doc.Delete(elem.Id);
                        deltrans.Commit();
                    }
                }
            }
            else
            {
                RackDim.CreateRackDim(doc, uiapp, dimDir, dimDirCross, dimto);
            }
            return(Result.Succeeded);
        }
示例#27
0
        /// <summary>
        /// dynElement constructor for use by workbench in creating dynElements
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="nickName"></param>
        public dynElement()
        {
            InitializeComponent();
            //System.Uri resourceLocater = new System.Uri("/DynamoElements;component/dynElement.xaml", UriKind.Relative);
            //System.Uri resourceLocater = new System.Uri("/dynElement.xaml", UriKind.Relative);
            //System.Windows.Application.LoadComponent(this, resourceLocater);

            //set the main grid's data context to
            //this element
            nickNameBlock.DataContext = this;

            inPorts = new List<dynPort>();
            inPortData = new List<PortData>();
            outPortData = new List<PortData>();
            outPorts = new List<dynPort>();
            statePorts = new List<dynPort>();
            statePortData = new List<PortData>();
            elements = new ElementArray();
            dataTree = new DataTree();
            stateSetter = new SetStateDelegate(SetState);
            Dispatcher.Invoke(stateSetter, System.Windows.Threading.DispatcherPriority.Background, new object[] {this, ElementState.DEAD });

            ElementNameAttribute elNameAttrib = this.GetType().GetCustomAttributes(typeof(ElementNameAttribute), true)[0] as ElementNameAttribute;
            if (elNameAttrib != null)
            {
                NickName = elNameAttrib.ElementName;
            }

            //set the z index to 2
            Canvas.SetZIndex(this, 1);

            //generate a guid for the component
            dynElementReadyToBuild += new dynElementReadyToBuildHandler(Build);
        }