public override BD.StatusInt OnElementModify(BDE.Element element) { BDE.ShapeElement shape = element as BDE.ShapeElement; if (shape == null) { return(BD.StatusInt.Error); } BG.CurveVector curveVector = shape.GetCurveVector(); BG.DTransform3d world2LoaclDTransform3D; BG.DTransform3d loacl2WorlDTransform3D; BG.DRange3d shapeRange3D; curveVector.IsPlanar(out loacl2WorlDTransform3D, out world2LoaclDTransform3D, out shapeRange3D); BG.DMatrix3d rotMatrix3D = loacl2WorlDTransform3D.Matrix; List <BG.DPoint3d> points = new List <BG.DPoint3d>(); curveVector.GetPrimitive(0).TryGetLineString(points); BG.DSegment3d linex = new BG.DSegment3d(points[0], points[1]); BG.DSegment3d liney = new BG.DSegment3d(points[0], points[3]); int ucellnum = 0; int vcellnum = 0; if (isOutRect) { ucellnum = (int)Math.Ceiling(linex.Length / uaxisoffset); vcellnum = (int)Math.Ceiling(liney.Length / vaxisoffset); } else { ucellnum = (int)Math.Floor(linex.Length / uaxisoffset); vcellnum = (int)Math.Floor(liney.Length / vaxisoffset); } double ufraction = uaxisoffset / linex.Length; double vfraction = vaxisoffset / liney.Length; for (int i = 0; i < vcellnum; i++) { BG.DPoint3d yaxisPoint = liney.PointAtFraction(i * vfraction); for (int j = 0; j < ucellnum; j++) { BG.DPoint3d xaxisPoint = linex.PointAtFraction(j * ufraction); BG.DVector3d xyDVector3D = BG.DVector3d.Add(BG.DPoint3d.Subtract(xaxisPoint, points[0]), BG.DPoint3d.Subtract(yaxisPoint, points[0])); BG.DPoint3d putPoint3D = BG.DPoint3d.Add(points[0], xyDVector3D); CellFunction.PlaceCell(new ArmorCellInfo() { CellName = cellName, CellTrans = rotMatrix3D, Origin = putPoint3D }); Bentley.UI.Threading.DispatcherHelper.DoEvents(); } } return(BD.StatusInt.Success); }
public void OpenCellLib() { OpenFileDialog cellFileDialog = new OpenFileDialog() { Filter = Resources.CellLibraryFilter, Title = "选择Cell库文件" }; if (cellFileDialog.ShowDialog() == DialogResult.OK) { BD.DgnDocument cellFileDocument = BD.DgnDocument.CreateForLocalFile(cellFileDialog.FileName); BD.DgnFile cellDgnFile = BD.DgnFile.Create(cellFileDocument, BD.DgnFileOpenMode.ReadOnly).DgnFile; if (cellDgnFile == null) { Prompt = Resources.PromptHeader + $"无法读取{cellFileDialog.FileName}的DgnDocument对象"; Status = Resources.StatusHeader + Resources.ErrorString; return; } BD.StatusInt loadStatusInt; if (BD.DgnFileStatus.Success != cellDgnFile.LoadDgnFile(out loadStatusInt)) { Prompt = Resources.PromptHeader + "无法载入文件"; Status = Resources.StatusHeader + Resources.ErrorString; return; } if (cellDgnFile.FillDictionaryModel() != BD.StatusInt.Success) { Prompt = Resources.PromptHeader + "填充模型失败"; Status = Resources.StatusHeader + Resources.ErrorString; return; } CellNameTypes.Clear(); ElementProps.Clear(); int index = 0; foreach (var modelindex in cellDgnFile.GetModelIndexCollection()) { BD.DgnModel model = cellDgnFile.LoadRootModelById(out loadStatusInt, modelindex.Id); if (model != null && modelindex.CellPlacementOptions == BD.CellPlacementOptions.CanBePlacedAsCell) { CellNameTypes.Add(model.ModelName + "(" + model.GetModelInfo().CellType.ToString() + ")"); index++; } } string filename; if (CellFunction.AttachLibrary(out filename, cellFileDialog.FileName, "") != BD.StatusInt.Success) { Prompt = Resources.PromptHeader + "附加模型失败"; Status = Resources.StatusHeader + Resources.ErrorString; return; } Prompt = Resources.PromptHeader + $"{cellFileDialog.SafeFileName}已载入!"; Status = Resources.StatusHeader + Resources.SuccessString; } }
public void BrowseCellLib() { OpenFileDialog cellFileDialog = new OpenFileDialog() { Filter = Resources.CellLibraryFilter, Title = "选择Cell库文件" }; if (cellFileDialog.ShowDialog() == DialogResult.OK) { BD.DgnDocument cellFileDocument = BD.DgnDocument.CreateForLocalFile(cellFileDialog.FileName); cellDgnFile = BD.DgnFile.Create(cellFileDocument, BD.DgnFileOpenMode.ReadOnly).DgnFile; if (cellDgnFile == null) { mc.ShowErrorMessage(Resources.StatusHeader + Resources.ErrorString, Resources.PromptHeader + $"无法读取{cellFileDialog.FileName}的DgnDocument对象", false); return; } BD.StatusInt loadStatusInt; if (BD.DgnFileStatus.Success != cellDgnFile.LoadDgnFile(out loadStatusInt)) { mc.ShowErrorMessage(Resources.StatusHeader + Resources.ErrorString, Resources.PromptHeader + "无法载入文件", false); return; } if (cellDgnFile.FillDictionaryModel() != BD.StatusInt.Success) { mc.ShowErrorMessage(Resources.StatusHeader + Resources.ErrorString, Resources.PromptHeader + "填充模型失败", false); return; } CellNames.Clear(); foreach (var modelindex in cellDgnFile.GetModelIndexCollection()) { if (modelindex.CellPlacementOptions == BD.CellPlacementOptions.CanBePlacedAsCell) { CellNames.Add(modelindex.Name); } } string filename; if (CellFunction.AttachLibrary(out filename, cellFileDialog.FileName, "") != BD.StatusInt.Success) { mc.ShowErrorMessage(Resources.StatusHeader + Resources.ErrorString, Resources.PromptHeader + "附加模型失败", false); return; } mc.ShowInfoMessage(Resources.StatusHeader + Resources.SuccessString, Resources.PromptHeader + $"{cellFileDialog.SafeFileName}已载入!", false); CellLibPath = cellDgnFile.GetFileName(); SelectCellName = MasterUnitTooltip = string.Empty; UAxisOffset = UAxisOffset = 0; } }
public static void Command(string unparsed) { //cppAddin.KeyinCommands.Command(""); //PDIWTCodeQueryLib.MeshTest.ConstructMesh(); //PDIWTCodeQueryLib.MeshTest.DgnFileTest(); //PDIWTCodeQueryLib.MeshTest.DgnModel(); PDIWTCodeQueryLib.CellFunction cellFunction = new CellFunction(@"D:\项目\BIM实习\梅山二期\建模中间文件\码头\celllib\节点库.cel"); if (BD.StatusInt.Success == cellFunction.AttachLibrary()) { MessageBox.Show("DONE!"); } }
public CellStatusType(int _armor, int _cost, string _cellfunction) { Armor = _armor; Cost = _cost; CellFunction = (CellFunction)System.Enum.Parse(typeof(CellFunction), _cellfunction); }