public void Create() { //Delete Example Site if it already exists DbElement site = DbElement.GetElement("/ExampleSite"); if (site.IsValid) site.Delete(); //Get world element mWorld = DbElement.GetElement("/*"); //ExampleSite mSite = mWorld.Create(0, DbElementTypeInstance.SITE); mSite.SetAttribute(DbAttributeInstance.NAME, "/ExampleSite"); //ExampleZone mZone = mSite.Create(0, DbElementTypeInstance.ZONE); mZone.SetAttribute(DbAttributeInstance.NAME, "/ExampleZone"); //ExampleEqui mEqui = mZone.Create(0, DbElementTypeInstance.EQUIPMENT); mEqui.SetAttribute(DbAttributeInstance.NAME, "/ExampleEqui"); //ExampleCyli mCyli = mEqui.Create(0, DbElementTypeInstance.CYLINDER); mCyli.SetAttribute(DbAttributeInstance.NAME, "/ExampleCyli"); //ExampleBox mBox = mEqui.Create(0, DbElementTypeInstance.BOX); mBox.SetAttribute(DbAttributeInstance.NAME, "/ExampleBox"); //ExampleNozz1 mNozz1 = mEqui.Create(0, DbElementTypeInstance.NOZZLE); mNozz1.SetAttribute(DbAttributeInstance.NAME, "/ExampleNozz1"); //ExampleNozz2 mNozz2 = mEqui.Create(0, DbElementTypeInstance.NOZZLE); mNozz2.SetAttribute(DbAttributeInstance.NAME, "/ExampleNozz2"); //ExamplePipe mPipe = mZone.Create(0, DbElementTypeInstance.PIPE); mPipe.SetAttribute(DbAttributeInstance.NAME, "/ExamplePipe"); //ExampleBran mBran = mPipe.Create(0, DbElementTypeInstance.BRANCH); mBran.SetAttribute(DbAttributeInstance.NAME, "/ExampleBran"); //ExampleGask mGask = mBran.Create(0, DbElementTypeInstance.GASKET); mGask.SetAttribute(DbAttributeInstance.NAME, "/ExampleGask"); //ExampleElbow mElbo = mBran.Create(0, DbElementTypeInstance.ELBOW); mElbo.SetAttribute(DbAttributeInstance.NAME, "/ExampleElbow"); //ExampleTee mTee = mBran.Create(0, DbElementTypeInstance.TEE); mTee.SetAttribute(DbAttributeInstance.NAME, "/ExampleTee"); }
public void SEXT(Buildable element) { var ptcaX = _ptca(element.Direction.X, element.Position); var ptcaY = _ptca(element.Direction.Y, element.Position); //var ptcaZ = PTCA(element.Direction.Z, element.Position); var geom = _gmse.Create(1, DbElementTypeInstance.SEXTRUSION); geom.SetAttribute(DbAttributeInstance.TUFL, true); var error = string.Empty; PMLCommander.RunPMLCommand(geom, "PAAX", $"P{ptcaX.GetAsString(DbAttributeInstance.NUMB)}", out error); PMLCommander.RunPMLCommand(geom, "PBAX", $"P{ptcaY.GetAsString(DbAttributeInstance.NUMB)}", out error); PMLCommander.RunPMLCommand(geom, "PHEI", element.Size.Height.ToString(), out error); // no need to set position, as position is set by PAAX and PBAX //PMLCommander.RunPMLCommandInParentheses(geom, "PX", element.Position.X.ToString(), out error); //PMLCommander.RunPMLCommandInParentheses(geom, "PY", element.Position.Y.ToString(), out error); //PMLCommander.RunPMLCommandInParentheses(geom, "PZ", element.Position.Z.ToString(), out error); var sloo = geom.Create(1, DbElementTypeInstance.SLOOP); foreach (var vert in element.Verticies) { var svert = sloo.CreateLast(DbElementTypeInstance.SVERTEX); PMLCommander.RunPMLCommandInParentheses(svert, "PX", vert.X.ToString(), out error); PMLCommander.RunPMLCommandInParentheses(svert, "PY", vert.Y.ToString(), out error); } }
public void CreateBox(DbElement owner, IfcObjectGeometryData primitive) { DbElement dbElement = owner.Create(0, (DbElementType)DbElementTypeInstance.BOX); try { AABB aabb = new AABB(primitive.StartPointTS, primitive.EndPointTS); Point point = new Point(aabb.GetCenterPoint().X, aabb.GetCenterPoint().Y, aabb.GetCenterPoint().Z); Position pos = Position.Create(point.X, point.Y, point.Z); Vector xdirTs = primitive.XDirTS; xdirTs.Normalize(); Vector ydirTs = primitive.YDirTS; ydirTs.Normalize(); Orientation orientation = Tools.CreateOrientation(xdirTs, ydirTs); Tools.CreatePosOri(dbElement, pos, orientation); double num1 = Math.Round(primitive.XDimension, 0); Tools.SetAttribute(dbElement, (DbAttribute)DbAttributeInstance.XLEN, num1); double num2 = Math.Round(primitive.YDimension, 0); Tools.SetAttribute(dbElement, (DbAttribute)DbAttributeInstance.YLEN, num2); double num3 = Math.Round(Distance.PointToPoint(primitive.StartPointTS, primitive.EndPointTS), 0); Tools.SetAttribute(dbElement, (DbAttribute)DbAttributeInstance.ZLEN, num3); } catch { dbElement.Delete(); } }
public void CreateCylinder(DbElement owner, IfcObjectGeometryData primitive) { DbElement element = owner.Create(0, (DbElementType)DbElementTypeInstance.CYLINDER); try { Position position1 = Tools.GetPosition("POS WRT WORLD", ((object)owner.GetActualType()).Equals((object)DbElementTypeInstance.TMPLATE) ? owner.get_Owner() : owner); Orientation orientation1 = Tools.GetOrientation("ORI WRT WORLD", ((object)owner.GetActualType()).Equals((object)DbElementTypeInstance.TMPLATE) ? owner.get_Owner() : owner); Direction direction1 = orientation1.XDir(); Direction direction2 = orientation1.YDir(); Matrix coordinateSystem = MatrixFactory.ToCoordinateSystem(new CoordinateSystem(new Point(position1.get_X(), position1.get_Y(), position1.get_Z()), new Vector(direction1.get_East(), direction1.get_North(), direction1.get_Up()), new Vector(direction2.get_East(), direction2.get_North(), direction2.get_Up()))); double num1 = Math.Max(primitive.XDimension, primitive.YDimension); Tools.SetAttribute(element, (DbAttribute)DbAttributeInstance.DIAM, num1); Point startPointTs = primitive.StartPointTS; Point endPointTs = primitive.EndPointTS; new Vector(endPointTs - startPointTs).Normalize(); AABB aabb = new AABB(startPointTs, endPointTs); Point p = new Point(aabb.GetCenterPoint().X, aabb.GetCenterPoint().Y, aabb.GetCenterPoint().Z); Point point1 = coordinateSystem.Transform(startPointTs); Point point2 = coordinateSystem.Transform(endPointTs); Point point3 = coordinateSystem.Transform(p); Orientation orientation2 = Orientation.Create("Z IS " + ((object)Direction.Create(Position.Create(point1.X, point1.Y, point1.Z), Position.Create(point2.X, point2.Y, point2.Z))).ToString()); Position position2 = Position.Create( .X, point3.Y, point3.Z); Tools.SetAttribute(element, (DbAttribute)DbAttributeInstance.POS, position2); Tools.SetAttribute(element, (DbAttribute)DbAttributeInstance.ORI, orientation2); double num2 = Math.Round(Distance.PointToPoint(primitive.StartPointTS, primitive.EndPointTS), 0); Tools.SetAttribute(element, (DbAttribute)DbAttributeInstance.HEIG, num2); } catch { element.Delete(); } }
internal DbElement CreateEmptyScom(DbElement cata, DbElement equipment) { //look for correct SECT DbElement sect = cata.Members().SingleOrDefault(s => s.GetString(DbAttributeInstance.DESC) == equipment.Owner.GetString(DbAttributeInstance.DESC)); if (sect == null || sect.IsValid == false) { sect = cata.CreateLast(DbElementTypeInstance.SECTION); sect.SetAttributeValue(DbAttributeInstance.DESC, equipment.Owner.GetString(DbAttributeInstance.DESC)); } DbElement cate = sect.Create(1, DbElementTypeInstance.CATEGORY); DbElement scom = cate.Create(1, DbElementTypeInstance.SCOMPONENT); scom.SetAttribute(DbAttributeInstance.NAME, equipment.Name() + ".SCOM"); DbElement sdte = cate.Create(1, DbElementTypeInstance.SDTEXT); Update(scom, equipment); Element = cate; return(scom); }
public void LSNO(Buildable element) { Direction direction = element.Direction; Position position = element.Position; Size size = element.Size; var ptcaY = _ptca(direction.Y, position); var ptcaZ = _ptca(direction.Z, position); var geom = _gmse.Create(1, DbElementTypeInstance.LSNOUT); geom.SetAttribute(DbAttributeInstance.TUFL, true); geom.SetAttribute(DbAttributeInstance.CLFL, false); PMLCommander.RunPMLCommand(geom, "PTDI", size.Height.ToString(), out var error); //invert top and bot in paragon... PMLCommander.RunPMLCommand(geom, "PTDM", size.BotDiameter.ToString(), out error); PMLCommander.RunPMLCommand(geom, "PBDM", size.TopDiameter.ToString(), out error); PMLCommander.RunPMLCommand(geom, "POFF", "0", out error); PMLCommander.RunPMLCommand(geom, "PAAXIS", $"-P{ptcaZ.GetAsString(DbAttributeInstance.NUMB)}", out error); PMLCommander.RunPMLCommand(geom, "PBAXIS", $"P{ptcaY.GetAsString(DbAttributeInstance.NUMB)}", out error); }
public void LPYR(Buildable element) { Direction direction = element.Direction; Position position = element.Position; Size size = element.Size; var ptcaX = _ptca(direction.X, position); var ptcaY = _ptca(direction.Y, position); var ptcaZ = _ptca(direction.Z, position); var lpyr = _gmse.Create(1, DbElementTypeInstance.LPYRAMID); lpyr.SetAttribute(DbAttributeInstance.TUFL, true); string error; if (element.SourceType == DbElementTypeInstance.PYRAMID) { PMLCommander.RunPMLCommandInParentheses(lpyr, "PBTP", size.XTop.ToString("0.##"), out error); PMLCommander.RunPMLCommandInParentheses(lpyr, "PCTP", size.YTop.ToString("0.##"), out error); PMLCommander.RunPMLCommandInParentheses(lpyr, "PBBT", size.XBottom.ToString("0.##"), out error); PMLCommander.RunPMLCommandInParentheses(lpyr, "PCBT", size.YBottom.ToString("0.##"), out error); PMLCommander.RunPMLCommandInParentheses(lpyr, "PTDI", size.Height.ToString("0.##"), out error); PMLCommander.RunPMLCommandInParentheses(lpyr, "PBOF", size.XOffset.ToString("0.##"), out error); PMLCommander.RunPMLCommandInParentheses(lpyr, "PCOF", size.YOffset.ToString("0.##"), out error); } else { PMLCommander.RunPMLCommandInParentheses(lpyr, "PBTP", size.XLength.ToString("0.##"), out error); PMLCommander.RunPMLCommandInParentheses(lpyr, "PCTP", size.YLength.ToString("0.##"), out error); PMLCommander.RunPMLCommandInParentheses(lpyr, "PBBT", size.XLength.ToString("0.##"), out error); PMLCommander.RunPMLCommandInParentheses(lpyr, "PCBT", size.YLength.ToString("0.##"), out error); PMLCommander.RunPMLCommandInParentheses(lpyr, "PTDI", size.ZLength.ToString("0.##"), out error); } PMLCommander.RunPMLCommand(lpyr, "PBAX", $"P{ptcaX.GetAsString(DbAttributeInstance.NUMB)}", out error); PMLCommander.RunPMLCommand(lpyr, "PCAX", $"P{ptcaY.GetAsString(DbAttributeInstance.NUMB)}", out error); PMLCommander.RunPMLCommand(lpyr, "PAAX", $"P{ptcaZ.GetAsString(DbAttributeInstance.NUMB)}", out error); PMLCommander.RunPMLCommand(lpyr, "PAAX", $"P{ptcaZ.GetAsString(DbAttributeInstance.NUMB)}", out error); }
public void CreateExtrusion(DbElement owner, IfcObjectGeometryData primitive, bool chamfers) { DbElement dbElement1 = owner.Create(0, (DbElementType)DbElementTypeInstance.EXTRUSION); try { Vector xdirTs = primitive.XDirTS; xdirTs.Normalize(); Vector ydirTs = primitive.YDirTS; ydirTs.Normalize(); CoordinateSystem CoordSys = new CoordinateSystem(primitive.PolygonPointsTS[0], xdirTs, ydirTs); Matrix matrix = MatrixFactory.ToCoordinateSystem(CoordSys); Orientation orientation = Tools.CreateOrientation(xdirTs, ydirTs); Position pos = Position.Create(CoordSys.Origin.X, CoordSys.Origin.Y, CoordSys.Origin.Z); Tools.CreatePosOri(dbElement1, pos, orientation); double num1 = Math.Round(Distance.PointToPoint(primitive.StartPointTS, primitive.EndPointTS), 0); Tools.SetAttribute(dbElement1, (DbAttribute)DbAttributeInstance.HEIG, num1); DbElement dbElement2 = dbElement1.Create(0, (DbElementType)DbElementTypeInstance.LOOP); int index = 0; List <Point> points; List <double> chamfers1; new PolygonCreator().GetPolygonPointsArcMiddelePoint(primitive, out points, out chamfers1); List <Point> list = points.Select <Point, Point>((Func <Point, Point>)(p => matrix.Transform(p))).ToList <Point>(); Tools.CleanPolygonImport(ref chamfers1, ref list); foreach (Point point in list) { DbElement element = dbElement2.Create(0, (DbElementType)DbElementTypeInstance.VERTEX); Tools.SetAttribute(element, (DbAttribute)DbAttributeInstance.POS, Position.Create(point.X, point.Y, point.Z)); double num2 = chamfers ? Math.Floor(chamfers1[index]) : 0.0; Tools.SetAttribute(element, (DbAttribute)DbAttributeInstance.FRAD, num2); ++index; } } catch { dbElement1.Delete(); } }
public void Create() { //Delete Example Site if it already exists DbElement site = DbElement.GetElement("/ExampleSite"); if (site.IsValid) { site.Delete(); } //Get world element mWorld = DbElement.GetElement("/*"); //ExampleSite mSite = mWorld.Create(0, DbElementTypeInstance.SITE); mSite.SetAttribute(DbAttributeInstance.NAME, "/ExampleSite"); //ExampleZone mZone = mSite.Create(0, DbElementTypeInstance.ZONE); mZone.SetAttribute(DbAttributeInstance.NAME, "/ExampleZone"); //ExampleEqui mEqui = mZone.Create(0, DbElementTypeInstance.EQUIPMENT); mEqui.SetAttribute(DbAttributeInstance.NAME, "/ExampleEqui"); //ExampleCyli mCyli = mEqui.Create(0, DbElementTypeInstance.CYLINDER); mCyli.SetAttribute(DbAttributeInstance.NAME, "/ExampleCyli"); //ExampleBox mBox = mEqui.Create(0, DbElementTypeInstance.BOX); mBox.SetAttribute(DbAttributeInstance.NAME, "/ExampleBox"); //ExampleNozz1 mNozz1 = mEqui.Create(0, DbElementTypeInstance.NOZZLE); mNozz1.SetAttribute(DbAttributeInstance.NAME, "/ExampleNozz1"); //ExampleNozz2 mNozz2 = mEqui.Create(0, DbElementTypeInstance.NOZZLE); mNozz2.SetAttribute(DbAttributeInstance.NAME, "/ExampleNozz2"); //ExamplePipe mPipe = mZone.Create(0, DbElementTypeInstance.PIPE); mPipe.SetAttribute(DbAttributeInstance.NAME, "/ExamplePipe"); //ExampleBran mBran = mPipe.Create(0, DbElementTypeInstance.BRANCH); mBran.SetAttribute(DbAttributeInstance.NAME, "/ExampleBran"); //ExampleGask mGask = mBran.Create(0, DbElementTypeInstance.GASKET); mGask.SetAttribute(DbAttributeInstance.NAME, "/ExampleGask"); //ExampleElbow mElbo = mBran.Create(0, DbElementTypeInstance.ELBOW); mElbo.SetAttribute(DbAttributeInstance.NAME, "/ExampleElbow"); //ExampleTee mTee = mBran.Create(0, DbElementTypeInstance.TEE); mTee.SetAttribute(DbAttributeInstance.NAME, "/ExampleTee"); }