8000 Added support for more types by sachint2001 · Pull Request #5 · paireks/T-Rex · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Added support for more types #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions T-Rex/CreateIfcGH.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ protected override void RegisterInputParams(GH_Component.GH_InputParamManager pM
GH_ParamAccess.item);
pManager.AddTextParameter("Path", "Path", "Path where the IFC file will be saved, should end up with .ifc",
GH_ParamAccess.item);
pManager.AddBooleanParameter("EnableGenerate", "EnableGenerate", "Enable generation of ifc",
GH_ParamAccess.item);
}
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
Expand All @@ -35,13 +37,18 @@ protected override void SolveInstance(IGH_DataAccess DA)
string projectName = string.Empty;
string buildingName = string.Empty;
string path = string.Empty;
bool enableGen = false;

DA.GetDataList(0, elementGroups);
DA.GetData(1, ref projectName);
DA.GetData(2, ref buildingName);
DA.GetData(3, ref path);

Ifc Ifc = new Ifc(elementGroups, projectName, buildingName, path);
DA.GetData(4, ref enableGen);

if (enableGen)
{
Ifc Ifc = new Ifc(elementGroups, projectName, buildingName, path);
}
}
protected override System.Drawing.Bitmap Icon
{
Expand Down
17 changes: 12 additions & 5 deletions T-Rex/MeshToElementsGH.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ protected override void RegisterInputParams(GH_Component.GH_InputParamManager pM
pManager.AddTextParameter("Name", "Name", "Name of the elements", GH_ParamAccess.item);
pManager.AddMeshParameter("Mesh", "Mesh", "Mesh representation of model", GH_ParamAccess.item);
pManager.AddGenericParameter("Material", "Material", "Concrete element material", GH_ParamAccess.item);
pManager.AddIntegerParameter("Type", "Type", "Element type as integer. 0 = Pad Footing, 1 = Strip Footing, 2 = Beam, 3 = Column", GH_ParamAccess.item);
pManager.AddTextParameter("MainType", "MainType", "Main Element type as text", GH_ParamAccess.item);
pManager.AddTextParameter("SubType", "SubType", "Sub Element type as text", GH_ParamAccess.item, "notdefined");
pManager.AddPlaneParameter("Insert Planes", "Insert Planes", "Destination planes of an element",
GH_ParamAccess.list);

}
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
Expand All @@ -34,16 +36,21 @@ protected override void SolveInstance(IGH_DataAccess DA)
string name = String.Empty;
Mesh mesh = null;
Material material = null;
int type = 0;
List<Plane> insertPlanes = new List<Plane>();
string maintype = "door";
string subtype = "notdefined";

DA.GetData(0, ref name);
DA.GetData(1, ref mesh);
DA.GetData(2, ref material);
DA.GetData(3, ref type);
DA.GetDataList(4, insertPlanes);
DA.GetData(3, ref maintype);
DA.GetData(4, ref subtype);
DA.GetDataList(5, insertPlanes);

string maintype_small = maintype.ToLower();
string subtype_small = subtype.ToLower();

MeshToElements customElements = new MeshToElements(name, mesh, material, type, insertPlanes);
MeshToElements customElements = new MeshToElements(name, mesh, material, maintype_small, subtype_small, insertPlanes);

DA.SetData(0, customElements);
DA.SetDataList(1, customElements.ResultMesh);
Expand Down
18 changes: 12 additions & 6 deletions T-Rex/ProfileToElementsGH.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ protected override void RegisterInputParams(GH_Component.GH_InputParamManager pM
pManager.AddAngleParameter("Rotation Angle", "Rotation Angle", "Set rotation angle for the profile",
GH_ParamAccess.item);
pManager.AddGenericParameter("Material", "Material", "Concrete element material", GH_ParamAccess.item);
pManager.AddIntegerParameter("Type", "Type", "Element type as integer. 0 = Pad Footing, 1 = Strip Footing, 2 = Beam, 3 = Column", GH_ParamAccess.item);
pManager.AddTextParameter("MainType", "MainType", "Main Element type as text", GH_ParamAccess.item);
pManager.AddTextParameter("SubType", "SubType", "Sub Element type as text", GH_ParamAccess.item, "notdefined");
pManager.AddLineParameter("Insert Lines", "Insert Lines", "Lines to specify the element length and position",
GH_ParamAccess.list);
}
Expand All @@ -35,7 +36,7 @@ protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager
pManager.AddGenericParameter("Element Group", "Element Group", "Concrete elements", GH_ParamAccess.item);
pManager.AddBrepParameter("Breps", "Breps", "Breps that represent concrete elements", GH_ParamAccess.list);
}

