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(); } }
public Buildable Convert(DbElement element) { Size size = new Size(); Position position = new Position(); Direction direction = new Direction(); size.Height = element.GetDouble(DbAttributeInstance.HEIG); size.Diameter = element.GetDouble(DbAttributeInstance.DIAM); var q = new DbQualifier(); q.Add(1); q.wrtQualifier = element.OwnerInHierarchyOfType(DbElementTypeInstance.EQUIPMENT); var pos = element.GetPosition(DbAttributeInstance.PPOS, q); position.X = pos.X; position.Y = pos.Y; position.Z = pos.Z; var d = element.GetDirection(DbAttributeInstance.PDIR, q); direction.X = d.ToString(); direction.Y = d.ToString(); direction.Z = d.ToString(); return(new Buildable(DbElementTypeInstance.SCYLINDER, element, size, position, direction, element.ElementType)); }
public static AxisDir Eval(DbElement modelEle, string exper) { exper = exper.Trim().ToUpper(); if (exper.IndexOfAny(flags) >= 0) { return(new AxisDir(Position.Create(), ParseExperDir(exper, modelEle))); } else if (exper.Contains('P')) { bool isNeg = false; if (exper[0] == '-') { isNeg = true; exper = exper.Substring(1).Trim(); } exper = exper.Substring(exper[1] == 'P' ? 2 : 1); int num = int.Parse(exper); AxisDir ad = null; ad = MakeDirection(num, isNeg, modelEle); if (ad == null || (ad.Dir.East + ad.Dir.North + ad.Dir.Up) < 0.000001) { ad = null; } return(ad); } else { return(new AxisDir(Position.Create(), Direction.Create(exper))); } }
public SpcoRepresentation(DbElement scom, DbElement equipment, Text text) { Scom = scom; _equipment = equipment; Sdte = text.Sdte; MatxtTextElement = text.MatxtElement(equipment); Stype = text.Stype(equipment); FirstSeleTans = text.TypeTans(equipment); DBElementCollection ptcas = new DBElementCollection(Scom.Owner, new TypeFilter(DbElementTypeInstance.PTCAR)); foreach (DbElement ptca in ptcas) { if (ptca.GetAsString(DbAttributeInstance.NUMB) == "1") { var t = ptca.GetAsString(DbAttributeInstance.PBOR); t = t.Replace("(", string.Empty); t = t.Replace("'", string.Empty); t = t.Replace(")", string.Empty); PBore1 = double.Parse(t); } else if (ptca.GetAsString(DbAttributeInstance.NUMB) == "2") { var t = ptca.GetAsString(DbAttributeInstance.PBOR); t = t.Replace("(", string.Empty); t = t.Replace("'", string.Empty); t = t.Replace(")", string.Empty); PBore2 = double.Parse(t); } } }
public TempDb() { Logger.WriteLine("Getting configuration details"); var settings = (TempDbSettingsSection)ConfigurationManager.GetSection("TempDbSettings"); Logger.WriteLine(" - Getting source settings"); DbElement sourceSettings = settings.SourceDb; Logger.WriteLine(" - Getting target settings"); _targetSettings = settings.TargetDb; Logger.WriteLine("Creating source connection"); var sourceConnection = new ServerConnection(sourceSettings.ServerInstance, sourceSettings.UserName, sourceSettings.Password); Logger.WriteLine(" - {0}", sourceConnection.SqlConnectionObject.ConnectionString); Logger.WriteLine("Creating source server"); _sourceServer = new Server(sourceConnection); _sourceDatabase = _sourceServer.Databases[sourceSettings.DatabaseName]; Logger.WriteLine("Creating target connection"); var targetConnection = new ServerConnection(_targetSettings.ServerInstance, _targetSettings.UserName, _targetSettings.Password); Logger.WriteLine(" - {0}", targetConnection.SqlConnectionObject.ConnectionString); Logger.WriteLine("Creating target server"); _targetServer = new Server(targetConnection); _targetDatabase = new Database(_targetServer, _targetSettings.DatabaseName); Tables = new List <string>(); }
public static void Run() { // Set up a navigator which looks at sites/pipes/Nozzles/Tee only TypeFilter filt = new TypeFilter(); filt.Add(DbElementTypeInstance.SITE); filt.Add(DbElementTypeInstance.PIPE); filt.Add(DbElementTypeInstance.NOZZLE); filt.Add(DbElementTypeInstance.TEE); CompoundFilter filt2 = new CompoundFilter(); filt2.AddShow(filt); ElementTreeNavigator navi = new ElementTreeNavigator(DbElement.GetElement("/*"), filt2); // Test FirstMember DbElement site = navi.FirstMemberInScan(Example.Instance.mWorld); DbElement nozz = navi.FirstMemberInScan(Example.Instance.mZone); nozz = navi.FirstMemberInScan(Example.Instance.mEqui); DbElement ele = navi.FirstMemberInScan(nozz); // Next DbElement zone = site.FirstMember(); DbElement next = navi.NextInScan(zone); // parent DbElement parent = navi.Parent(Example.Instance.mEqui); parent = navi.Parent(nozz); parent = navi.Parent(parent); //All Members DbElement[] tees = navi.MembersInScan(Example.Instance.mPipe); }
public static DbElement GetWritable(DbElement equi) { var cataName = equi.Owner.Owner.Name() + "-CATA"; DbElement cata = MDB.CurrentMDB.FindElement(DbType.Catalog, cataName); Db db = default(Db); if (!cata.IsValid) { Db[] dbs = MDB.CurrentMDB.GetDBArray(); //find cata dbs with dbwrite eq true db = dbs.FirstOrDefault(d => d.Type == DbType.Catalog && !d.IsReadOnly); Console.WriteLine($"can write to:{ db.Number} - { db.IsReadOnly}- { db.Type}"); cata = db.World.Create(1, DbElementTypeInstance.CATALOGUE); cata.SetAttribute(DbAttributeInstance.NAME, cataName); } else { db = cata.Db; } return(cata); }
public static void Run() { //add database changes event handler DatabaseService.Changes += new DbChangesEventHandler(DatabaseService_Changes); // // Element Creation, Deletion, Re-order, Include, Copy // DbElement nozz1 = Example.Instance.mEqui.CreateFirst(DbElementTypeInstance.NOZZLE); Pdms.Utilities.CommandLine.Command.Update(); DbElement nozz2 = Example.Instance.mEqui.CreateLast(DbElementTypeInstance.NOZZLE); Pdms.Utilities.CommandLine.Command.Update(); nozz1.Copy(Example.Instance.mNozz1); // Copy element nozz1.SetAttribute(DbAttributeInstance.DESC, "nozzle"); // Change only one part Pdms.Utilities.CommandLine.Command.Update(); // Make sure these changes are ignored nozz1.Copy(Example.Instance.mNozz1); // Re-Copy element - should indicate only the description part has changed Pdms.Utilities.CommandLine.Command.Update(); nozz1.InsertAfterLast(Example.Instance.mEqui); Pdms.Utilities.CommandLine.Command.Update(); nozz1.Delete(); Pdms.Utilities.CommandLine.Command.Update(); }
private DbElement SDTE(DbElement cate, string detailText, string skey, DbElement equipment) { var equiDesc = equipment.GetAsString(DbAttributeInstance.DESC); DbElement sdte = DbElement.GetElement(); if (equiDesc == "unset") { sdte = cate.Members().FirstOrDefault(m => m.ElementType == DbElementTypeInstance.SDTEXT); if (sdte == null || sdte.IsValid == false) { sdte = cate.CreateLast(DbElementTypeInstance.SDTEXT); } } else { var sdteName = equipment.Name() + ".SDTE"; sdte = cate.Members().FirstOrDefault(m => m.ElementType == DbElementTypeInstance.SDTEXT && m.Name() == sdteName); if (sdte == null || sdte.IsValid == false) { sdte = cate.CreateLast(DbElementTypeInstance.SDTEXT); try { sdte.SetAttribute(DbAttributeInstance.NAME, sdteName); Console.WriteLine("name error for sdte"); } catch (Exception e) { Console.WriteLine(e.Message); } } } detailText = detailText.Replace("@SIZE", "' + STRING (PARA[1] ) + '"); detailText = detailText.Replace("@DESC", equiDesc); PMLCommander.RunPMLCommand(sdte, "SKEY", $"'{skey}'", out var error); PMLCommander.RunPMLCommandInParentheses(sdte, "RTEXT", $"'{detailText}'", out error); Sdte = sdte; return(sdte); }
public Buildable Convert(DbElement element) { Size size = new Size(); Position position = new Position(); Direction direction = new Direction(); size.XLength = element.GetDouble(DbAttributeInstance.XLEN); size.YLength = element.GetDouble(DbAttributeInstance.YLEN); size.ZLength = element.GetDouble(DbAttributeInstance.ZLEN); var q = new DbQualifier(); q.Add(6); q.wrtQualifier = element.OwnerInHierarchyOfType(DbElementTypeInstance.EQUIPMENT); var pos = element.GetPosition(DbAttributeInstance.PPOS, q); position.X = pos.X; position.Y = pos.Y; position.Z = pos.Z; var orientation = element.GetOrientation(DbAttributeInstance.ORI, q); direction.X = orientation.XDir().ToString(); direction.Y = orientation.YDir().ToString(); direction.Z = orientation.ZDir().ToString(); return(new Buildable(DbElementTypeInstance.LPYRAMID, element, size, position, direction, element.ElementType)); }
private static AxisDir MakeDirection(int num, bool isNeg, DbElement modelEle) { DbElement cate = modelEle.GetElement(DbAttributeInstance.SPRE).GetElement(DbAttributeInstance.CATR); DbElement ptre = cate.GetElement(DbAttributeInstance.PTRE); DbElement pt = ptre.FirstMember(); while (pt != null && pt.IsValid) { if (num != pt.GetInteger(DbAttributeInstance.NUMB)) { pt = pt.Next(); continue; } DbElementType type = pt.GetElementType(); if (type == DbElementTypeInstance.PTAXIS) { return(MakeAxialDirection(num, isNeg, pt, modelEle)); } else if (type == DbElementTypeInstance.PTCAR) { return(MakeCartesianDirection(num, isNeg, pt, modelEle)); } else if (type == DbElementTypeInstance.PTMIX) { return(MakeMixedDirection(num, isNeg, pt, modelEle)); } else if (type == DbElementTypeInstance.PTPOS) { return(MakePositionTypeDirection(num, isNeg, pt, modelEle)); } pt = pt.Next(); } return(null); }
public void ExportPipingItem(DbElement cur, ref List <IIfcProduct> elements) { new PipingItem(cur, string.Empty, this._mapping).ExportComponents(ref elements); string asString = cur.GetAsString((DbAttribute)DbAttributeInstance.NAME); HierarchyItem.Log.Info((object)("PIPE Exported: " + asString)); }
public static string Purpose(this DbElement element) { var value = string.Empty; element.GetValidAsString(DbAttributeInstance.PURP, ref value); return(value); }
private List <DbElement> CollectStructuralItems() { List <DbElement> dbElementList = new List <DbElement>(); DbElement element = CurrentElement.get_Element(); DbElementType[] dbElementTypeArray = new DbElementType[7] { (DbElementType)DbElementTypeInstance.SCTN, (DbElementType)DbElementTypeInstance.PANEL, (DbElementType)DbElementTypeInstance.GENSEC, (DbElementType)DbElementTypeInstance.FLOOR, (DbElementType)DbElementTypeInstance.GWALL, (DbElementType)DbElementTypeInstance.STWALL, (DbElementType)DbElementTypeInstance.WALL }; DBElementCollection elementCollection = new DBElementCollection(element); elementCollection.set_IncludeRoot(true); elementCollection.set_Filter((BaseFilter) new TypeFilter(dbElementTypeArray)); DBElementEnumerator enumerator = (DBElementEnumerator)elementCollection.GetEnumerator(); while (enumerator.MoveNext()) { dbElementList.Add((DbElement)enumerator.get_Current()); } return(dbElementList); }
private static AxisDir MakeDirection(int num, bool isNeg, DbElement modelEle) { DbElement cate = modelEle.GetElement(DbAttributeInstance.SPRE).GetElement(DbAttributeInstance.CATR); DbElement ptre = cate.GetElement(DbAttributeInstance.PTRE); DbElement pt = ptre.FirstMember(); while (pt != null && pt.IsValid) { if (num != pt.GetInteger(DbAttributeInstance.NUMB)) { pt = pt.Next(); continue; } DbElementType type = pt.GetElementType(); if (type == DbElementTypeInstance.PTAXIS) return MakeAxialDirection(num, isNeg, pt, modelEle); else if (type == DbElementTypeInstance.PTCAR) return MakeCartesianDirection(num, isNeg, pt, modelEle); else if (type == DbElementTypeInstance.PTMIX) return MakeMixedDirection(num, isNeg, pt, modelEle); else if (type == DbElementTypeInstance.PTPOS) return MakePositionTypeDirection(num, isNeg, pt, modelEle); pt = pt.Next(); } return null; }
private void ComBox_ATTA_SelectedIndexChanged(object sender, EventArgs e) { TxtPipe.Text = ""; ComboBox comb = sender as ComboBox; NameRef nr = (NameRef)comb.SelectedItem; DbElement dbElement = DbElement.GetElement(nr.Ref); DbElement Pipe = dbElement.Owner.Owner; DrawList dl = DrawListManager.Instance.CurrentDrawList; TxtPipe.Text = Pipe.ToString(); DbElement hanger = dbElement.GetElement(DbAttributeInstance.CREF); dl.Add(Pipe); dl.Add(hanger); //dl.AddToSelection(); // DbElement Support = hanger.Owner.GetElement(DbAttributeInstance.STLR); ListBox_Element.Items.Clear(); foreach (DbElement h in hanger.Members()) { ListBox_Element.Items.Add(new NameRef(h.ToString(), h.RefNo())); } //foreach (DbElement s in Support.Owner.Members()) //{ // ListBox_Element.Items.Add(new NameRef(s.ToString(), s.RefNo())); //} ListBox_Element.DisplayMember = "Name"; }
public static AxisDir Eval(DbElement modelEle, string exper) { exper = exper.Trim().ToUpper(); if (exper.IndexOfAny(flags) >= 0) { return new AxisDir(Position.Create(), ParseExperDir(exper, modelEle)); } else if (exper.Contains('P')) { bool isNeg = false; if (exper[0] == '-') { isNeg = true; exper = exper.Substring(1).Trim(); } exper = exper.Substring(exper[1] == 'P' ? 2 : 1); int num = int.Parse(exper); AxisDir ad = null; ad = MakeDirection(num, isNeg, modelEle); if (ad == null || (ad.Dir.East + ad.Dir.North + ad.Dir.Up) < 0.000001) ad = null; return ad; } else { return new AxisDir(Position.Create(), Direction.Create(exper)); } }
public static void Run() { //Add delegates DbPostElementChange.AddPostCreateElement(DbElementTypeInstance.PIPE, new DbPostElementChange.PostCreateDelegate(PostCreateSubscriber)); DbPostElementChange.AddPreDeleteElement(DbElementTypeInstance.PIPE, new DbPostElementChange.PreDeleteDelegate(PreDeleteSubscriber)); DbPostElementChange.AddPostMoveElement(DbElementTypeInstance.PIPE, new DbPostElementChange.PostMoveDelegate(PostMoveSubscriber)); DbPostElementChange.AddPostAttributeChange(DbAttributeInstance.AREA, new DbPostElementChange.PostAttributeChangeDelegate(PostSetAttSubscriber)); DbPostElementChange.AddPostAttributeChange(DbAttributeInstance.NAME, new DbPostElementChange.PostAttributeChangeDelegate(PostSetAttSubscriber)); DbPostElementChange.AddPostRefAttributeChange(DbAttributeInstance.CREF, new DbPostElementChange.PostRefAttributeChangeDelegate(PostSetRefAttSubscriber)); //Post create DbElement newele = Example.Instance.mZone.Create(1, DbElementTypeInstance.PIPE); //Pre Delete newele.Delete(); //Post move Example.Instance.mPipe.InsertAfter(Example.Instance.mEqui); //Post set attribute int area = Example.Instance.mEqui.GetInteger(DbAttributeInstance.AREA) + 1; Example.Instance.mEqui.SetAttribute(DbAttributeInstance.AREA, area); //Post set ref attribute Example.Instance.mNozz1.SetAttribute(DbAttributeInstance.CREF, Example.Instance.mBran); }
public Buildable Convert(DbElement element) { Size size = new Size(); Position position = new Position(); Direction direction = new Direction(); size.TopDiameter = element.GetDouble(DbAttributeInstance.DTOP); size.BotDiameter = element.GetDouble(DbAttributeInstance.DBOT); size.Height = element.GetDouble(DbAttributeInstance.HEIG); var q = new DbQualifier(); q.Add(1); q.wrtQualifier = element.OwnerInHierarchyOfType(DbElementTypeInstance.EQUIPMENT); var pos = element.GetPosition(DbAttributeInstance.PPOS, q); position.X = pos.X; position.Y = pos.Y; position.Z = pos.Z; var orientation = element.GetOrientation(DbAttributeInstance.ORI, q); direction.X = orientation.XDir().ToString(); direction.Y = orientation.YDir().ToString(); direction.Z = orientation.ZDir().ToString(); return(new Buildable(DbElementTypeInstance.LSNOUT, element, size, position, direction, element.ElementType)); }
public Dictionary <IFCObjectsReader.Data.IfcObject, DbElement> GetConnectedIfcList( DbElement root, out List <string> duplicates) { duplicates = new List <string>(); this._connectedIfcList = new Dictionary <IFCObjectsReader.Data.IfcObject, DbElement>(); TypeFilter typeFilter = new TypeFilter(new DbElementType[3] { (DbElementType)DbElementTypeInstance.SCTN, (DbElementType)DbElementTypeInstance.PANEL, (DbElementType)DbElementTypeInstance.GENSEC }); foreach (IFCObjectsReader.Data.IfcObject key in this._mapping.IfcObjectslist) { DbElement dbElement = (DbElement)null; AndFilter filter = new AndFilter((BaseFilter)typeFilter, (BaseFilter) new TeklaIfcGuidFilter(key.SourceGuid)); List <DbElement> elements = this.GetElements(root, filter); int count = elements.Count; if (!count.Equals(0)) { count = elements.Count; if (count.Equals(1)) { dbElement = elements[0]; } else { duplicates.Add("Duplicates found: " + elements[0].GetAsString((DbAttribute)DbAttributeInstance.REF)); } } this._connectedIfcList.Add(key, dbElement); } return(this._connectedIfcList); }
public Buildable ElementToBuildable(DbElement element) { if (_converters.ContainsKey(element.ElementType)) { return(_converters[element.ElementType].Convert(element)); } return(null); }
public DbElement MatxtElement(DbElement equipment) { var possbileMatxts = new DBElementCollection(equipment.Owner, new AndFilter(new TypeFilter(DbElementTypeInstance.TEXT), new AttributeStringFilter(DbAttributeInstance.PURP, FilterOperator.Equals, "MTXT"))); return(possbileMatxts.First()); }
private void ListBox_Element_SelectedIndexChanged(object sender, EventArgs e) { ListBox lb = sender as ListBox; NameRef nr = (NameRef)lb.SelectedItem; DbElement dbElement = DbElement.GetElement(nr.Ref); CurrentElement.Element = dbElement; }
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"); }
// Double delegate for UDA private static double VolumeCalculation(DbElement ele, DbAttribute att, DbQualifier qualifier) { // Uda calculates the volume by multiplying the lengths along each side double x = ele.GetDouble(ATT.XLEN); double y = ele.GetDouble(ATT.YLEN); double z = ele.GetDouble(ATT.ZLEN); // Result of UDA must be returned return (x * y * z); }
public Buildable(DbElementType buildAs, DbElement element, Size size, Position position, Direction direction, List <Position> vertices) { BuildAs = buildAs; _element = element; Size = size; Position = position; Direction = direction; Verticies = vertices; }
public Buildable(DbElementType buildAs, DbElement element, Size size, Position position, Direction direction, DbElementType sourceType) { BuildAs = buildAs; _element = element; Size = size; Position = position; Direction = direction; SourceType = sourceType; }
public Buildable(DbElementType buildAs, DbElement element, Size size, Position position, Direction direction, ConvertToBuildable.NozzleConfig nozzleConfig) { _element = element; Size = size; Position = position; Direction = direction; NozzleConfig = nozzleConfig; BuildAs = buildAs; }
private static AxisDir MakeAxialDirection(int num, bool isNeg, DbElement pnt, DbElement modelEle) { Direction dir = ParseExperDir(pnt.GetAsString(DbAttributeInstance.PAXI), modelEle); double offset = EvalDouble(pnt.GetAsString(DbAttributeInstance.PDIS), modelEle); Position pos = Position.Create(); pos.MoveBy(dir, offset); if (isNeg) dir = dir.Opposite(); return new AxisDir(pos, dir); }
private int GetColor(DbElement ele, int parentColor) { DbElementType eleType = ele.GetElementType(); if (eleType == DbElementTypeInstance.BRANCH) return System.Drawing.Color.Gold.ToArgb(); else if (eleType == DbElementTypeInstance.EQUIPMENT) return System.Drawing.Color.Tan.ToArgb(); else return parentColor; }
public static bool MemberWithAttributeValue(this DbElement element, DbAttribute attribute, string value) { DbElement y = element.Members().SingleOrDefault(x => x.GetAsString(attribute) == value); if (y != null && y.IsValid) { return(true); } return(false); }
public IEnumerable <DbElement> GetEquipmentsInZone(DbElement zone) { TypeFilter equipment = new TypeFilter(DbElementTypeInstance.EQUIPMENT); DBElementCollection elements = new DBElementCollection(zone, equipment); foreach (DbElement element in elements) { yield return(element); } }
// Double delegate for UDA static private double VolumeCalculation(DbElement ele, DbAttribute att, DbQualifier qualifier) { // Uda calculates the volume by multiplying the lengths along each side double x = ele.GetDouble(ATT.XLEN); double y = ele.GetDouble(ATT.YLEN); double z = ele.GetDouble(ATT.ZLEN); // Result of UDA must be returned return(x * y * z); }
public Buildable(DbElementType buildAs, DbElement element, Size size, Position position, Direction direction, Position p2, Direction d2) { BuildAs = buildAs; _element = element; Size = size; Position = position; Direction = direction; Position2 = p2; Direction2 = d2; }
private bool IsSupportedDesignGeometryEle(DbElement ele) { DbElementType type = ele.GetElementType(); return(type == DbElementTypeInstance.CYLINDER || type == DbElementTypeInstance.BOX || type == DbElementTypeInstance.DISH || type == DbElementTypeInstance.CONE || type == DbElementTypeInstance.PYRAMID ); }
private int GetColor(DbElement ele) { List<DbElement> eleArr = new List<DbElement>(); do { eleArr.Add(ele); } while (IsReadableEle(ele = ele.Owner)); int color = System.Drawing.Color.White.ToArgb(); for (int i = eleArr.Count-1; i >= 0; --i) { color = GetColor(eleArr[i], color); } return color; }
private void ExportSite(DbElement siteEle, int color) { int curCol = GetColor(siteEle, color); D3Transform transform = GetTransform(siteEle); DbElement ele = siteEle.FirstMember(); while (ele != null && ele.IsValid) { if (IsReadableEle(ele) && ele.GetElementType() == DbElementTypeInstance.ZONE) ExportZone(ele, transform, curCol); ele = ele.Next(); } }
private void ExportWorld(DbElement worldEle) { int color = GetColor(worldEle, System.Drawing.Color.White.ToArgb()); DbElement ele = worldEle.FirstMember(); while (ele != null && ele.IsValid) { if (IsReadableEle(ele) && ele.GetElementType() == DbElementTypeInstance.SITE) ExportSite(ele, color); ele = ele.Next(); } }
private void ExportPipe(DbElement pipeEle, D3Transform transform, int color) { int curCol = GetColor(pipeEle, color); DbElement ele = pipeEle.FirstMember(); while (ele != null && ele.IsValid) { if (IsReadableEle(ele) && ele.GetElementType() == DbElementTypeInstance.BRANCH) ExportBranch(ele, transform, curCol); ele = ele.Next(); } }
private void ExportZone(DbElement zoneEle, D3Transform transform, int color) { int curCol = GetColor(zoneEle, color); D3Transform currentTransform = transform.Multiply(GetTransform(zoneEle)); DbElement ele = zoneEle.FirstMember(); while (ele != null && ele.IsValid) { if (IsReadableEle(ele)) { if (ele.GetElementType() == DbElementTypeInstance.PIPE) ExportPipe(ele, currentTransform, curCol); else if (ele.GetElementType() == DbElementTypeInstance.EQUIPMENT) ExportEquip(ele, currentTransform, curCol); } ele = ele.Next(); } }
private static void PostSetRefAttSubscriber(DbElement ele, DbAttribute att, DbElement oldref) { Console.WriteLine("PostRefAtt"); }
private Experssion GetExper(DbElement gEle, DbAttribute attr) { Dictionary<string, Experssion> map = null; if (!experMap.TryGetValue(attr, out map)) { map = new Dictionary<string, Experssion>(); experMap.Add(attr, map); } Experssion exper = null; if (!map.TryGetValue(gEle.GetAsString(DbAttributeInstance.NAME), out exper)) { exper = new Experssion(gEle.GetAsString(attr)); map.Add(gEle.GetAsString(DbAttributeInstance.NAME), exper); } return exper; }
private void Export(DbElement ele) { if (ele.GetElementType() == DbElementTypeInstance.WORLD) ExportWorld(ele); else if (ele.GetElementType() == DbElementTypeInstance.SITE) ExportSite(ele, GetColor(ele.Owner)); else if (ele.GetElementType() == DbElementTypeInstance.ZONE) { D3Transform transform = GetTransform(ele.Owner); ExportZone(ele, transform, GetColor(ele.Owner)); } else if (ele.GetElementType() == DbElementTypeInstance.PIPE) { DbElement zoneEle = ele.Owner; DbElement siteEle = zoneEle.Owner; D3Transform transform = GetTransform(siteEle).Multiply(GetTransform(zoneEle)); ExportPipe(ele, transform, GetColor(ele.Owner)); } else if (ele.GetElementType() == DbElementTypeInstance.EQUIPMENT) { DbElement zoneEle = ele.Owner; DbElement siteEle = zoneEle.Owner; D3Transform transform = GetTransform(siteEle).Multiply(GetTransform(zoneEle)); ExportEquip(ele, transform, GetColor(ele.Owner)); } else if (ele.GetElementType() == DbElementTypeInstance.BRANCH) { DbElement pipeEle = ele.Owner; DbElement zoneEle = pipeEle.Owner; DbElement siteEle = zoneEle.Owner; D3Transform transform = GetTransform(siteEle).Multiply(GetTransform(zoneEle)); ExportBranch(ele, transform, GetColor(ele.Owner)); } SaveExpr(); }
private static double EvalDouble(string strExper, DbElement modelEle) { Experssion exper = new Experssion(strExper); return exper.Eval(modelEle); }
private static void PostCreateSubscriber(DbElement ele) { Console.WriteLine("PostCreate"); }
private void ExportEquip(DbElement equipEle, D3Transform transform, int parentColor) { int color = GetColor(equipEle, parentColor); D3Transform currTrans = transform.Multiply(GetTransform(equipEle)); DbElement ele = equipEle.FirstMember(); while (ele != null && ele.IsValid) { if (IsReadableEle(ele)) { if (!IsVisible(ele)) { ele = ele.Next(); continue; } DbElementType eleType = ele.GetElementType(); if (eleType == DbElementTypeInstance.NOZZLE) ExportPipeItem(ele, currTrans, parentColor); else if (eleType == DbElementTypeInstance.TMPLATE) { DbElement[] lcnfArray = null; if (ele.IsAttributeValid(DbAttributeInstance.LCNFA)) { lcnfArray = ele.GetElementArray(DbAttributeInstance.LCNFA); } if (lcnfArray == null || lcnfArray.Length <= 0) { DbElement tmplEle = ele.FirstMember(); while (tmplEle != null && tmplEle.IsValid) { if (IsReadableEle(tmplEle) && IsVisible(tmplEle)) ExportDesignGeomotry(tmplEle, currTrans, color); tmplEle = tmplEle.Next(); } } else { foreach (DbElement lcnfEle in lcnfArray) { if (IsReadableEle(lcnfEle) && IsVisible(lcnfEle)) ExportDesignGeomotry(lcnfEle, currTrans, color); } } } else if (eleType == DbElementTypeInstance.SUBEQUIPMENT) { ExportEquip(ele, currTrans, color); } else ExportDesignGeomotry(ele, currTrans, color); } ele = ele.Next(); } }
private void ExportPipeItem(DbElement ele, D3Transform transform, int color) { if (ele.GetElementType() == DbElementTypeInstance.TUBING) { ExportTube(ele, transform, color); return; } DbElement specEle = null; if ((specEle = ele.GetElement(DbAttributeInstance.SPRE)) == null || !IsReadableEle(specEle) || ele.GetElementType() == DbElementTypeInstance.ATTACHMENT ) { return; ; } DbElement cateEle = null; if ((cateEle = specEle.GetElement(DbAttributeInstance.CATR)) == null || !IsReadableEle(cateEle)) { return; } DbElement gmEle = null; if ((gmEle = cateEle.GetElement(DbAttributeInstance.GMRE)) == null || !IsReadableEle(gmEle)) { return; } D3Transform eleTrans = transform.Multiply(GetTransform(ele)); DbElement gEle = gmEle.FirstMember(); while (gEle != null && gEle.IsValid) { if (IsReadableEle(gEle) && gEle.GetBool(DbAttributeInstance.TUFL)) { if (!IsVisible(gEle)) { gEle = gEle.Next(); continue; } try { if (gEle.GetElementType() == DbElementTypeInstance.SCYLINDER) { string expr = gEle.GetAsString(DbAttributeInstance.PAXI); AxisDir paxi = EvalDirection.Eval(ele, expr); double phei = GetExper(gEle, DbAttributeInstance.PHEI).Eval(ele); double pdia = GetExper(gEle, DbAttributeInstance.PDIA).Eval(ele); double pdis = GetExper(gEle, DbAttributeInstance.PDIS).Eval(ele); D3Vector dir = eleTrans.Multiply(GeometryUtility.ToD3VectorRef(paxi.Dir)); D3Point pos = eleTrans.Multiply(GeometryUtility.ToD3Point(paxi.Pos)); Cylinder cyl = new Cylinder(); cyl.Org = new Point(pos) .MoveBy(dir, pdis); cyl.Height = new Point(dir).Mul(phei); cyl.Radius = pdia / 2.0; cyl.Color = color; session.Save(cyl); } else if (gEle.GetElementType() == DbElementTypeInstance.LCYLINDER) { string expr = gEle.GetAsString(DbAttributeInstance.PAXI); AxisDir paxi = EvalDirection.Eval(ele, expr); double pdia = GetExper(gEle, DbAttributeInstance.PDIA).Eval(ele); double pbdi = GetExper(gEle, DbAttributeInstance.PBDI).Eval(ele); double ptdi = GetExper(gEle, DbAttributeInstance.PTDI).Eval(ele); D3Vector dir = eleTrans.Multiply(GeometryUtility.ToD3VectorRef(paxi.Dir)); D3Point pos = eleTrans.Multiply(GeometryUtility.ToD3Point(paxi.Pos)); Cylinder cyl = new Cylinder(); cyl.Org = new Point(pos) .MoveBy(dir, pbdi); cyl.Height = new Point(dir).Mul(ptdi - pbdi); cyl.Radius = pdia / 2.0; cyl.Color = color; session.Save(cyl); } else if (gEle.GetElementType() == DbElementTypeInstance.SBOX) { double pxlen = GetExper(gEle, DbAttributeInstance.PXLE).Eval(ele); double pylen = GetExper(gEle, DbAttributeInstance.PYLE).Eval(ele); double pzlen = GetExper(gEle, DbAttributeInstance.PZLE).Eval(ele); double px = GetExper(gEle, DbAttributeInstance.PX).Eval(ele); double py = GetExper(gEle, DbAttributeInstance.PY).Eval(ele); double pz = GetExper(gEle, DbAttributeInstance.PZ).Eval(ele); Point xlen = new Point(eleTrans.Multiply(D3Vector.D3EAST)); Point ylen = new Point(eleTrans.Multiply(D3Vector.D3NORTH)); Point zlen = new Point(eleTrans.Multiply(D3Vector.D3UP)); Point pos = new Point(eleTrans.Multiply(GeometryUtility.Org)); pos.MoveBy(xlen, px - pxlen / 2.0).MoveBy(ylen, py - pylen / 2.0).MoveBy(zlen, pz - pzlen / 2.0); xlen.Mul(pxlen); ylen.Mul(pylen); zlen.Mul(pzlen); Box box = new Box(); box.Org = pos; box.XLen = xlen; box.YLen = ylen; box.ZLen = zlen; box.Color = color; session.Save(box); } else if (gEle.GetElementType() == DbElementTypeInstance.SCTORUS) { string expr = gEle.GetAsString(DbAttributeInstance.PAAX); AxisDir paax = EvalDirection.Eval(ele, expr); expr = gEle.GetAsString(DbAttributeInstance.PBAX); AxisDir pbax = EvalDirection.Eval(ele, expr); double pdia = GetExper(gEle, DbAttributeInstance.PDIA).Eval(ele); CircularTorus ct = new CircularTorus(); Direction normal = null; if (!paax.Dir.IsParallel(pbax.Dir)) normal = paax.Dir.Orthogonal(pbax.Dir); else normal = paax.Dir.Orthogonal(Direction.Create(paax.Pos, pbax.Pos)); ct.Normal = new Point(eleTrans.Multiply(GeometryUtility.ToD3VectorRef(normal))); ct.StartPnt = new Point(eleTrans.Multiply(GeometryUtility.ToD3Point(pbax.Pos))); ct.StartRadius = ct.EndRadius = pdia / 2.0; double mRadius = 0.0; if (!paax.Dir.IsParallel(pbax.Dir)) { double ang = paax.Dir.Angle(pbax.Dir) * Math.PI / 180.0; ct.Angle = Math.PI - ang; ang /= 2.0; double len = paax.Pos.Distance(pbax.Pos) / 2; mRadius = len / Math.Sin(ang) * Math.Tan(ang); } else { ct.Angle = Math.PI; mRadius = paax.Pos.Distance(pbax.Pos) / 2.0; } D3Vector radiusDir = eleTrans.Multiply(GeometryUtility.ToD3VectorRef(pbax.Dir.Orthogonal(normal))); ct.Center = new Point(ct.StartPnt).MoveBy(radiusDir, mRadius); ct.Color = color; session.Save(ct); } else if (gEle.GetElementType() == DbElementTypeInstance.SRTORUS) { string expr = gEle.GetAsString(DbAttributeInstance.PAAX); AxisDir paax = EvalDirection.Eval(ele, expr); expr = gEle.GetAsString(DbAttributeInstance.PBAX); AxisDir pbax = EvalDirection.Eval(ele, expr); double pdia = GetExper(gEle, DbAttributeInstance.PDIA).Eval(ele); double phei = GetExper(gEle, DbAttributeInstance.PHEI).Eval(ele); RectangularTorus rt = new RectangularTorus(); Direction normal = null; if (!paax.Dir.IsParallel(pbax.Dir)) normal = paax.Dir.Orthogonal(pbax.Dir); else normal = paax.Dir.Orthogonal(Direction.Create(paax.Pos, pbax.Pos)); rt.Normal = new Point(eleTrans.Multiply(GeometryUtility.ToD3VectorRef(normal))); rt.StartPnt = new Point(eleTrans.Multiply(GeometryUtility.ToD3Point(pbax.Pos))); rt.StartWidth = rt.EndWidth = pdia; rt.StartHeight = rt.EndHeight = phei; double mRadius = 0.0; if (!paax.Dir.IsParallel(pbax.Dir)) { double ang = paax.Dir.Angle(pbax.Dir) * Math.PI / 180.0; rt.Angle = Math.PI - ang; ang /= 2.0; double len = paax.Pos.Distance(pbax.Pos) / 2; mRadius = len / Math.Sin(ang) * Math.Tan(ang); } else { rt.Angle = Math.PI; mRadius = paax.Pos.Distance(pbax.Pos) / 2.0; } D3Vector radiusDir = eleTrans.Multiply(GeometryUtility.ToD3VectorRef(pbax.Dir.Orthogonal(normal))); rt.Center = new Point(rt.StartPnt).MoveBy(radiusDir, mRadius); rt.Color = color; session.Save(rt); } else if (gEle.GetElementType() == DbElementTypeInstance.LSNOUT) { string expr = gEle.GetAsString(DbAttributeInstance.PAAX); AxisDir paax = EvalDirection.Eval(ele, expr); expr = gEle.GetAsString(DbAttributeInstance.PBAX); AxisDir pbax = EvalDirection.Eval(ele, expr); double ptdi = GetExper(gEle, DbAttributeInstance.PTDI).Eval(ele); double pbdi = GetExper(gEle, DbAttributeInstance.PBDI).Eval(ele); double ptdm = GetExper(gEle, DbAttributeInstance.PTDM).Eval(ele); double pbdm = GetExper(gEle, DbAttributeInstance.PBDM).Eval(ele); double poff = GetExper(gEle, DbAttributeInstance.POFF).Eval(ele); D3Vector tdir = eleTrans.Multiply(GeometryUtility.ToD3VectorRef(paax.Dir)); D3Point pos = eleTrans.Multiply(GeometryUtility.ToD3Point(paax.Pos)); D3Vector bdir = eleTrans.Multiply(GeometryUtility.ToD3VectorRef(pbax.Dir)); if (pbdm < 1.0e-5 || ptdm < 1.0e-5) { Cone cone = new Cone(); cone.Radius = pbdm > ptdm ? pbdm / 2.0 : ptdm / 2.0; cone.Org = new Point(pos).MoveBy(tdir, pbdi); cone.Offset = new Point(bdir).Mul(poff); cone.Height = new Point(tdir).Mul(ptdi - pbdi); cone.Color = color; session.Save(cone); } else { Snout snout = new Snout(); snout.BottomRadius = pbdm / 2.0; snout.TopRadius = ptdm / 2.0; snout.Org = new Point(pos).MoveBy(tdir, pbdi); snout.Offset = new Point(bdir).Mul(poff); snout.Height = new Point(tdir).Mul(ptdi - pbdi); snout.Color = color; session.Save(snout); } } else if (gEle.GetElementType() == DbElementTypeInstance.SDSH) { string expr = gEle.GetAsString(DbAttributeInstance.PAXI); AxisDir paxi = EvalDirection.Eval(ele, expr); double phei = GetExper(gEle, DbAttributeInstance.PHEI).Eval(ele); double pdia = GetExper(gEle, DbAttributeInstance.PDIA).Eval(ele); double pdis = GetExper(gEle, DbAttributeInstance.PDIS).Eval(ele); double prad = GetExper(gEle, DbAttributeInstance.PRAD).Eval(ele); D3Vector dir = eleTrans.Multiply(GeometryUtility.ToD3VectorRef(paxi.Dir)); if (prad > 0.0) { Ellipsoid ellipsoid = new Ellipsoid(); ellipsoid.Center = new Point(eleTrans.Multiply(GeometryUtility.ToD3Point(paxi.Pos))) .MoveBy(dir, pdis); ellipsoid.ALen = new Point(dir).Mul(phei); ellipsoid.BRadius = pdia / 2.0; ellipsoid.Color = color; session.Save(ellipsoid); } else { Sphere sphere = new Sphere(); sphere.Center = new Point(eleTrans.Multiply(GeometryUtility.ToD3Point(paxi.Pos))) .MoveBy(dir, pdis); double bottomRadius = pdia / 2.0; sphere.Radius = (bottomRadius * bottomRadius + phei * phei) / 2.0 / phei; sphere.BottomNormal = new Point(-dir); double angle = Math.PI / 2.0 - Math.Asin(2.0 * bottomRadius * phei / (bottomRadius * bottomRadius + phei * phei)); if (bottomRadius >= phei) sphere.Angle = Math.PI - angle * 2.0; else sphere.Angle = Math.PI + angle * 2.0; sphere.Color = color; session.Save(sphere); } } else if (gEle.GetElementType() == DbElementTypeInstance.LPYRAMID) { string exper = gEle.GetAsString(DbAttributeInstance.PAAX); AxisDir paax = EvalDirection.Eval(ele, exper); exper = gEle.GetAsString(DbAttributeInstance.PBAX); AxisDir pbax = EvalDirection.Eval(ele, exper); exper = gEle.GetAsString(DbAttributeInstance.PCAX); AxisDir pcax = EvalDirection.Eval(ele, exper); double pbtp = GetExper(gEle, DbAttributeInstance.PBTP).Eval(ele); double pctp = GetExper(gEle, DbAttributeInstance.PCTP).Eval(ele); double pbbt = GetExper(gEle, DbAttributeInstance.PBBT).Eval(ele); double pcbt = GetExper(gEle, DbAttributeInstance.PCBT).Eval(ele); double pbof = GetExper(gEle, DbAttributeInstance.PBOF).Eval(ele); double pcof = GetExper(gEle, DbAttributeInstance.PCOF).Eval(ele); double ptdi = GetExper(gEle, DbAttributeInstance.PTDI).Eval(ele); double pbdi = GetExper(gEle, DbAttributeInstance.PBDI).Eval(ele); D3Vector zDir = eleTrans.Multiply(GeometryUtility.ToD3VectorRef(paax.Dir)); D3Vector xDir = eleTrans.Multiply(GeometryUtility.ToD3VectorRef(pbax.Dir)); D3Vector yDir = eleTrans.Multiply(GeometryUtility.ToD3VectorRef(pcax.Dir)); D3Point org = eleTrans.Multiply(GeometryUtility.ToD3Point(paax.Pos)); org.MoveBy(zDir * pbdi); double height = ptdi - pbdi; Pyramid pyramid = new Pyramid(); pyramid.Org = new Point(org); pyramid.Height = new Point(zDir).Mul(height); pyramid.XAxis = new Point(xDir); pyramid.BottomXLen = pbbt; pyramid.BottomYLen = pcbt; pyramid.TopXLen = pbtp; pyramid.TopYLen = pctp; pyramid.Offset = new Point(xDir * pbof + yDir * pcof); pyramid.Color = color; session.Save(pyramid); } } catch (System.NullReferenceException ) { } catch (System.Exception) { System.Console.WriteLine("Ele = " + ele.GetAsString(DbAttributeInstance.NAME)); System.Console.WriteLine("GEle = " + gEle.GetAsString(DbAttributeInstance.NAME)); throw; } } gEle = gEle.Next(); } }
private bool IsVisible(DbElement ele) { if (ele.IsAttributeValid(DbAttributeInstance.LEVE)) { int[] level = ele.GetIntegerArray(DbAttributeInstance.LEVE); if (level.Length >= 2 && level[1] < 6) { return false; } } return true; }
private static void PreDeleteSubscriber(DbElement ele) { Console.WriteLine("PreDelete"); }
private bool IsReadableEle(DbElement ele) { return ele.IsValid && !ele.IsNull && !ele.IsDeleted; }
private D3Transform GetTransform(DbElement ele) { return GeometryUtility.ToD3Transform(ele.GetOrientation(DbAttributeInstance.ORI), ele.GetPosition(DbAttributeInstance.POS)); }
private static AxisDir MakeMixedDirection(int num, bool isNeg, DbElement pnt, DbElement modelEle) { Direction dir = ParseExperDir(pnt.GetAsString(DbAttributeInstance.PAXI), modelEle); double x = EvalDouble(pnt.GetAsString(DbAttributeInstance.PX), modelEle); double y = EvalDouble(pnt.GetAsString(DbAttributeInstance.PY), modelEle); double z = EvalDouble(pnt.GetAsString(DbAttributeInstance.PZ), modelEle); if (isNeg) dir = dir.Opposite(); return new AxisDir(Position.Create(x, y, z), dir); }
private void ExportTube(DbElement tubeEle, D3Transform transform, int color) { double ltLength = tubeEle.GetDouble(DbAttributeInstance.ITLE); if (ltLength <= 0.001) return; double lbore = tubeEle.GetDoubleArray(DbAttributeInstance.PARA)[1]; D3Vector dir = null; DbElement prevEle = tubeEle.Previous; if (prevEle == null || !prevEle.IsValid) { DbElement branchEle = tubeEle.Owner; dir = transform.Multiply(GeometryUtility.ToD3VectorRef(branchEle.GetDirection(DbAttributeInstance.HDIR))); } else { int leave = prevEle.GetInteger(DbAttributeInstance.LEAV); AxisDir ptax = EvalDirection.Eval(prevEle, "P" + leave); if (ptax == null) return; D3Transform eleTrans = transform.Multiply(GetTransform(prevEle)); dir = eleTrans.Multiply(GeometryUtility.ToD3VectorRef(ptax.Dir)); } D3Point pos = transform.Multiply(GeometryUtility.ToD3Point(tubeEle.GetPosition(DbAttributeInstance.ITPS))); pos.MoveBy(dir * (-ltLength / 2)); Cylinder cyl = new Cylinder(); cyl.Org = new Point(pos); cyl.Height = new Point(dir).Mul(ltLength); cyl.Radius = lbore / 2.0; cyl.Color = color; session.Save(cyl); }
private static Direction ParseExperDir(string exper, DbElement modelEle) { if (exper.IndexOfAny(flags) < 0 && exper.Contains("P")) { AxisDir dir = Eval(modelEle, exper); return dir.Dir; } StringBuilder sb = new StringBuilder(); int preIdx = 0, nextIdx; while ((nextIdx = exper.IndexOfAny(flags, preIdx)) >= 0) { string item = exper.Substring(preIdx, nextIdx - preIdx).Trim(); if (item.Length > 0) { if (item[item.Length-1] == '-') { item = item.Substring(0, item.Length-1).Trim(); if (item.Length > 0) sb.Append(EvalDouble(item, modelEle).ToString()); sb.Append('-'); } else sb.Append(EvalDouble(item, modelEle).ToString()); } sb.Append(exper[nextIdx]); preIdx = nextIdx + 1; } if (sb.Length <= 0) sb.Append(exper); return Direction.Create(sb.ToString()); }
private static void PostMoveSubscriber(DbElement ele, DbElement oldOwner, int oldpos) { Console.WriteLine("PostMove"); }
private static AxisDir MakePositionTypeDirection(int num, bool isNeg, DbElement pnt, DbElement modelEle) { Direction dir = ParseExperDir(pnt.GetAsString(DbAttributeInstance.PTCD), modelEle); AxisDir pos = Eval(modelEle, pnt.GetAsString(DbAttributeInstance.PTCPOS)); if (isNeg) dir = dir.Opposite(); return new AxisDir(pos.Pos, dir); }
private void ExportBranch(DbElement branchEle, D3Transform transform, int color) { int curCol = GetColor(branchEle, color); DbElement ele = branchEle.FirstMember(); while (ele != null && ele.IsValid) { if (IsReadableEle(ele)) ExportPipeItem(ele, transform, curCol); ele = ele.Next(); } }
private bool IsSupportedDesignGeometryEle(DbElement ele) { DbElementType type = ele.GetElementType(); return type == DbElementTypeInstance.CYLINDER || type == DbElementTypeInstance.BOX || type == DbElementTypeInstance.DISH || type == DbElementTypeInstance.CONE || type == DbElementTypeInstance.PYRAMID ; }
private void ExportDesignGeomotry(DbElement ele, D3Transform currTrans, int color) { if (ele.GetElementType() == DbElementTypeInstance.CYLINDER) { D3Transform eleTrans = currTrans.Multiply(GetTransform(ele)); Cylinder cyl = new Cylinder(); cyl.Height = new Point(eleTrans.Multiply(D3Vector.D3UP)) .Mul(ele.GetDouble(DbAttributeInstance.HEIG)); cyl.Org = new Point(eleTrans.Multiply(GeometryUtility.Org)).MoveBy(cyl.Height, -0.5); cyl.Radius = ele.GetDouble(DbAttributeInstance.DIAM) / 2.0; cyl.Color = color; session.Save(cyl); } else if (ele.GetElementType() == DbElementTypeInstance.BOX) { D3Transform eleTrans = currTrans.Multiply(GetTransform(ele)); double xlen = ele.GetDouble(DbAttributeInstance.XLEN); double ylen = ele.GetDouble(DbAttributeInstance.YLEN); double zlen = ele.GetDouble(DbAttributeInstance.ZLEN); Box box = new Box(); box.XLen = new Point(eleTrans.Multiply(D3Vector.D3EAST)).Mul(xlen); box.YLen = new Point(eleTrans.Multiply(D3Vector.D3NORTH)).Mul(ylen); box.ZLen = new Point(eleTrans.Multiply(D3Vector.D3UP)).Mul(zlen); box.Org = new Point(eleTrans.Multiply(GeometryUtility.Org)) .MoveBy(box.XLen, -0.5).MoveBy(box.YLen, -0.5).MoveBy(box.ZLen, -0.5); box.Color = color; session.Save(box); } else if (ele.GetElementType() == DbElementTypeInstance.DISH) { D3Transform eleTrans = currTrans.Multiply(GetTransform(ele)); D3Vector normal = eleTrans.Multiply(D3Vector.D3UP); double h = ele.GetDouble(DbAttributeInstance.HEIG); double bottomRadius = ele.GetDouble(DbAttributeInstance.DIAM) / 2.0; if (ele.GetDouble(DbAttributeInstance.RADI) > 0.0) { Ellipsoid ellipsoid = new Ellipsoid(); ellipsoid.Center = new Point(eleTrans.Multiply(GeometryUtility.Org)); ellipsoid.ALen = new Point(normal).Mul(ele.GetDouble(DbAttributeInstance.HEIG)); ellipsoid.BRadius = bottomRadius; ellipsoid.Color = color; session.Save(ellipsoid); } else { Sphere sphere = new Sphere(); sphere.Center = new Point(eleTrans.Multiply(GeometryUtility.Org)); sphere.BottomNormal = new Point(-normal); sphere.Radius = (bottomRadius * bottomRadius + h * h) / 2.0 / h; sphere.Angle = Math.PI / 2.0 - Math.Asin(2.0 * bottomRadius * h / (bottomRadius * bottomRadius + h * h)); if (bottomRadius >= h) sphere.Angle = Math.PI - sphere.Angle * 2.0; else sphere.Angle = Math.PI + sphere.Angle * 2.0; sphere.Color = color; session.Save(sphere); } } else if (ele.GetElementType() == DbElementTypeInstance.CONE) { D3Transform eleTrans = currTrans.Multiply(GetTransform(ele)); D3Point pos = eleTrans.Multiply(GeometryUtility.Org); D3Vector dir = eleTrans.Multiply(D3Vector.D3UP); double height = ele.GetDouble(DbAttributeInstance.HEIG); double topRadius = ele.GetDouble(DbAttributeInstance.DTOP) / 2.0; double bottomRadius = ele.GetDouble(DbAttributeInstance.DBOT) / 2.0; if (topRadius < 1.0e-5 || bottomRadius < 1.0e-5) { Cone cone = new Cone(); cone.Org = new Point(pos).MoveBy(dir, -height / 2.0); cone.Height = new Point(dir) .Mul(height); cone.Offset = new Point(); cone.Radius = topRadius > bottomRadius ? topRadius : bottomRadius; cone.Color = color; session.Save(cone); } else { Snout snout = new Snout(); snout.Org = new Point(pos).MoveBy(dir, -height / 2.0); snout.Height = new Point(dir) .Mul(height); snout.Offset = new Point(); snout.TopRadius = topRadius; snout.BottomRadius = bottomRadius; snout.Color = color; session.Save(snout); } } else if (ele.GetElementType() == DbElementTypeInstance.PYRAMID) { D3Transform eleTrans = currTrans.Multiply(GetTransform(ele)); D3Point pos = eleTrans.Multiply(GeometryUtility.Org); D3Vector zDir = eleTrans.Multiply(D3Vector.D3UP); D3Vector xDir = eleTrans.Multiply(D3Vector.D3EAST); D3Vector yDir = eleTrans.Multiply(D3Vector.D3NORTH); double height = ele.GetDouble(DbAttributeInstance.HEIG); double xBottom = ele.GetDouble(DbAttributeInstance.XBOT); double yBottom = ele.GetDouble(DbAttributeInstance.YBOT); double xTop = ele.GetDouble(DbAttributeInstance.XTOP); double yTop = ele.GetDouble(DbAttributeInstance.YTOP); double xOffset = ele.GetDouble(DbAttributeInstance.XOFF); double yOffset = ele.GetDouble(DbAttributeInstance.YOFF); Pyramid pyramid = new Pyramid(); pyramid.Org = new Point(pos).MoveBy(zDir, -height / 2.0); pyramid.Height = new Point(zDir).Mul(height); pyramid.XAxis = new Point(xDir); pyramid.Offset = new Point().MoveBy(xDir, xOffset).MoveBy(yDir, yOffset); pyramid.BottomXLen = xBottom; pyramid.BottomYLen = yBottom; pyramid.TopXLen = xTop; pyramid.TopYLen = yTop; pyramid.Color = color; session.Save(pyramid); } }