示例#1
0
        private static ECSchema CreateSchema(DgnFile File)
        {
            ECSchema   newSchema        = new ECSchema(schemaName, 1, 0, schemaName);
            ECClass    streamStateClass = new ECClass(className);
            ECProperty streamDataProp   = new ECProperty(propertyName, ECObjects.StringType);

            streamStateClass.Add(streamDataProp);
            newSchema.AddClass(streamStateClass);

            var status = DgnECManager.Manager.ImportSchema(newSchema, File, new ImportSchemaOptions());

            if (status != SchemaImportStatus.Success)
            {
                return(null);
            }

            return(newSchema);
        }
示例#2
0
        public void CreateAndImport()
        {
            ECSchema schema = new ECSchema(SchemaTreeViewItems.Last().Name, 1, 0, "PDIWT");

            foreach (var classnode in SchemaTreeViewItems.Last().ClassNodes)
            {
                ECClass someclass = new ECClass(classnode.Name);
                foreach (var propnode in classnode.PropertyNodes)
                {
                    ECProperty someProp = new ECProperty(propnode.Name, GetTypeFromString(propnode.PropertyType));
                    //someProp.
                    someclass.Add(someProp);
                    //someclass.AddProperty();
                }
                schema.AddClass(someclass);
            }
            if (BDEC.DgnECManager.Manager.ImportSchema(schema, Program.GetActiveDgnFile(), new BDEC.ImportSchemaOptions()) == BD.SchemaImportStatus.Success)
            {
                MessageBox.Show($"{schema.FullName}导入成功", " 水规院", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#3
0
            public static ECSchema AddSchema()
            {
                DgnFile      File    = Session.Instance.GetActiveDgnFile();
                DgnECManager Manager = DgnECManager.Manager;

                ECSchema   newSchema        = new ECSchema(schemaName, 1, 0, schemaName);
                ECClass    streamStateClass = new ECClass(className);
                ECProperty streamIdProp     = new ECProperty("Id", ECObjects.StringType);
                ECProperty streamDataProp   = new ECProperty("StreamData", ECObjects.StringType);

                streamStateClass.Add(streamIdProp);
                streamStateClass.Add(streamDataProp);
                newSchema.AddClass(streamStateClass);

                var status = Manager.ImportSchema(newSchema, File, new ImportSchemaOptions());

                if (status != SchemaImportStatus.Success)
                {
                    return(null);
                }

                return(newSchema);
            }
示例#4
0
        /// <summary>
        /// Returns all the speckle stream states present in the custom schema (schema is attached to file).
        /// </summary>
        /// <param name="schema"></param>
        /// <returns></returns>
        public static List <StreamState> ReadState(ECSchema schema)
        {
            DgnFile      File    = Session.Instance.GetActiveDgnFile();
            DgnECManager Manager = DgnECManager.Manager;

            try
            {
                ECQuery readWidget = new ECQuery(schema.GetClass(className));
                readWidget.SelectClause.SelectAllProperties = true;

                FindInstancesScope scope = FindInstancesScope.CreateScope(File, new FindInstancesScopeOption(DgnECHostType.All));

                var states = new List <StreamState>();
                using (DgnECInstanceCollection ecInstances = Manager.FindInstances(scope, readWidget))
                {
                    foreach (IDgnECInstance instance in ecInstances)
                    {
                        var id = instance["Id"].StringValue;
                        var streamStateData = instance["StreamData"].StringValue;
                        var state           = JsonConvert.DeserializeObject <StreamState>(streamStateData);
                        states.Add(state);
                    }
                }

                if (states != null)
                {
                    states.ForEach(x => x.Initialise(true));
                }

                return(states);
            }
            catch (Exception e)
            {
                return(new List <StreamState>());
            }
        }
示例#5
0
 public static SchemaImportStatus ImportSchema(ECSchema schema, DgnFile file)
 {
     return(DgnECManager.Manager.ImportSchema(schema, file,
                                              new ImportSchemaOptions()));
 }