Giter Club home page Giter Club logo

Comments (3)

alex-d-richards avatar alex-d-richards commented on July 18, 2024 1

hi @clairekuang thanks for reviewing this. I have pulled a copy the dev branch and from my limited testing so far this looks to provide the parameters that I was expecting.

Reviewing this same wok flow I do have a few other comments, queries but I think I will add these to the community page later in the week.

from speckle-sharp.

alex-d-richards avatar alex-d-richards commented on July 18, 2024
public Structure StructureToSpeckle(CivilDB.Structure structure)
{
  // get ids pipes that are connected to this structure
  var pipeIds = new List<string>();
  var pipeNames = new List<string>();
  for (int i = 0; i < structure.ConnectedPipesCount; i++)
  {
    pipeIds.Add(structure.get_ConnectedPipe(i).ToString());

  }

  Structure speckleStructure = new()
  {
    location = PointToSpeckle(structure.Location, ModelUnits),
    pipeIds = pipeIds,
    displayValue = new List<Mesh>() { SolidToSpeckle(structure.Solid3dBody, out List<string> _) },
    units = ModelUnits,
    //applicationId = structure.Id.ToString()
  };

  // assign additional structure props
  AddNameAndDescriptionProperty(structure.Name, structure.Description, speckleStructure);

  try { speckleStructure["grate"] = structure.Grate; } catch (Exception e) when (!e.IsFatal()) { }
  try { speckleStructure["station"] = structure.Station; } catch (Exception e) when (!e.IsFatal()) { }
  try { speckleStructure["network"] = structure.NetworkName; } catch (Exception e) when (!e.IsFatal()) { }
  try { speckleStructure["sumpDepth"] = structure.SumpDepth; } catch (Exception e) when (!e.IsFatal()) { }
  try { speckleStructure["rimElevation"] = structure.RimElevation; } catch (Exception e) when (!e.IsFatal()) { }
  try { speckleStructure["sumpDepth"] = structure.SumpDepth; } catch (Exception e) when (!e.IsFatal()) { }
  try { speckleStructure["sumpElevation"] = structure.SumpElevation; } catch (Exception e) when (!e.IsFatal()) { }
  try { speckleStructure["wallThickness"] = structure.WallThickness; } catch (Exception e) when (!e.IsFatal()) { }
  try { speckleStructure["floorThickness"] = structure.FloorThickness; } catch (Exception e) when (!e.IsFatal()) { }
  try { speckleStructure["rotation"] = structure.Rotation; } catch (Exception e) when (!e.IsFatal()) { }
  try { speckleStructure["material"] = structure.Material; } catch (Exception e) when (!e.IsFatal()) { }
  try { speckleStructure["diameterOuter"] = structure.DiameterOrWidth; } catch (Exception e) when (!e.IsFatal()) { }
  try { speckleStructure["diameterInner"] = structure.InnerDiameterOrWidth; } catch (Exception e) when (!e.IsFatal()) { }
  try { speckleStructure["lengthOuter"] = structure.Length; } catch (Exception e) when (!e.IsFatal()) { }
  try { speckleStructure["lengthInner"] = structure.InnerLength; } catch (Exception e) when (!e.IsFatal()) { }
  try { speckleStructure["height"] = structure.Height; } catch (Exception e) when (!e.IsFatal()) { }
  try { speckleStructure["structureId"] = structure.Id.ToString(); } catch (Exception ex) when (!ex.IsFatal()) { }
  //try { speckleStructure["structureId"] = structure.Id; } catch (Exception ex) when (!ex.IsFatal()) { }

  return speckleStructure;
}
public Pipe PipeToSpeckle(CivilDB.Pipe pipe)
{
  // get the pipe curve
  ICurve curve;
  switch (pipe.SubEntityType)
  {
    case PipeSubEntityType.Straight:
      var line = new Acad.LineSegment3d(pipe.StartPoint, pipe.EndPoint);
      curve = LineToSpeckle(line);
      break;
    default:
      curve = CurveToSpeckle(pipe.BaseCurve);
      break;
  }

  Pipe specklePipe = new()
  {
    baseCurve = curve,
    diameter = pipe.InnerDiameterOrWidth,
    length = pipe.Length3DToInsideEdge,
    displayValue = new List<Mesh> { SolidToSpeckle(pipe.Solid3dBody, out List<string> notes) },
    units = ModelUnits,
    //applicationId = pipe.Id.ToString()
  };

  // assign additional pipe props
  AddNameAndDescriptionProperty(pipe.Name, pipe.Description, specklePipe);

  try { specklePipe["shape"] = pipe.CrossSectionalShape.ToString(); } catch (Exception ex) when (!ex.IsFatal()) { }
  try { specklePipe["slope"] = pipe.Slope; } catch (Exception ex) when (!ex.IsFatal()) { }
  try { specklePipe["flowDirection"] = pipe.FlowDirection.ToString(); } catch (Exception ex) when (!ex.IsFatal()) { }
  try { specklePipe["flowRate"] = pipe.FlowRate; } catch (Exception ex) when (!ex.IsFatal()) { }
  try { specklePipe["network"] = pipe.NetworkName; } catch (Exception ex) when (!ex.IsFatal()) { }
  try { specklePipe["startOffset"] = pipe.StartOffset; } catch (Exception ex) when (!ex.IsFatal()) { }
  try { specklePipe["endOffset"] = pipe.EndOffset; } catch (Exception ex) when (!ex.IsFatal()) { }
  try { specklePipe["startStation"] = pipe.StartStation; } catch (Exception ex) when (!ex.IsFatal()) { }
  try { specklePipe["endStation"] = pipe.EndStation; } catch (Exception ex) when (!ex.IsFatal()) { }
  try { specklePipe["startStructure"] = pipe.StartStructureId.ToString(); } catch (Exception ex) when (!ex.IsFatal()) { }
  try { specklePipe["endStructure"] = pipe.EndStructureId.ToString(); } catch (Exception ex) when (!ex.IsFatal()) { }
  try { specklePipe["material"] = pipe.Material; } catch (Exception ex) when (!ex.IsFatal()) { }
  try { specklePipe["thickness"] = pipe.WallThickness; } catch (Exception ex) when (!ex.IsFatal()) { }
  try { specklePipe["slope"] = pipe.Slope; } catch (Exception ex) when (!ex.IsFatal()) { }
  try { specklePipe["pipeId"] = pipe.Id.ToString(); } catch (Exception ex) when (!ex.IsFatal()) { }
  //try { specklePipe["pipeId"] = pipe.Id; } catch (Exception ex) when (!ex.IsFatal()) { }


  return specklePipe;
}

from speckle-sharp.

clairekuang avatar clairekuang commented on July 18, 2024

Hey @alex-d-richards , could you take a look at this recent pr that adds PartData to pipes and structures? It does contain some of the missing properties you mentioned, but perhaps not all of them. Is the information in PartData enough, or do you require all of the properties?

from speckle-sharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.