Get schema from PipeFittingAndAccessoryPressureDropData

Get schema from PipeFittingAndAccessoryPressureDropData

reylorente1
Collaborator Collaborator
896 Views
4 Replies
Message 1 of 5

Get schema from PipeFittingAndAccessoryPressureDropData

reylorente1
Collaborator
Collaborator
Hi, I want to create a schema from PipeFittingAndAccessoryPressureDropData, but it is not shown in the Revit Lookup. What's missing?
Here is the code.

 

Hola,Quiero crear un esquema a partir de PipeFittingAndAccessoryPressureDropData,pero no se muestra en el Revit Lookup.Que falta?.
Aqui esta el codigo.

 

 

public static class PipeSchemaBuildingUtility
    {
        internal static readonly Guid LongEquivSchemaGuid = new Guid("60610463-b1b8-4a93-bbea-4591a02d4e5d");

        public static readonly string fieldLongEquiv = "TestPresion";

        internal static Schema BuildSchema(Guid schemaGuid, int version)
        {
            SchemaBuilder sb = new SchemaBuilder(schemaGuid);

            sb.SetReadAccessLevel((AccessLevel)1);
            sb.SetWriteAccessLevel((AccessLevel)1);
            sb.SetVendorId("ASDK");
            sb.SetDocumentation("Version" + version.ToString());

            if (schemaGuid.Equals(LongEquivSchemaGuid))
            {
                sb.SetSchemaName("TestElementPresion");

                sb.AddSimpleField(fieldLongEquiv, typeof(string));
            }

            return sb.Finish();
        }

    }
    public class ElementPipePressureDropServerDB : IPipeFittingAndAccessoryPressureDropServer
    {
        public bool Calculate(PipeFittingAndAccessoryPressureDropData data)
        {
            if (data == null)
            {
                return false;
            }

            string str = string.Empty;
            var f = data.GetPresureDropItems();

            foreach (var item in f)
            {
                str = UnitUtils.ConvertFromInternalUnits(item.Coefficient, UnitTypeId.Millimeters).ToString();
            }

            Entity entity = new Entity(this.GetDataSchema());
            entity.Set<string>(PipeSchemaBuildingUtility.fieldLongEquiv, str);
            data.SetDefaultEntity(entity);

            return true;
        }

        public Schema GetDataSchema() => Schema.Lookup(PipeSchemaBuildingUtility.LongEquivSchemaGuid) ?? PipeSchemaBuildingUtility.BuildSchema(PipeSchemaBuildingUtility.LongEquivSchemaGuid, 1);

        public string GetDescription()
        {
            return "Show Presion";
        }

        public string GetName()
        {
            return "Presion";
        }

        public Guid GetServerId()
        {
            return new Guid("ce513edc-a61a-480e-bcc5-e02628b4ff8a");
        }

        public ExternalServiceId GetServiceId()
        {
            return ExternalServices.BuiltInExternalServices.PipeFittingAndAccessoryPressureDropService;
        }

        public string GetVendorId()
        {
            return "RL";
        }

        public bool IsApplicable(PipeFittingAndAccessoryPressureDropData data)
        {
            return true;
        }
    }

public class ServerApp : IExternalDBApplication
    {
        public ExternalDBApplicationResult OnShutdown(ControlledApplication application)
        {
            return ExternalDBApplicationResult.Succeeded;
        }

        public ExternalDBApplicationResult OnStartup(ControlledApplication application)
        {
            AddPipeFittingAndAccessoryPressureDropServers();
            return ExternalDBApplicationResult.Succeeded;
        }

        private void AddPipeFittingAndAccessoryPressureDropServers()
        {
            MultiServerService service = ExternalServiceRegistry
                .GetService(ExternalServices.BuiltInExternalServices.PipeFittingAndAccessoryPressureDropService) as MultiServerService;
            if (service == null)
                return;

            List<Guid> activeServerIds = new List<Guid>();

            ElementPipePressureDropServerDB PerdidasTablePipe = new ElementPipePressureDropServerDB();
            if (PerdidasTablePipe != null)
            {
                service.AddServer(PerdidasTablePipe);
            }
            activeServerIds.AddRange(service.GetActiveServerIds());
            service.SetActiveServers(activeServerIds);
        }
    }

