Код: Выделить всё
private double[][] transform2ProssedPartAndGetCache(List prossedPart, double[] explosionDirection, IMathUtility mathUtility)
{
int counter = 0;
double[][] cacheTransform = new double[prossedPart.Count][];
foreach (Component2 component in prossedPart)
{
cacheTransform[counter] = component.Transform2.ArrayData;
double[] transformArray = component.Transform2.ArrayData;
double explosionMagnitude = 0.085;
transformArray[9] += explosionDirection[0] * explosionMagnitude;
transformArray[10] += explosionDirection[1] * explosionMagnitude;
transformArray[11] += explosionDirection[2] * explosionMagnitude;
MathTransform newTransform = mathUtility.CreateTransform(transformArray);
component.Transform2 = newTransform;
counter++;
}
return cacheTransform;
}
Код: Выделить всё
public string ExportStepResultImages(string subAssyParentName, string[] primaryProcessPartArr, string[] secondaryProcessPartArr)
{
string exportPath = "C:\\SolidworksAPI";
object[] tempComponents = swAssembly.GetComponents(true);
Component2[] allComponents = tempComponents.Cast().ToArray();
double[] assemblyBbox = null;
List primaryprocessParts = null;
List secondaryProcessParts = null;
if (subAssyParentName == null) // Sub-assy is the root
{
assemblyBbox = swAssembly.GetBox((int)swBoundingBoxOptions_e.swBoundingBoxIncludeRefPlanes);
primaryprocessParts = OrderProcessPartComponents(allComponents, primaryProcessPartArr);
if(secondaryProcessPartArr.Length > 0)
secondaryProcessParts = OrderProcessPartComponents(allComponents, secondaryProcessPartArr);
}
else
{
Component2 subAssy = GetSubAssyComp(subAssyParentName, allComponents);
if (subAssy == null)
throw new Exception("could not find sub assembly");
//TODO: need to set subAssy as flexible
object[] subAssyChildrenObj = subAssy.GetChildren();
Component2[] subAssyChildren = subAssyChildrenObj.Select(c => (Component2)c).ToArray();
primaryprocessParts = OrderProcessPartComponents(subAssyChildren, primaryProcessPartArr);
if (secondaryProcessPartArr.Length > 0)
secondaryProcessParts = OrderProcessPartComponents(subAssyChildren, secondaryProcessPartArr);
assemblyBbox = subAssy.GetBox(false, false);
}
dynamic result = SnapshotStepResult(primaryprocessParts, secondaryProcessParts, assemblyBbox, exportPath);
}
Но для некоторых По этой причине компоненты PrimaryProssedPart также перемещаются.
Примечание. Это происходит, когда они находятся в одной подсборке в САПР:
Изображение дерева САПР
Но когда они являются последней сборкой, все работает нормально:
Изображение дерева САПР
Подробнее здесь: https://stackoverflow.com/questions/791 ... components
Мобильная версия