В настоящее время я работаю над проектом, который включает создание файла IFC для структурных элементов с использованием C# и Xbim.Essentials. Я попробовал следующий код, но сгенерированный файл IFC кажется неправильным. В частности, выдавливание работает нормально в направлении z, но для направлений x и y форма не перпендикулярна направлению выдавливания.
Вот код, который я использовал:< /p>
static void Main(string[] args)
{
// Define the path for the IFC file to be saved
var path = "SteelProfiles.ifc";
var credentials = new XbimEditorCredentials
{
ApplicationDevelopersName = "EZ Bim Apps Inc",
ApplicationFullName = "My BIM App",
ApplicationIdentifier = "my-bim-app",
ApplicationVersion = "1.0",
EditorsFamilyName = "John",
EditorsGivenName = "Doe",
EditorsOrganisationName = "Acme Consultants Inc"
};
var sizes = new List();
using (var model = IfcStore.Create(credentials, XbimSchemaVersion.Ifc4, XbimStoreType.InMemoryModel))
{
// Begin a transaction to write data to the model
using (var txn = model.BeginTransaction("Create Model"))
{
// Define units in millimeters
var project = model.Instances.New(p =>
{
p.Name = "Sample Project";
p.UnitsInContext = model.Instances.New(u =>
{
u.Units.Add(model.Instances.New(s =>
{
s.UnitType = IfcUnitEnum.LENGTHUNIT;
s.Name = IfcSIUnitName.METRE;
s.Prefix = IfcSIPrefix.MILLI;
}));
});
});
// Create a geometric context
var context = model.Instances.New(c =>
{
c.ContextType = "Model";
c.CoordinateSpaceDimension = 3;
c.Precision = 0.0001;
c.WorldCoordinateSystem = model.Instances.New(w => { w.Location = model.Instances.New(p => p.SetXYZ(0, 0, 0)); });
});
// Create the steel profile IPE300
var profileDef = model.Instances.New(p =>
{
p.ProfileType = IfcProfileTypeEnum.AREA;
p.ProfileName = "IPE300";
p.OverallWidth = 150; // Width of the flange in mm
p.OverallDepth = 300; // Depth of the profile in mm
p.WebThickness = 6.8; // Thickness of the web in mm
p.FlangeThickness = 10.7; // Thickness of the flange in mm
p.FilletRadius = 15; // Radius of the fillet in mm
//p.Position = model.Instances.New(p1 => p1.Location = model.Instances.New(q => q.SetXY(0, 0)));
});
// Create two beams with IPE300 profile
CreateBeam(model, profileDef, context, 0, 0, 1000, 1000, 0, 1000);
CreateBeam(model, profileDef, context, 1000, 0, 1000, 1000, 2000, 1000);
CreateBeam(model, profileDef, context, 0, 0, 0, 0, 0, 3000);
// Commit the transaction
txn.Commit();
}
// Save the model to an IFC file
model.SaveAs(path);
}
}
private static void CreateBeam(IfcStore model, IfcProfileDef profile, IfcGeometricRepresentationContext context, double x1, double y1, double z1, double x2, double y2, double z2)
{
const double TOLERANCE = 0.0001;
var x = Math.Abs(x1 - x2) < TOLERANCE ? 0 : 1;
var y = Math.Abs(y1 - y2) < TOLERANCE ? 0 : 1;
var z = Math.Abs(z1 - z2) < TOLERANCE ? 0 : 1;
var depth = Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2) + Math.Pow(z2 - z1, 2));
// Direction vector for the beam's extrusion
var dirX = (x2 - x1) / depth;
var dirY = (y2 - y1) / depth;
var dirZ = (z2 - z1) / depth;
var beam = model.Instances.New(b =>
{
b.Name = "IPE300 Beam";
b.ObjectPlacement = model.Instances.New(lp =>
{
lp.RelativePlacement = model.Instances.New(ap =>
{
ap.Location = model.Instances.New(p => p.SetXYZ(x1, y1, z1));
//ap.RefDirection = model.Instances.New(d => d.SetXYZ(dirX, dirY, dirZ));
ap.Axis = model.Instances.New(p => p.SetXYZ(0, 0, 1));
});
});
b.Representation = model.Instances.New(r =>
{
var bodyRep = model.Instances.New(sr =>
{
sr.ContextOfItems = context;
sr.RepresentationIdentifier = "Body";
sr.RepresentationType = "SweptSolid";
sr.Items.Add(model.Instances.New(s =>
{
s.Depth = depth;
s.SweptArea = profile;
s.ExtrudedDirection = model.Instances.New(d => d.SetXYZ(dirX, dirY, dirZ));
}));
});
r.Representations.Add(bodyRep);
});
});
}
Я пытался следовать правильному подходу, но проблема, с которой я столкнулся, заключается в том, что, хотя выдавливание в направлении Z правильное, формы не перпендикулярны направлению выдавливания в направлениях x и y.Будем очень признательны за любую помощь или предложения о том, как это исправить!
В настоящее время я работаю над проектом, который включает создание файла IFC для структурных элементов с использованием C# и Xbim.Essentials. Я попробовал следующий код, но сгенерированный файл IFC кажется неправильным. В частности, выдавливание работает нормально в направлении z, но для направлений x и y форма не перпендикулярна направлению выдавливания. Вот код, который я использовал:< /p> [code] static void Main(string[] args) { // Define the path for the IFC file to be saved var path = "SteelProfiles.ifc";
using (var model = IfcStore.Create(credentials, XbimSchemaVersion.Ifc4, XbimStoreType.InMemoryModel)) { // Begin a transaction to write data to the model using (var txn = model.BeginTransaction("Create Model")) { // Define units in millimeters var project = model.Instances.New(p => { p.Name = "Sample Project"; p.UnitsInContext = model.Instances.New(u => { u.Units.Add(model.Instances.New(s => { s.UnitType = IfcUnitEnum.LENGTHUNIT; s.Name = IfcSIUnitName.METRE; s.Prefix = IfcSIPrefix.MILLI; })); }); });
// Create the steel profile IPE300 var profileDef = model.Instances.New(p => { p.ProfileType = IfcProfileTypeEnum.AREA; p.ProfileName = "IPE300";
p.OverallWidth = 150; // Width of the flange in mm p.OverallDepth = 300; // Depth of the profile in mm p.WebThickness = 6.8; // Thickness of the web in mm p.FlangeThickness = 10.7; // Thickness of the flange in mm p.FilletRadius = 15; // Radius of the fillet in mm
Я пытался следовать правильному подходу, но проблема, с которой я столкнулся, заключается в том, что, хотя выдавливание в направлении Z правильное, формы не перпендикулярны направлению выдавливания в направлениях x и y.Будем очень признательны за любую помощь или предложения о том, как это исправить!