protected override void BeforeSolveInstance()
{
base.BeforeSolveInstance();
Expand All @@ -50,18 +51,23 @@ protected override void SolveInstance(IGH_DataAccess DA)
List<Line> lines = new List<Line>();
double angle = 0.0;
Material material = null;
int type = 0;
string maintype = "door";
string subtype = "notdefined";

DA.GetData(0, ref name);
DA.GetData(1, ref profile);
if (!DA.GetData(2, ref angle)) return;
if (_useDegrees)
angle = RhinoMath.ToRadians(angle);
DA.GetData(3, ref material);
DA.GetData(4, ref type);
DA.GetDataList(5, lines);
DA.GetData(4, ref maintype);
DA.GetData(5, ref subtype);
DA.GetDataList(6, lines);

string maintype_small = maintype.ToLower();
string subtype_small = subtype.ToLower();

ProfileToElements profileToElements = new ProfileToElements(name, profile, lines, angle, material, type);
ProfileToElements profileToElements = new ProfileToElements(name, profile, lines, angle, material, maintype_small, subtype_small);

DA.SetData(0, profileToElements);
DA.SetDataList(1, profileToElements.Breps);
Expand Down
2 changes: 1 addition & 1 deletion T-Rex/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions T-Rex/T_Rex.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -15,6 +15,7 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -173,7 +174,7 @@
</Target>
-->
<PropertyGroup>
<PostBuildEvent>Copy "$(TargetPath)" "C:\Users\code-structures\AppData\Roaming\Grasshopper\Libraries\T-Rex\T-Rex.gha"
<PostBuildEvent>Copy "$(TargetPath)" "$(TargetDir)$(ProjectName).gha"
Erase "$(TargetPath)"</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
Expand Down
6 changes: 6 additions & 0 deletions T-RexEngine/ElementGroup.cs
9E19
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
using Rhino.Geometry;
using T_RexEngine.Enums;
using Xbim.Ifc;
using Xbim.Ifc4.Kernel;
using Xbim.Ifc4.ProductExtension;
using Xbim.Ifc4.StructuralElementsDomain;
using Xbim.Ifc4.SharedComponentElements;

namespace T_RexEngine
{
Expand All @@ -13,7 +15,11 @@ public abstract class ElementGroup
public Material Material { get; set; }
public ElementType ElementType { get; set; }
public abstract List<IfcBuildingElement> ToBuildingElementIfc(IfcStore model);
public abstract List<IfcProxy> ToProxyIfc(IfcStore model);
public abstract List<IfcReinforcingElement> ToReinforcingElementIfc(IfcStore model);
public abstract List<IfcElementComponent> ToElementComponentIfc(IfcStore model);
public abstract List<IfcDistributionElement> ToDistributionElementIfc(IfcStore model);
public abstract List<IfcElement> ToElementIfc(IfcStore model);
public int Amount { get; set; }
public double Volume { get; set; }
public double Mass { get; set; }
Expand Down
113 changes: 106 additions & 7 deletions T-RexEngine/ElementLibrary/MeshToElements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
using Rhino.Geometry;
using Rhino.Geometry.Collections;
using Xbim.Ifc;
using Xbim.Ifc4.Kernel;
using Xbim.Ifc4.GeometricModelResource;
using Xbim.Ifc4.GeometryResource;
using Xbim.Ifc4.ProductExtension;
using Xbim.Ifc4.StructuralElementsDomain;
usin F438 g Xbim.Ifc4.SharedComponentElements;


namespace T_RexEngine.ElementLibrary
{
public class MeshToElements: ElementGroup
public class MeshToElements : ElementGroup
{
private Mesh _mesh;
public MeshToElements(string name, Mesh mesh, Material material, int type, List<Plane> insertPlanes)
public MeshToElements(string name, Mesh mesh, Material material, string mainType, string subType, List<Plane> insertPlanes)
{
Name = name;
Mesh = mesh;
Expand All @@ -22,7 +25,7 @@ public MeshToElements(string name, Mesh mesh, Material material, int type, List<
Volume = VolumeMassProperties.Compute(mesh).Volume * Amount;
Mass = Volume * material.Density;
InsertPlanes = insertPlanes;
ElementType = IfcTools.IntToType(type);
ElementType = IfcTools.StringToType(mainType, subType);
ResultMesh = new List<Mesh>();

foreach (var plane in InsertPlanes)
Expand All @@ -41,7 +44,22 @@ public override string ToString()

public override List<IfcReinforcingElement> ToReinforcingElementIfc(IfcStore model)
{
throw new ArgumentException("Mesh elements should be converted to IfcBuildingElement");
using (var transaction = model.BeginTransaction("Create Mesh Element"))
{
MeshFaceList faces = Mesh.Faces;
MeshVertexList vertices = Mesh.Vertices;
List<IfcCartesianPoint> ifcVertices = IfcTools.VerticesToIfcCartesianPoints(model, vertices);
IfcFaceBasedSurfaceModel faceBasedSurfaceModel = IfcTools.CreateIfcFaceBasedSurfaceModel(model, faces, ifcVertices);
var shape = IfcTools.CreateIfcShapeRepresentation(model, "Mesh");
shape.Items.Add(faceBasedSurfaceModel);
var ifcRelAssociatesMaterial = IfcTools.CreateIfcRelAssociatesMaterial(model, Material.Name, Material.Grade);
var reinforcingElements = IfcTools.CreateReinforcingElements(model, ElementType, Name, shape, InsertPlanes,
ifcRelAssociatesMaterial);

transaction.Commit();

return reinforcingElements;
}
}

public override List<IfcBuildingElement> ToBuildingElementIfc(IfcStore model)
Expand All @@ -59,10 +77,91 @@ public override List<IfcBuildingElement> ToBuildingElementIfc(IfcStore model)
ifcRelAssociatesMaterial);

transaction.Commit();

return buildingElements;
}
}

public override List<IfcProxy> ToProxyIfc(IfcStore model)
{
using (var transaction = model.BeginTransaction("Create Mesh Element"))
{
MeshFaceList faces = Mesh.Faces;
MeshVertexList vertices = Mesh.Vertices;
List<IfcCartesianPoint> ifcVertices = IfcTools.VerticesToIfcCartesianPoints(model, vertices);
IfcFaceBasedSurfaceModel faceBasedSurfaceModel = IfcTools.CreateIfcFaceBasedSurfaceModel(model, faces, ifcVertices);
var shape = IfcTools.CreateIfcShapeRepresentation(model, "Mesh");
shape.Items.Add(faceBasedSurfaceModel);
var ifcRelAssociatesMaterial = IfcTools.CreateIfcRelAssociatesMaterial(model, Material.Name, Material.Grade);
var proxy = IfcTools.CreateProxy(model, ElementType, Name, shape, InsertPlanes,
ifcRelAssociatesMaterial);

transaction.Commit();

return proxy;
}
}

public override List<IfcElement> ToElementIfc(IfcStore model)
{
using (var transaction = model.BeginTransaction("Create Mesh Element"))
{
MeshFaceList faces = Mesh.Faces;
MeshVertexList vertices = Mesh.Vertices;
List<IfcCartesianPoint> ifcVertices = IfcTools.VerticesToIfcCartesianPoints(model, vertices);
IfcFaceBasedSurfaceModel faceBasedSurfaceModel = IfcTools.CreateIfcFaceBasedSurfaceModel(model, faces, ifcVertices);
var shape = IfcTools.CreateIfcShapeRepresentation(model, "Mesh");
shape.Items.Add(faceBasedSurfaceModel);
var ifcRelAssociatesMaterial = IfcTools.CreateIfcRelAssociatesMaterial(model, Material.Name, Material.Grade);
var element = IfcTools.CreateElement(model, ElementType, Name, shape, InsertPlanes,
ifcRelAssociatesMaterial);

transaction.Commit();

return element;
}
}

public override List<IfcElementComponent> ToElementComponentIfc(IfcStore model)
{
using (var transaction = model.BeginTransaction("Create Mesh Element"))
{
MeshFaceList faces = Mesh.Faces;
MeshVertexList vertices = Mesh.Vertices;
List<IfcCartesianPoint> ifcVertices = IfcTools.VerticesToIfcCartesianPoints(model, vertices);
IfcFaceBasedSurfaceModel faceBasedSurfaceModel = IfcTools.CreateIfcFaceBasedSurfaceModel(model, faces, ifcVertices);
var shape = IfcTools.CreateIfcShapeRepresentation(model, "Mesh");
shape.Items.Add(faceBasedSurfaceModel);
var ifcRelAssociatesMaterial = IfcTools.CreateIfcRelAssociatesMaterial(model, Material.Name, Material.Grade);
var elementComponents = IfcTools.CreateElementComponent(model, ElementType, Name, shape, InsertPlanes,
ifcRelAssociatesMaterial);

transaction.Commit();

return elementComponents;
}
}

public override List<IfcDistributionElement> ToDistributionElementIfc(IfcStore model)
{
using (var transaction = model.BeginTransaction("Create Mesh Element"))
{
MeshFaceList faces = Mesh.Faces;
MeshVertexList vertices = Mesh.Vertices;
List<IfcCartesianPoint> ifcVertices = IfcTools.VerticesToIfcCartesianPoints(model, vertices);
IfcFaceBasedSurfaceModel faceBasedSurfaceModel = IfcTools.CreateIfcFaceBasedSurfaceModel(model, faces, ifcVertices);
var shape = IfcTools.CreateIfcShapeRepresentation(model, "Mesh");
shape.Items.Add(faceBasedSurfaceModel);
var ifcRelAssociatesMaterial = IfcTools.CreateIfcRelAssociatesMaterial(model, Material.Name, Material.Grade);
var elementComponents = IfcTools.CreateDistributionElement(model, ElementType, Name, shape, InsertPlanes,
ifcRelAssociatesMaterial);

transaction.Commit();

return elementComponents;
}
}

public string Name { get; }

public Mesh Mesh
Expand All @@ -80,6 +179,6 @@ private set

public List<Mesh> ResultMesh { get; }
public List<Plane> InsertPlanes { get; }

}
}
}
Loading
0