specklesystems / speckle-sharp

.NET SDK, Schema and Connectors: Revit, Rhino, Grasshopper, Dynamo, ETABS, AutoCAD, Civil3D & more.
https://speckle.systems
Apache License 2.0
368 stars 170 forks source link

Revit MEP fabrication parts support for connector #1100

Closed thoffeller closed 1 year ago

thoffeller commented 2 years ago

Hi specklers,

currently the mep fabrication parts are nor supported in the connector. Is there a plan to add them for export to speckle? If not, shall we implement the parts and create a pull request?

Sunny greetings from Germany, Tim

teocomi commented 2 years ago

Hey Tim, we don't have short-term plans to pick those up, so it'd be great if you could do a PR!

thoffeller commented 2 years ago

Hey @teocomi , added the support and send a pr. Hope it is, what you expected? Cheers, Tim

thoffeller commented 2 years ago

Ahh, it seems that are elements missing if the fabrication parts handled that way... In a bigger project I saw missing mep parts in a system. They are exported when I use the current master or my modifications in materialsformep branch. So, I think this isn't the perfect solution yet...

thoffeller commented 2 years ago

Hi @teocomi, the fabrication issue pops up again. Before we implement it we should agree an the best way to do it.

Thanks, Tim

teocomi commented 2 years ago

Hey @thoffeller I haven't worked with fabrication parts before, happy to jump on a quick call and see what's the best way to go about them. Cc @connorivy

thoffeller commented 2 years ago

Hi @teocomi, cool, how about next Monday, 11 am german time? Shall I send an teams invite? Thanks, Tim

barocuda commented 2 years ago

Hey @teocomi,

As you discussed with @thoffeller,here is the way we would implement the export of fabrication parts in two steps without changing anything in existing code:

public RevitElement FabricationPartToSpeckle(FabricationPart revitElement, out List<string> notes)
    {
        notes = new List<string>();

        RevitElement speckleElement = new RevitElement();

        speckleElement.type = revitElement.Name;

        speckleElement.category = revitElement.Category.Name;

        speckleElement.displayValue = GetFabricationMeshes(revitElement);

        //Only send elements that have a mesh, if not we should probably support them properly via direct conversions
        if (speckleElement.displayValue == null || speckleElement.displayValue.Count == 0)
        {
            notes.Add("Not sending elements without display meshes");
            return null;
        }

        GetAllRevitParamsAndIds(speckleElement, revitElement);

        return speckleElement;
    }

/// <summary>
    /// Get meshes from fabrication parts which have different geometry hierarchy than other revit elements.
    /// </summary>
    /// <param name="element"></param>
    /// <param name="subElements"></param>
    /// <returns></returns>
    public List<Mesh> GetFabricationMeshes(Element element, List<Element> subElements = null)
    {
        //Search for solids on geometry element level
        var allSolids = GetElementSolids(element, opt: new Options() { DetailLevel = ViewDetailLevel.Fine, ComputeReferences = true });

        List<Mesh> meshes = new List<Mesh>();

        var geom = element.get_Geometry(new Options());
        foreach (GeometryInstance instance in geom)
        {
            //Get instance geometry from fabrication part geometry
            var symbolGeometry = instance.GetInstanceGeometry();

            //Get meshes
            var symbolMeshes = GetMeshes(symbolGeometry, element.Document);
            meshes.AddRange(symbolMeshes);

            //Get solids
            var symbolSolids = GetSolids(symbolGeometry);
            allSolids.AddRange(symbolSolids);
        }

        if (subElements != null)
            foreach (var sb in subElements)
                allSolids.AddRange(GetElementSolids(sb));

        //Convert solids to meshes
        meshes.AddRange(GetMeshesFromSolids(allSolids, element.Document));

        return meshes;
    }

I have compiled the revit connector and exported a model, which contains many fabrication elements and Revit MEP Design elements. I invited you to stream. You can check it out.

teocomi commented 2 years ago

Thanks Baris! We're away at our company offsite and will most likely check this out the week after.

barocuda commented 1 year ago

Hi @teocomi,

Did you get a chance to check it out?

teocomi commented 1 year ago

We're going to look at this this week! Or you might keep it open for Hacktoberfest ;)

connorivy commented 1 year ago

Hey @barocuda sorry for just now getting around to this. Your code that you've posted here looks pretty good. However, it seems you've only implemented sending the fabrication parts to Speckle. Do you want to receive the parts back into Revit? If not then would you mind sharing your use case for sending these parts?

thoffeller commented 1 year ago

Hi @connorivy , thanks for your mail! Currently we need the export of fabrication parts only. The usecase is sending them out of Revit into a CAVE based on the speckle unity connector + a CAVE implementation in Unity. The plan is to visualize the speckle models for prefabrication planning in this CAVE. We need to check, if it is possible to bring those parts back into Revit. Fabrication is quiete complex and I'm afraid it won't work without a huge mapping....

connorivy commented 1 year ago

@thoffeller okay yeah that makes sense. I'll go ahead and push the code that you wrote into the next speckle release (2.9) which will be in about 2 weeks I think, but there will be some alpha versions of 2.9 availble next week.

Would you be able to send me a Revit model with a lot of these MEP fabrication parts? I'm wondering if implementing the receive functionality of these parts may be similar to other objects that we support and if we'd be able to reuse some code to get it to work.

teocomi commented 1 year ago

We can also let you PR if you prefer that ;)

thoffeller commented 1 year ago

Hi, we send a pr, so we have a chance to receive shirts 😉😂. Greetings, Tim

For further information please do not hesitate to contact me.

With kind regards

Tim Hoffeller Managing Director

ekkodale GmbH Friedrichstr. 10 GER-65185 Wiesbaden Managing director: Tim Hoffeller Headquarters and register court: Wiesbaden HRB 31552

phone: +49 611 34198071 mail: @.*** web: www.ekkodale.comhttp://www.ekkodale.com

This email may contain confidential or proprietary information and is intended for the recipient only. If you are not the intended recipient or have received this email in error, please inform the sender immediately and delete this email (including any attachments) from your system. The unauthorized copying as well as the unauthorized transmission of this email is not permitted.


From: Matteo Cominetti @.> Sent: Tuesday, October 4, 2022 4:57:03 PM To: specklesystems/speckle-sharp @.> Cc: Tim Hoffeller @.>; Mention @.> Subject: Re: [specklesystems/speckle-sharp] Revit MEP fabrication parts support for connector (Issue #1100)

We can also let you PR if you prefer that ;)

— Reply to this email directly, view it on GitHubhttps://github.com/specklesystems/speckle-sharp/issues/1100#issuecomment-1267137545, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACCKNHOVSZSAY5RWYQ5FPCDWBRAT7ANCNFSM5QPNR4KQ. You are receiving this because you were mentioned.Message ID: @.***>

thoffeller commented 1 year ago

Mr @barocuda , can you do your magic? 😁

barocuda commented 1 year ago

Sure, I will send PR today.

teocomi commented 1 year ago

Seems like this has been done but we forgot to close :)