예제 #1
0
        public static void SetEntityFieldsValue(
            Document doc, ModelLine line,
            double height, double width, string type, ElementId id)
        {
            Schema schema = Schema.Lookup(Guids.MODELLINE_SCHEMA_GUID);
            Entity ent    = line.GetEntity(schema);

            Field sectionHeight = schema.GetField("SectionHeight");

            Field sectionWidth = schema.GetField("SectionWidth");

            Field beamType = schema.GetField("BeamType");

            Field beamId = schema.GetField("BeamId");

            using (Transaction trans = new Transaction(doc, "Set value to entities"))
            {
                trans.Start();
                // Set value to entity
                ent.Set(sectionHeight, height, DisplayUnitType.DUT_CENTIMETERS);
                ent.Set(sectionWidth, width, DisplayUnitType.DUT_CENTIMETERS);
                ent.Set(beamType, type);

                if (id != ElementId.InvalidElementId)
                {
                    ent.Set(beamId, id);
                }

                if (null != line)
                {
                    line.SetEntity(ent);
                }
                trans.Commit();
            }
        }
예제 #2
0
        private void GetParameterFromEntity(ModelLine modelLine,
                                            out string beamSign,
                                            out double beamHeight,
                                            out double beamWidth,
                                            out ElementId beamId)
        {
            beamSign   = string.Empty;
            beamHeight = 0;
            beamWidth  = 0;
            beamId     = ElementId.InvalidElementId;

            Schema lineSchema    = Schema.Lookup(Guids.MODELLINE_SCHEMA_GUID);
            Entity lineSchemaEnt = modelLine.GetEntity(lineSchema);

            // Get beam sign
            string sBeamType = lineSchemaEnt.Get <string>(lineSchema.GetField("BeamType"));

            beamSign = BeamType.GetBeamTypeFromName(sBeamType).Sign;

            // Get beam section height
            beamHeight = lineSchemaEnt.Get <double>(
                lineSchema.GetField("SectionHeight"),
                DisplayUnitType.DUT_CENTIMETERS);

            // Get beam section width
            beamWidth = lineSchemaEnt.Get <double>(
                lineSchema.GetField("SectionWidth"),
                DisplayUnitType.DUT_CENTIMETERS);

            //
            beamId = lineSchemaEnt.Get <ElementId>(
                lineSchema.GetField("BeamId"));
        }
예제 #3
0
        private void AddModelLineInfosToDataTable(DimensionEditingForm def)
        {
            def.DataTable.Rows.Clear();
            // Get all the model lines created by our plugin in the doc
            IList <CurveElement> lines =
                (from line in new FilteredElementCollector(_doc)
                 .OfClass(typeof(CurveElement))
                 .OfCategory(BuiltInCategory.OST_Lines)
                 .Cast <CurveElement>()
                 where (line as ModelLine) != null && line.GetEntitySchemaGuids().Count != 0
                 select line)
                .ToList();

            // Add infos to eht data table for each model line
            IList <object[]> linesParams = new List <object[]>();

            foreach (CurveElement line in lines)
            {
                ModelLine modelLine     = line as ModelLine;
                Schema    lineSchema    = Schema.Lookup(Utils.Guids.MODELLINE_SCHEMA_GUID);
                Entity    lineSchemaEnt = modelLine.GetEntity(lineSchema);

                // Get line Id
                int lineId = modelLine.Id.IntegerValue;

                // Get associated level of the line
                string lineLevel = modelLine.SketchPlane.Name;

                // Get line length
                double lineLength = Math.Round(
                    UnitUtils.Convert(modelLine.GeometryCurve.Length,
                                      DisplayUnitType.DUT_DECIMAL_FEET,
                                      DisplayUnitType.DUT_METERS),
                    2);

                // Get beam type
                string beamType = lineSchemaEnt.Get <string>(lineSchema.GetField("BeamType"));

                // Get beam section height
                double beamHeight = lineSchemaEnt.Get <double>(
                    lineSchema.GetField("SectionHeight"),
                    DisplayUnitType.DUT_CENTIMETERS);

                // Get beam section width
                double beamWidth = lineSchemaEnt.Get <double>(
                    lineSchema.GetField("SectionWidth"),
                    DisplayUnitType.DUT_CENTIMETERS);

                // Add infos to the datatable
                def.DataTable.Rows.Add(
                    lineId,
                    lineLevel,
                    lineLength,
                    beamType,
                    beamHeight,
                    beamWidth);
            }
            ;
        }
예제 #4
0
        private bool SetBeamIdToModelLine(ElementId newBeamId, ModelLine modelLine)
        {
            Schema lineSchema    = Schema.Lookup(Utils.Guids.MODELLINE_SCHEMA_GUID);
            Entity lineSchemaEnt = modelLine.GetEntity(lineSchema);

            try
            {
                lineSchemaEnt.Set(lineSchema.GetField("BeamId"), newBeamId);
                modelLine.SetEntity(lineSchemaEnt);
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }