//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 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); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 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); }