private void LoadFiles(DirectoryInfo di) { var files = di.GetFiles("*.cutx"); foreach (var fi in files) { Subassemblies.Add(new SubassemblyViewModel(fi)); } }
protected override void GenerateDrawings() { if (Subassemblies == null) { return; } var selectedSubassemblies = Subassemblies.Where(x => x.IsSelected == true).ToList(); if (selectedSubassemblies.Count == 0) { ShowWarningMessageBox("No subassemblies are selected."); return; } foreach (var assembly in selectedSubassemblies) { var drawingDocument = CreateDrawingDocument(); var sheet = drawingDocument.ActiveSheet; var topRightCorner = sheet.TopRightCorner(); try { // 1. Alter formatting of custom properties. SetCustomPropertyFormat(assembly.Parts); // 2. Add base view. var baseView = sheet.DrawingViews.AddBaseView( Model: (_Document)assembly.Document, Position: drawingDocument.ActiveSheet.CenterPoint(), Scale: Scale, ViewOrientation: ViewOrientationTypeEnum.kFrontViewOrientation, ViewStyle: SelectedViewStyle.EnumValue, ModelViewName: string.Empty, ArbitraryCamera: Type.Missing, AdditionalOptions: Type.Missing ); baseView.AddTopAndLeftProjectedViews( addDimensions: true, drawingDistance: 0.5 ); baseView.AddPartName( partName: baseView.ReferencedDocumentDescriptor.DisplayName.RemoveExtension(), drawingDistance: 0.5 ); // 3. Add part list to the top right corner. var partsList = sheet.AddPartsList(assembly.Document, PartsListLevelEnum.kStructured); // 4. Add base "ISO TOP Right", Hidden line removed, Shaded base view of the subassembly // in the drawing's top right corner. var perspectiveView = sheet.DrawingViews.AddBaseView( Model: (_Document)assembly.Document, Position: drawingDocument.ActiveSheet.TopRightPoint(), Scale: PerspectiveScale, ViewOrientation: ViewOrientationTypeEnum.kIsoTopRightViewOrientation, ViewStyle: SelectedViewStyle.EnumValue, ModelViewName: string.Empty, ArbitraryCamera: Type.Missing, AdditionalOptions: Type.Missing ); perspectiveView.FitToTopRightCorner(sheet); perspectiveView.Position = AddIn.CreatePoint2D( x: perspectiveView.Position.X, y: perspectiveView.Position.Y - partsList.RangeBox.Height() ); } catch (Exception ex) { ShowWarningMessageBox(ex.ToString()); } } }
private void LoadBookSubassemblies() { logger.Debug("开始读取当前产品中的组件清单:"); Subassemblies.Clear(); IRange cells = book.Worksheets["Subassemblies"].Cells; for (int i = 0; i < cells.Rows.RowCount; i++) { var row = cells.Rows[i, 0].EntireRow; string name = cells.Rows[i, 16].Text; if (string.IsNullOrEmpty(name)) { break; } SubassemblyItem item = new SubassemblyItem(); item.Handle = new PropertyElement(row[0, 1]); item.Name = new PropertyElement(row[0, 16]); item.Qty = new PropertyElement(row[0, 17]); item.Width = new PropertyElement(row[0, 18]); item.Height = new PropertyElement(row[0, 19]); item.Depth = new PropertyElement(row[0, 20]); item.XOrigin = new PropertyElement(row[0, 29]); item.YOrigin = new PropertyElement(row[0, 30]); item.ZOrigin = new PropertyElement(row[0, 31]); item.ZRotation = new PropertyElement(row[0, 34]); item.RowIndex = i; string file = string.Format("{3}\\Subassemblies\\{0}_({1}){2}.cutx", productHandle, item.Name.PropertyValue, i + 1, project.JobPath); if (File.Exists(file)) { item.IsUnique = true; } else { item.IsUnique = false; } this.Subassemblies.Add(item); logger.Debug(string.Format("读取组件:{0}/{1}/{2}/{3}/{4}/{5}/{6}/{7}/{8}/{9}", item.Name, item.Qty, item.Width, item.Height, item.Depth, item.XOrigin, item.YOrigin, item.ZOrigin, item.ZRotation, item.Handle)); } logger.Debug("结束读取当前产品中的组件清单。"); }