<?xml version="1.0" encoding="utf-8"?>
<RevitAddIns>
  <AddIn Type="DBApplication">
    <Name>DBApplication FitingDBSchema</Name>
    <Assembly>FitingDBSchema.dll</Assembly>
    <FullClassName>FitingDBSchema.ServerApp</FullClassName>
    <ClientId>b65818c3-d7e5-4550-941f-a2db974216a4</ClientId>
    <VendorId>RL</VendorId>
    <VendorDescription>RL, http://thebuildingcoder.typepad.com</VendorDescription>
  </AddIn>
</RevitAddIns>

 

0 Likes
897 Views
4 Replies
Replies (4)
Message 2 of 5

jeremy_tammik
Alumni
Alumni

I so not understand exactly what you are asking.

 

In a schema, you can only specify specific data types.

  

https://www.revitapidocs.com/2022/5de0ea30-a58e-4db2-373c-05222a139465.htm

   

Remarks

The supported types are Boolean, Byte, Int16, Int32, Float, Double, ElementId, GUID, String, XYZ, UV and Entity.

    

I suggest you extract the data you wish to store from the PipeFittingAndAccessoryPressureDropData object and convert that to the simple data types supported by the schema.

 

For more on extensible storage, please refer to the existing articles on that topic:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.23

 

Cheers,

 

Jeremy

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 5

reylorente1
Collaborator
Collaborator

Hola,
En mi pais no calculamos la caida de presion de las piezas por la K ,tal como la enseña el Revit por defecto,
lo calculamos por longitudes Equivalente,que lo muestro en una tabla Excel
Mi metodo consiste en exportar esta tabla a Revit,por un Datatable,utilizando WPF,Mi pregunta es como puedo crear un schema.con
IPipeFittingAndAccessoryPressureDropUIServer ,IPipeFittingAndAccessoryPressureDropServer.
Aqui estas mi solucion,
Alguna idea de como poder solucionarlo?

 

Hello,
In my country we do not calculate the pressure drop of the parts by the K(K_PipingFiting), as taught by Revit by default,
We calculate it by Equivalent lengths, which I show in an Excel table
My method is to export this table to Revit, by a Datatable, using WPF, My question is how can I create a schema.con
IPipeFittingAndAccessoryPressureDropUIServer, IPipeFittingAndAccessoryPressureDropServer.
Here you are my solution,
Any ideas, to solve it?

2021-08-27 (1).png

0 Likes
Message 4 of 5

jeremy_tammik
Alumni
Alumni

You ask how to create an extensible storage schema containing IPipeFittingAndAccessoryPressureDropUIServer and IPipeFittingAndAccessoryPressureDropServer.

 

I repeat  my answer from above: an extensible storage schema can only contain simple data types.

 

Therefore, you cannot store IPipeFittingAndAccessoryPressureDropUIServer and IPipeFittingAndAccessoryPressureDropServer directly.

 

What you can do instead: identify the data contained in these objects that you wish to save, extract and store that.

 

Maybe it will help move forward if you explain why you wish to store this information.

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 5 of 5

reylorente1
Collaborator
Collaborator

Hola, gracias por su respuesta, mi idea es crear una plantilla donde ya se estuviera en cuenta este metodo, y con esto poder calcular la ruta critica, teniendo en cuenta la altura del mueble sanitarios.Revit me brinda mucha informacion, que se puede aprovechar para mi objetivo.

 

Hello, thanks for your answer, my idea is to create a template where this method is already taken into account,
and with this to be able to calculate the critical path,
taking into account the height of the sanitary furniture
. Revit gives me a lot of information, which can be used for my object.
Following this method, add this.

 

 

public bool Calculate(PipeFittingAndAccessoryPressureDropData data)
        {
            if (data == null)
            {
                return false;
            }
            DataTable dt = Utiles.ReadExcel();

            var dictList = Utiles.GetDataTableDictionaryList(dt);
            string str = Utiles.GetOutputString(dictList);

            Entity val = new Entity(GetDataSchema());
            
            val.Set<string>(PipeSchemaBuildingUtility.fieldLongEquiv, str);
            data.SetDefaultEntity(val);

            return true;
        }

 

 

I don't know if I'm going the right way.

 

This is my excel table, and I am using the Epluss library, to export excel to DataGrid

 

0 Likes