//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void SaveReport(int index) { FeatureReport report = _Reports[index]; switch (cbAction.SelectedIndex) { case 0: //Suppress report.FinalizeAction = FinalizeActionEnum.kSuppress; break; case 1: //Delete report.FinalizeAction = FinalizeActionEnum.kDeleteAll; break; case 2: //None report.FinalizeAction = FinalizeActionEnum.kNone; break; } report.Style = cbStyles.Text; foreach (ListViewItem item in lvNewFeatures.Items) { ReportData data = item.Tag as ReportData; switch (item.Text) { case "Delete": data.FinalizeAction = FinalizeActionEnum.kDeleteAll; break; case "Suppress": data.FinalizeAction = FinalizeActionEnum.kSuppress; break; case "None": default: data.FinalizeAction = FinalizeActionEnum.kNone; break; } } foreach (ListViewItem item in lvUnrefDocs.Items) { report.SetUnrefDocAction(item.Text, item.Checked); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public FeatureReport SendToParts(AssemblyDocument ParentDocument, List <ComponentOccurrence> Participants, PartFeature AsmFeature) { ExtrudeFeature extrudeFeature = AsmFeature as ExtrudeFeature; FeatureReport result = new FeatureReport(AsmFeature); if (FeatureUtilities.CreateBackupFile) { FeatureUtilities.BackupFile(Participants); } PlanarSketch asmSketch = extrudeFeature.Profile.Parent as PlanarSketch; foreach (ComponentOccurrence occurrence in Participants) { if (!FeatureUtilities.IsValidOccurrence(occurrence)) { continue; } Matrix invTransfo = occurrence.Transformation; invTransfo.Invert(); PartComponentDefinition partCompDef = occurrence.Definition as PartComponentDefinition; PartFeature newFeature = CopyFeature(partCompDef, AsmFeature, invTransfo); //Place Feature Tag: associativity handling FeatureAttributeManager.CreatePartFeatureTag(ParentDocument, AsmFeature, newFeature, occurrence); ReportData reportData = new ReportData(partCompDef.Document as PartDocument, newFeature); result.addReportData(reportData); } return(result); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void LoadReport(int index) { FeatureReport report = _Reports[index]; switch (report.ReportStatus) { case ReportStatusEnum.kFailed: lbFeatureStatus.Text = " Send to Parts Failed"; lbFeatureStatus.ForeColor = System.Drawing.Color.Red; break; case ReportStatusEnum.kPartial: lbFeatureStatus.Text = " Send to Parts Partially Succeeded"; lbFeatureStatus.ForeColor = System.Drawing.Color.Orange; break; case ReportStatusEnum.kSuccess: lbFeatureStatus.Text = " Send to Parts Succeeded"; lbFeatureStatus.ForeColor = System.Drawing.Color.Green; break; } switch (report.FinalizeAction) { case FinalizeActionEnum.kSuppress: cbAction.SelectedIndex = 0; break; case FinalizeActionEnum.kDeleteAll: case FinalizeActionEnum.kDeleteRetainConsumedSketches: case FinalizeActionEnum.kDeleteRetainSketchesFeatAndWorkFeat: cbAction.SelectedIndex = 1; break; case FinalizeActionEnum.kNone: cbAction.SelectedIndex = 2; break; default: break; } cbStyles.Text = report.Style; lvNewFeatures.Items.Clear(); foreach (ReportData data in report.ReportDataList) { ListViewItem item = null; if (data.PartFeature == null) { item = lvNewFeatures.Items.Add(" --- "); item.UseItemStyleForSubItems = false; item.Tag = data; ListViewItem.ListViewSubItem subItemName = item.SubItems.Add(" --- "); ListViewItem.ListViewSubItem subItemHealth = item.SubItems.Add("Copy Failure"); subItemHealth.ForeColor = System.Drawing.Color.Red; ListViewItem.ListViewSubItem subItemPath = item.SubItems.Add(data.Document.FullFileName); } else { switch (data.FinalizeAction) { case FinalizeActionEnum.kDeleteAll: case FinalizeActionEnum.kDeleteRetainConsumedSketches: case FinalizeActionEnum.kDeleteRetainSketchesFeatAndWorkFeat: item = lvNewFeatures.Items.Add("Delete"); break; case FinalizeActionEnum.kSuppress: item = lvNewFeatures.Items.Add("Suppress"); break; case FinalizeActionEnum.kNone: default: item = lvNewFeatures.Items.Add("None"); break; } item.UseItemStyleForSubItems = false; item.Tag = data; ListViewItem.ListViewSubItem subItemName = item.SubItems.Add(data.FeatureName); ListViewItem.ListViewSubItem subItemHealth = item.SubItems.Add(FeatureUtilities.GetHealthStatusString(data.PartFeature.HealthStatus)); if (data.PartFeature.HealthStatus != HealthStatusEnum.kUpToDateHealth) { subItemHealth.ForeColor = System.Drawing.Color.Red; } ListViewItem.ListViewSubItem subItemPath = item.SubItems.Add(data.Document.FullFileName); } } lvUnrefDocs.Items.Clear(); foreach (string doc in report.UnreferencedDocuments) { ListViewItem item = lvUnrefDocs.Items.Add(doc); item.Checked = report.GetUnrefDocAction(doc); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static FeatureReport SendToPartsAsPattern(AssemblyDocument ParentDocument, List <ComponentOccurrence> Participants, RectangularPatternFeature AsmFeature) { FeatureReport result = new FeatureReport(AsmFeature as PartFeature); if (FeatureUtilities.CreateBackupFile) { FeatureUtilities.BackupFile(Participants); } foreach (ComponentOccurrence occurrence in Participants) { if (!FeatureUtilities.IsValidOccurrence(occurrence)) { continue; } bool loop = true; int elementIdx = 1; Matrix patternElemTransfo = FeatureUtilities.Application.TransientGeometry.CreateMatrix(); //Find first pattern element that affect this occurrence foreach (FeaturePatternElement element in AsmFeature.PatternElements) { foreach (FaceProxy faceProxy in element.Faces) { if (faceProxy.ContainingOccurrence == occurrence) { patternElemTransfo = element.Transform; patternElemTransfo.Invert(); elementIdx = element.Index; loop = false; break; } } if (!loop) { break; } } Matrix invTransfo = occurrence.Transformation; invTransfo.TransformBy(patternElemTransfo); invTransfo.Invert(); PartComponentDefinition partCompDef = occurrence.Definition as PartComponentDefinition; ReportData[] reports = null; RectangularPatternFeature[] newFeatures = CopyRectangularPatternFeature(partCompDef, AsmFeature, invTransfo, elementIdx, occurrence, out reports); foreach (ReportData reportData in reports) { result.addReportData(reportData); } foreach (RectangularPatternFeature newFeature in newFeatures) { result.addReportData(new ReportData(partCompDef.Document as PartDocument, newFeature as PartFeature)); } } return(result); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static FeatureReport SendToPartsAsCollection(AssemblyDocument ParentDocument, List <ComponentOccurrence> Participants, RectangularPatternFeature AsmFeature) { FeatureReport result = new FeatureReport(AsmFeature as PartFeature); if (FeatureUtilities.CreateBackupFile) { FeatureUtilities.BackupFile(Participants); } foreach (ComponentOccurrence occurrence in Participants) { if (!FeatureUtilities.IsValidOccurrence(occurrence)) { continue; } //Find if a pattern element affects this occurrence foreach (FeaturePatternElement element in AsmFeature.PatternElements) { bool affected = false; foreach (FaceProxy faceProxy in element.Faces) { if (faceProxy.ContainingOccurrence == occurrence) { affected = true; break; } } //first occurrence won't be migrated to parts. //Need to migrate parent feature for that if (!affected) { continue; } Matrix invTransfo = occurrence.Transformation; Matrix patternElemTransfo = element.Transform; patternElemTransfo.Invert(); invTransfo.TransformBy(patternElemTransfo); invTransfo.Invert(); PartComponentDefinition partCompDef = occurrence.Definition as PartComponentDefinition; ReportData[] reports = null; ObjectCollection ParentFeatures = FeatureUtilities.CopyParentFeatures(partCompDef, ParentDocument as Document, AsmFeature.ParentFeatures, invTransfo, occurrence, out reports); foreach (ReportData reportData in reports) { //Place Feature Tag: associativity handling //Not supported yet /*FeatureAttributeManager.CreatePartFeatureTag(ParentDocument, * AsmFeature as PartFeature, * reportData.PartFeature, * occurrence);*/ result.addReportData(reportData); } } } return(result); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static FeatureReport SendToPartsAsPattern(AssemblyDocument ParentDocument, List <ComponentOccurrence> Participants, CircularPatternFeature AsmFeature) { FeatureReport result = new FeatureReport(AsmFeature as PartFeature); if (FeatureUtilities.CreateBackupFile) { FeatureUtilities.BackupFile(Participants); } foreach (ComponentOccurrence occurrence in Participants) { if (!FeatureUtilities.IsValidOccurrence(occurrence)) { continue; } bool loop = true; int elementIdx = 1; Matrix patternElemTransfo = FeatureUtilities.Application.TransientGeometry.CreateMatrix(); //Find first pattern element that affect this occurrence foreach (FeaturePatternElement element in AsmFeature.PatternElements) { foreach (FaceProxy faceProxy in element.Faces) { if (faceProxy.ContainingOccurrence == occurrence) { patternElemTransfo = element.Transform; patternElemTransfo.Invert(); elementIdx = element.Index; loop = false; break; } } if (!loop) { break; } } Matrix invTransfo = occurrence.Transformation; invTransfo.TransformBy(patternElemTransfo); invTransfo.Invert(); PartComponentDefinition partCompDef = occurrence.Definition as PartComponentDefinition; ReportData[] reports = null; CircularPatternFeature[] newFeatures = CopyCircularPatternFeature(partCompDef, AsmFeature, invTransfo, elementIdx, occurrence, out reports); foreach (ReportData reportData in reports) { result.addReportData(reportData); } foreach (CircularPatternFeature newFeature in newFeatures) { double count = (double)(newFeature.Count.Value); if (newFeature.HealthStatus != HealthStatusEnum.kUpToDateHealth) { foreach (FeaturePatternElement element in newFeature.PatternElements) { if (element.Faces.Count == 0 && element.Index != 1) { element.Suppressed = true; --count; } } } //Single pattern occurrence -> delete the pattern feature if (count == 1) { newFeature.Delete(false, false, false); continue; } result.addReportData(new ReportData(partCompDef.Document as PartDocument, newFeature as PartFeature)); } } return(result); }