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); } }
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 DbElement PTCA(string direction, Position position) { var error = string.Empty; foreach (DbElement p in new DBElementCollection(_ptse, new TypeFilter(DbElementTypeInstance.PTCAR))) { var pDir = p.GetAsString(DbAttributeInstance.PTCD); var pX = p.GetString(DbAttributeInstance.PX).Clean(); var pZ = p.GetAsString(DbAttributeInstance.PZ).Clean(); var pY = p.GetString(DbAttributeInstance.PY).Clean(); if (pDir == direction && position.XString() == pX && position.YString() == pY && position.ZString() == pZ) { return(p); } } var ptca = _ptse.Create(1, DbElementTypeInstance.PTCAR); int number = _ppointCounter++; //ptca.SetAttribute(DbAttributeInstance.NUMB, number); PMLCommander.RunPMLCommand(ptca, "NUMB", number.ToString(), out error); PMLCommander.RunPMLCommandInParentheses(ptca, "PX", position.XString(), out error); PMLCommander.RunPMLCommandInParentheses(ptca, "PY", position.YString(), out error); PMLCommander.RunPMLCommandInParentheses(ptca, "PZ", position.ZString(), out error); PMLCommander.RunPMLCommand(ptca, "PTCDI", direction, out error); return(ptca); }
public void SCYL(Buildable element) { Direction direction = element.Direction; Position position = element.Position; Size size = element.Size; var ptca = PTCA(direction.X, position); var geom = _gmse.Create(1, DbElementTypeInstance.SCYLINDER); geom.SetAttribute(DbAttributeInstance.TUFL, true); var error = string.Empty; PMLCommander.RunPMLCommand(geom, "PDIA", size.Diameter.ToString(), out error); PMLCommander.RunPMLCommand(geom, "PHEI", size.Height.ToString(), out error); PMLCommander.RunPMLCommand(geom, "PAXIS", $"-P{ptca.GetAsString(DbAttributeInstance.NUMB)}", out error); }
public void AddSpco(SpcoRepresentation spcoRepre) { // TODO: implement better SPCO naming strategy Console.WriteLine("SpecManager.AddSpco"); if (spcoRepre.Stype == string.Empty || spcoRepre.PBore1 == 0) { Console.WriteLine($"## Invalid input for:{spcoRepre.Sdte.GetString(DbAttributeInstance.DTXR)}"); Console.WriteLine($"Stype cannot be empty and is: {spcoRepre.Stype}"); Console.WriteLine($"Bore cannot be 0 and is : {spcoRepre.PBore1}"); return; } var spcoName = Spec.Name() + spcoRepre.Name; if (spcoName.Length > 50) { spcoName = Spec.Name() + spcoRepre.Name.Substring(Spec.Name().Length); } DBElementCollection spcos = new DBElementCollection(Spec, new AttributeRefFilter(DbAttributeInstance.CATR, spcoRepre.Scom)); DbElement spco; if (spcos.Count() > 0) { spco = spcos.First(); } else { spco = BoreSele(spcoRepre.PBore1).CreateLast(DbElementTypeInstance.SPCOMPONENT); } // TODO: do something much better. with the spco name. maybe stype + size + dtxr??? try { spco.SetAttribute(DbAttributeInstance.NAME, spcoName); } catch { for (int i = 0; i < 100; i++) { try { spco.SetAttribute(DbAttributeInstance.NAME, spcoName + i.ToString()); } catch { } } } spco.SetAttribute(DbAttributeInstance.TANS, spcoRepre.Stype); spco.SetAttribute(DbAttributeInstance.CATR, spcoRepre.Scom); PMLCommander.RunPMLCommand(spco, "DETR", spcoRepre.Sdte.FullName(), out string error); PMLCommander.RunPMLCommand(spco, "MATXT", spcoRepre.Smte.FullName(), out error); }
public DbElement ConnectingPTCA(string direction, Position position, double size, int number, string coco) { var ptca = _ptse.Create(1, DbElementTypeInstance.PTCAR); ptca.SetAttribute(DbAttributeInstance.NUMB, number); var error = string.Empty; PMLCommander.RunPMLCommandInParentheses(ptca, "PX", position.XString(), out error); PMLCommander.RunPMLCommandInParentheses(ptca, "PY", position.YString(), out error); PMLCommander.RunPMLCommandInParentheses(ptca, "PZ", position.ZString(), out error); PMLCommander.RunPMLCommand(ptca, "PBOR", size.ToString(), out error); PMLCommander.RunPMLCommand(ptca, "PCON", coco, out error); PMLCommander.RunPMLCommand(ptca, "PTCDI", direction, out error); return(ptca); }
public void PPointForNozzle(Buildable element) { //TODO: handle p3 for direction if (!_usedNozzlePpoints.Contains(3)) { var p = new Position(); p.X = 0; p.Y = 0; p.Z = 0; ConnectingPTCA("Z", p, 0, 3, ""); _usedNozzlePpoints.Add(3); } Direction direction = element.Direction; Position position = element.Position; Size size = element.Size; int ppoint = -1; if (element.NozzleConfig.Ppoint == -1) { if (_nozzlePpointIndex < _validNozzlePpoints.Length) { ppoint = _validNozzlePpoints[_nozzlePpointIndex++]; } } else { ppoint = element.NozzleConfig.Ppoint; } if (_usedNozzlePpoints.Contains(ppoint) || ppoint <= 0 || ppoint > _validNozzlePpoints.Last()) { PMLCommander.RunPMLCommand($"Invalid ppoint {ppoint} supplied for nozzle, will not create"); return; } else { _usedNozzlePpoints.Add(ppoint); } ConnectingPTCA(direction.Z, position, size.Diameter, ppoint, element.NozzleConfig.Coco); }
public void SCTO(Buildable element) { Direction direction = element.Direction; Position position = element.Position; Direction direction2 = element.Direction2; Position position2 = element.Position2; Size size = element.Size; var ptca1 = PTCA(direction.X, position); var ptca2 = PTCA(direction2.X, position2); var geom = _gmse.Create(1, DbElementTypeInstance.SCTORUS); geom.SetAttribute(DbAttributeInstance.TUFL, true); var error = string.Empty; PMLCommander.RunPMLCommand(geom, "PDIA", size.Diameter.ToString(), out error); PMLCommander.RunPMLCommand(geom, "PAAX", $"P{ptca1.GetAsString(DbAttributeInstance.NUMB)}", out error); PMLCommander.RunPMLCommand(geom, "PBAX", $"P{ptca2.GetAsString(DbAttributeInstance.NUMB)}", out error); }
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 SDSH(Buildable element) { Direction direction = element.Direction; Position position = element.Position; Size size = element.Size; var ptca = PTCA(direction.X, position); var geom = _gmse.Create(1, DbElementTypeInstance.SDSH); geom.SetAttribute(DbAttributeInstance.TUFL, true); var error = string.Empty; PMLCommander.RunPMLCommand(geom, "PDIA", size.Diameter.ToString(), out error); PMLCommander.RunPMLCommand(geom, "PHEI", size.Height.ToString(), out error); PMLCommander.RunPMLCommand(geom, "PRAD", size.ZLength.ToString(), out error); PMLCommander.RunPMLCommand(geom, "PAXI", $"P{ptca.GetAsString(DbAttributeInstance.NUMB)}", out error); //geom.SetAttribute(DbAttributeInstance.PHEI, size.YLength); //geom.SetAttribute(DbAttributeInstance.PRAD, size.ZLength.ToString()); //geom.SetAttribute(DbAttributeInstance.PAAX, ptca); }
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); }